Skip to content

partial port to macos #250

@zooko

Description

@zooko

With the patch below I can run at least some benches with at least some allocators on macos 26.2:

output:

#------------------------------------------------------------------
# test    alloc   time  rss    user  sys  page-faults page-reclaims
gs          je    00.15 31760 0.13 0.01 372 3047
gs          mi2   00.13 31376 0.12 0.00 371 2082
gs          sn    00.14 31408 0.13 0.01 371 3013
lua         je    00.33 72288 1.94 0.91 7023 198697
lua         mi2   00.32 71776 1.91 0.69 7021 199101
lua         sn    00.34 71360 1.92 0.91 7021 198889

patch:

diff --git a/bench.sh b/bench.sh
index c03fe2d..43aec96 100755
--- a/bench.sh
+++ b/bench.sh
@@ -31,6 +31,7 @@ readonly tests_exclude_macos="sh6bench sh8bench redis"
 readonly version_redis=6.2.7
 readonly version_rocksdb=8.1.1
 readonly version_linux=6.5.1
+readonly version_lua=5.5.0
 
 # --------------------------------------------------------------------
 # Environment
@@ -160,7 +161,7 @@ if test "$use_packages" = "1"; then
   fi
 fi
 
-readonly luadir="$localdevdir/lua"
+readonly luadir="$localdevdir/lua/lua-${version_lua}"
 readonly leandir="$localdevdir/lean"
 readonly leanmldir="$leandir/../mathlib"
 readonly redis_dir="$localdevdir/redis-$version_redis/src"
diff --git a/bench/CMakeLists.txt b/bench/CMakeLists.txt
index f9c95e3..36bf6cd 100644
--- a/bench/CMakeLists.txt
+++ b/bench/CMakeLists.txt
@@ -114,4 +114,9 @@ target_link_libraries(glibc-simple pthread)
 add_executable(glibc-thread glibc-bench/bench-malloc-thread.c)
 target_link_libraries(glibc-thread pthread)
 
-add_subdirectory(security)
+option(BUILD_SECURITY_BENCHMARKS "Build security test benchmarks" OFF)
+
+if(BUILD_SECURITY_BENCHMARKS)
+    add_subdirectory(security)
+endif()
+
diff --git a/build-bench-env.sh b/build-bench-env.sh
index bc5a5a7..e9855b3 100755
--- a/build-bench-env.sh
+++ b/build-bench-env.sh
@@ -54,7 +54,7 @@ readonly version_mi2=v2.1.2
 readonly version_mng=master  # ~unmaintained
 readonly version_nomesh=$version_mesh
 readonly version_pa=main
-readonly version_rp=1.4.5
+readonly version_rp=feb43aee0d4dcca9fd91b3dd54311c34c6cc6187 # 2025-10-26
 readonly version_sc=master   # unmaintained since 2016
 readonly version_scudo=main
 readonly version_sg=master   # ~unmaintained since 2021
@@ -69,7 +69,7 @@ readonly version_yal=main
 readonly version_redis=6.2.7
 readonly version_lean=21d264a66d53b0a910178ae7d9529cb5886a39b6 # build fix for recent compilers
 readonly version_rocksdb=8.1.1
-readonly version_lua=v5.4.7
+readonly version_lua=5.5.0
 readonly version_linux=6.5.1
 
 # HTTP-downloaded files checksums
@@ -375,6 +375,24 @@ function check_checksum {  # name, sha256sum
   fi
 }
 
+function wgetunpack {  # name, url-up-to-fname, fname-incl-version
+  phase "build $1: version $3"
+  pushd $devdir
+  if test "$rebuild" = "1"; then
+    rm -rf "$1"
+  fi
+  if test -d "$1"; then
+    echo "$devdir/$1 already exists; no need to wget+unpack"
+  else
+    mkdir "$devdir/$1"
+    cd "$devdir/$1"
+    wget --no-verbose "$2$3"
+    tar xf "$3"
+    rm "$3"
+  fi
+  popd
+}
+
 function aptinstall {
   echo ""
   echo "> $SUDO apt install $1"
@@ -460,7 +478,7 @@ if test "$setup_packages" = "1"; then
       ghostscript libatomic gflags-dev readline-dev snappy-dev"
     apkinstall "bazel@testing"
   elif brew --version 2> /dev/null >/dev/null; then
-    brewinstall "dos2unix wget cmake ninja automake libtool gnu-time gmp mpir gnu-sed \
+    brewinstall "dos2unix wget cmake ninja automake libtool gnu-time gmp gnu-sed \
       ghostscript bazelisk gflags snappy"
   elif grep -q 'Arch Linux' /etc/os-release; then
     sudo pacman -S dos2unix wget cmake ninja automake libtool time gmp sed ghostscript bazelisk gflags snappy
@@ -640,11 +658,11 @@ if test "$setup_rp" = "1"; then
   if test -f build.ninja; then
     echo "$devdir/rpmalloc is already configured; no need to reconfigure"
   else
-    python3 configure.py
+    python3 configure.py -t macos
   fi
   # fix build using clang-16
   # see https://github.com/mjansson/rpmalloc/issues/316
-  sed -i 's/-Werror//' build.ninja
+  sed -i.bak 's/-Werror//' build.ninja && rm -f build.ninja.bak
   ninja
   popd
 fi
@@ -849,8 +867,7 @@ if test "$setup_bench" = "1"; then
   popd
 
   phase "get lua"
-  checkout lua $version_lua https://github.com/lua/lua
-  popd
+  wgetunpack lua https://www.lua.org/ftp/ lua-${version_lua}.tar.gz
 
   phase "build benchmarks"
 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions