Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ jobs:
- name: Unload host AppArmor profiles
run: sudo aa-teardown || true

# Some tests (e.g. sh6bench) keep tens of thousands of allocations live at
# once and some allocators (e.g. hardened_malloc) map guard pages per
# large allocation, so they hit vm.max_map_count. Increase to make them pass.
- name: Raise vm.max_map_count for the benchmarks
run: sudo sysctl -w vm.max_map_count=1048576

- name: Build allocator and run benchmarks in Docker
id: docker_build
uses: docker/build-push-action@v7
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ sudo aa-teardown
GitHub CI runners have this profile, so the CI workflow unloads the host
profiles before building.

**`sh6bench` reports "Out of memory" for some allocators although the machine
has plenty of memory?**
Some allocators (hardened_malloc `hm` for example) map guard pages around their
allocations, so every live allocation costs at least one extra kernel mapping,
and `sh6bench` keeps tens of thousands of them alive at once: with 16 threads it
measures over 140000 mappings, more than the default `vm.max_map_count` of
65530. Once the limit is reached, `mprotect` fails and `malloc` returns null.
Raise the limit:
```
sudo sysctl -w vm.max_map_count=1048576
```

## Current Allocators

Supported allocators are as follow, see
Expand Down
12 changes: 10 additions & 2 deletions build-bench-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -649,16 +649,24 @@ fi

if test "$setup_tcg" = "1"; then
checkout tcg $version_tcg https://github.com/google/tcmalloc
# tcmalloc only builds static libraries, so add a target for the shared
# library that bench.sh preloads
set +e
patch -p1 -N -r- < ../../patches/tcg.patch
set -e
if command -v bazelisk > /dev/null; then
USE_BAZEL_VERSION=$version_bazel bazelisk build -c opt tcmalloc
USE_BAZEL_VERSION=$version_bazel bazelisk build -c opt tcmalloc //tcmalloc:libtcmalloc.so
else
bazel build -c opt tcmalloc
bazel build -c opt tcmalloc //tcmalloc:libtcmalloc.so
fi
popd
fi

if test "$setup_hd" = "1"; then
checkout hd $version_hd https://github.com/emeryberger/Hoard
set +e
patch -p1 -N -r- < ../../patches/hoard.patch
set -e
cd src
if [ "`uname -m -s`" = "Darwin x86_64" ] ; then
sed -i_orig 's/-arch arm64/ /g' GNUmakefile # fix the makefile
Expand Down
17 changes: 17 additions & 0 deletions patches/hoard.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/src/source/libhoard.cpp b/src/source/libhoard.cpp
index 0f7567a..0b36a79 100644
--- a/src/source/libhoard.cpp
+++ b/src/source/libhoard.cpp
@@ -163,3 +163,12 @@ extern "C" {
// include gnuwrapper here to aid inlining of xxmalloc + friends
#include "wrappers/gnuwrapper.cpp"
#endif
+
+
+// Heap-Layers' macwrapper.cpp defines these as weak defaults; its linux
+// wrapper.cpp calls them but libhoard.cpp did not define them, so libhoard.so
+// ended up with undefined symbols.
+extern "C" {
+ __attribute__((weak)) void xxfree_sized (void * ptr, size_t) { xxfree(ptr); }
+ __attribute__((weak)) void xxfree_aligned_sized (void * ptr, size_t, size_t) { xxfree(ptr); }
+}
14 changes: 14 additions & 0 deletions patches/tcg.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/tcmalloc/BUILD b/tcmalloc/BUILD
index 47b0f065..cfb1570a 100644
--- a/tcmalloc/BUILD
+++ b/tcmalloc/BUILD
@@ -1610,3 +1610,9 @@ cc_library(
],
deps = ["@com_google_absl//absl/base:core_headers"],
)
+
+cc_binary(
+ name = "libtcmalloc.so",
+ linkshared = 1,
+ deps = [":tcmalloc"],
+)
Loading