> http://build-failures.rhaalovely.net/powerpc/2019-07-29/benchmarks/wrk.log

It requires a move from __sync to __atomic. Debian did that already [0],
so i've taken their stuff.

While wrk is written in C, the use of __atomic functions requires
estdc++ and ports-gcc (we can't use COMPILER_LANGS=c).

It builds [1] and runs fine on macppc and amd64 with multiple threads.

Comments/feedback are welcome,

Charlène.


[0] https://sources.debian.org/patches/wrk/4.0.2-2/debian-changes/
[1] https://bin.charlenew.xyz/wrk.log


Index: Makefile
===================================================================
RCS file: /cvs/ports/benchmarks/wrk/Makefile,v
retrieving revision 1.2
diff -u -p -u -p -r1.2 Makefile
--- Makefile    12 Jul 2019 20:43:43 -0000      1.2
+++ Makefile    12 Aug 2019 19:40:01 -0000
@@ -5,6 +5,7 @@ COMMENT =       modern HTTP benchmarking tool
 GH_ACCOUNT =   wg
 GH_PROJECT =   wrk
 GH_TAGNAME =   4.1.0
+REVISION =     0
 
 CATEGORIES =   benchmarks
 
@@ -15,6 +16,9 @@ PERMIT_PACKAGE =      Yes
 
 WANTLIB +=     c crypto luajit-5.1 m pthread ssl
 
+# __atomic support (GCC>4.7.4)
+COMPILER =             base-clang ports-gcc
+
 LIB_DEPENDS =  lang/luajit
 
 USE_GMAKE =    Yes
@@ -26,6 +30,12 @@ MAKE_ENV =   WITH_LUAJIT=${LOCALBASE} WITH
 MAKE_ENV +=    LIBS=-lc++abi
 WANTLIB +=     c++abi
 .endif
+
+.if ${MACHINE_ARCH:Mhppa} || ${MACHINE_ARCH:Mpowerpc}
+MAKE_ENV +=    LIBS=-latomic
+WANTLIB +=     atomic
+.endif
+
 
 NO_TEST =      Yes
 
Index: patches/patch-src_stats_c
===================================================================
RCS file: patches/patch-src_stats_c
diff -N patches/patch-src_stats_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_stats_c   12 Aug 2019 19:40:01 -0000
@@ -0,0 +1,33 @@
+$OpenBSD$
+
+ppc, hppa: we can't use 64-bit __sync operators there
+
+Index: src/stats.c
+--- src/stats.c.orig
++++ src/stats.c
+@@ -21,12 +21,21 @@ void stats_free(stats *stats) {
+ 
+ int stats_record(stats *stats, uint64_t n) {
+     if (n >= stats->limit) return 0;
+-    __sync_fetch_and_add(&stats->data[n], 1);
+-    __sync_fetch_and_add(&stats->count, 1);
++    __atomic_fetch_add(&stats->data[n], 1, __ATOMIC_SEQ_CST);
++    __atomic_fetch_add(&stats->count, 1, __ATOMIC_SEQ_CST);
+     uint64_t min = stats->min;
+     uint64_t max = stats->max;
+-    while (n < min) min = __sync_val_compare_and_swap(&stats->min, min, n);
+-    while (n > max) max = __sync_val_compare_and_swap(&stats->max, max, n);
++    while (n < min) {
++        __atomic_compare_exchange(&stats->min, &min, &n, false,
++                                  __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
++        min = stats->min;
++    }
++    while (n > max) {
++        __atomic_compare_exchange(&stats->max, &max, &n, false,
++                                  __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
++        max = stats->max;
++   }
++
+     return 1;
+ }
+ 

Reply via email to