Skip to content

replace build_bench_env.sh with a Makefile - #243

Open
derSteFfi wants to merge 31 commits into
daanx:masterfrom
derSteFfi:build_with_makefile
Open

derSteFfi wants to merge 31 commits into
daanx:masterfrom
derSteFfi:build_with_makefile

Conversation

@derSteFfi

@derSteFfi derSteFfi commented Aug 7, 2025 •

Copy link
Copy Markdown
Contributor

pushing this draft as a starter to get your opinions - I'll be on vacation the next weeks and won't be working on it anyway. There are a few open tasks, but the general vibe should already come across. Feedback very welcome.

Decisions made:

  • VERSIONS: demand versions instead of reporting them in the end
  • switched from git cloning to grabbing a snapshot of the reqeuested version from github
  • dh: move build directory (dh/src/build -> dh/build)
  • lua: moved to extern benchmarks because it is built in extern/
  • benchmarks: if something is updated, CMakeLists.txt needs to be touched (or replaced with a Makefile longterm)
  • sm: instead of default target, switched to building supermalloc only
  • linux: updated version to LTS series
  • lean: switched to smaller build target

TODO

  • put archives in extra storage after versionizing them (see here) docker caches these already
  • adapt CI-scripts to use Makefile
  • package installation
    • document in README: bazel5 missing, rest is done
    • move to CI instead of build_bench_env.sh
  • bench.sh needs to be adapted in the way it finds 'installed allocators' -- fixed in Detect allocators present and functional #247

open Questions:

  1. partial_checkout
    1. scudo
    2. lp Also, github does not serve archives on that repo. Re-add when solved.
  2. pa: re-add, but smaller? (see here), but: Add partitionalloc #184
  3. sed patches in Makefile: port to proper patch? at least gd, hd, rp are patched with sed right now, we could port that to a patch

@derSteFfi derSteFfi changed the title replace build_bench_env.sh with a Makefile Draft: replace build_bench_env.sh with a Makefile Aug 7, 2025
@derSteFfi
derSteFfi marked this pull request as draft August 7, 2025 13:35
@derSteFfi

Copy link
Copy Markdown
Contributor Author

one ToDo I forgot in notes: tar can exclude files from extraction. The current shell-script does delete a few folders in a few repositories - we could modify the tar call to not extract them in the first place.

@derSteFfi
derSteFfi force-pushed the build_with_makefile branch 2 times, most recently from 1f4928c to ffbdf87 Compare September 25, 2025 14:34
@derSteFfi

Copy link
Copy Markdown
Contributor Author

the remaining CI failures are not specific to the Makefile but actual problems, so marking this ready.

@derSteFfi
derSteFfi marked this pull request as ready for review October 7, 2025 13:01
Comment thread Dockerfile Resolved
Comment thread Makefile Resolved
Comment thread Makefile Resolved
Comment thread Makefile Resolved
@jvoisin
jvoisin requested review from Copilot, daanx and mjp41 October 7, 2025 14:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces the build_bench_env.sh script with a Makefile-based build system to improve consistency and maintainability. The change switches from git cloning to downloading versioned archives from GitHub and centralizes version management.

Key changes:

  • Replace shell script with comprehensive Makefile for building allocators and benchmarks
  • Introduce VERSIONS file to centralize version management across all components
  • Move package installation documentation from script to README with per-distribution instructions

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
build-bench-env.sh Add python-six dependency for ArchLinux package installation
bench.sh Update library paths and remove hardcoded version variables
VERSIONS New file defining versions and sources for all allocators and benchmarks
README.md Replace build script documentation with Makefile usage and detailed dependency lists
Makefile New comprehensive build system with targets for all allocators and benchmarks
Dockerfile Update to use Makefile instead of build script and add package installations
.github/workflows/all.yml Remove Fedora exclusion from CI matrix

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread build-bench-env.sh Resolved
Comment thread Makefile Resolved
Comment thread README.md Resolved

@mjp41 mjp41 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking pretty tidy. Thanks for working on this.

Comment thread Makefile Resolved
Comment thread Makefile Resolved
Comment thread Makefile Resolved
Comment thread Makefile Resolved
Comment thread Makefile Resolved
Comment thread VERSIONS Resolved
Comment thread Makefile Resolved
Comment thread Makefile Resolved

@mjp41 mjp41 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the changes.

@jvoisin, @derSteFfi I don't want to hold these changes holding off on fixing issues for individual allocators/platforms. But I really like to only have a Green CI. Thoughts?

Comment thread Makefile Resolved
Comment thread Makefile Resolved
Comment thread Makefile Resolved
@derSteFfi

Copy link
Copy Markdown
Contributor Author

Absolutely agree. I still have at least scudo and lp on my list and will re-check all comments here afterwards. With that fixed, I would also be pro-merging to make it easier to hunt individual bugs. The branch-switching sometimes takes time, and we would have a clear stand - fixing individual things is much easier than to always have to model the whole process.

@derSteFfi
derSteFfi force-pushed the build_with_makefile branch from 0266c64 to 2d0082e Compare October 13, 2025 13:22
@derSteFfi

Copy link
Copy Markdown
Contributor Author

@jvoisin the MR is up-to-date with master - what do you think about merging?

@jvoisin

jvoisin commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator

~All the tests are failing :/

@derSteFfi

Copy link
Copy Markdown
Contributor Author

sorry, missed a reference to build-bench-env.sh. Should be fixed.

@jvoisin

jvoisin commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator

There are still a bunch of failures it seems

@derSteFfi

Copy link
Copy Markdown
Contributor Author

these are the same we have on master, except that fedora is deactivated in the CI on master (don't remember why). alpine base container and ubuntu/tcg fail with master, too.

@jvoisin

jvoisin commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator

Then it does look good to me. I'll let @daanx hit the merge button as it's his project :)

@derSteFfi
derSteFfi force-pushed the build_with_makefile branch from d0028ed to 90a3c8a Compare July 9, 2026 10:11
@derSteFfi

Copy link
Copy Markdown
Contributor Author

re-synced with master. Also added rmalloc and fixed sc. Would love to not have to resolve merge conflicts like these every few months...

@derSteFfi derSteFfi changed the title Draft: replace build_bench_env.sh with a Makefile replace build_bench_env.sh with a Makefile Jul 9, 2026
@derSteFfi

Copy link
Copy Markdown
Contributor Author

I missed a few bumps in the merge, should be synchronized now.

@derSteFfi
derSteFfi force-pushed the build_with_makefile branch from bc691e3 to c976d1a Compare October 26, 2026 09:39
@derSteFfi

Copy link
Copy Markdown
Contributor Author

rebased onto master, added support for versioned archives.

Replace the build-bench-env.sh usage sections with make targets
(allocs, benchmarks, individual allocators, -j behaviour), move the
per-distribution package lists to match the Dockerfile, and mention
VERSIONS as the single place to bump allocator versions.
Download each project into archives/<name>-<label>.tar.gz, where the
label is the version tag or a short sha, and unpack from there into
extern/<name>. The version is now visible on disk, and each unpack
stamp records "<label> <sha>": the pin the build tree was made from.

Version bumps were invisible to make before: with unversioned archive
names and empty stamps, an existing extern/<name> tree was never
refreshed after VERSIONS moved. Freshness is now keyed by the pin: the
archive target is named after the pinned version, so editing a pin
gives the project a new prerequisite and make re-fetches, re-unpacks,
and rebuilds exactly that project, while everything else stays put.
The archive targets are declared explicitly (static pattern rules) to
keep make from treating them as intermediate files it may silently
skip or delete.

lp and scudo unpack by sparse git clone instead of using an archive.
Pins are full shas now, and git clone -b only accepts branch names, so
fetch the sha explicitly and check it out detached; a marker file
named after their pin, archives/<name>-<label>.clone, triggers their
re-clone and nothing else. Add a clean-archives target that sweeps
stale archives and markers but keeps the pinned ones, and in the
README point at VERSIONS instead of build-bench-env.sh for the
versions.
The bazel tcmalloc target is a static library, so bench.sh finds no shared
object to preload and runs the job with an empty allocator list. Add a
linkshared cc_binary for it.
hardened_malloc maps guard pages per allocation and sh6bench keeps tens of
thousands of them alive, so it needs over 140000 mappings; at the default
65530 mprotect fails and malloc returns null although memory is free.
libhoard.cpp does not define them but Heap-Layers' wrapper.cpp calls them, so
libhoard.so has undefined symbols and every c++ test dies at its first sized
delete. Define them as weak defaults, as the mac wrapper does.
The exclusion was for a bazel target error that is gone at the pinned version.
Fedora has no bazel installed and alpine does not compile tcmalloc with clang.
The bench-env image is cached per platform (type=gha, scope=buildkit_<platform>)
and later jobs reuse it on other machines, but RocksDB compiles with
-march=native when PORTABLE is unset (it ends up in make_config.mk). A db_bench
built on a machine with AVX-512 therefore dies with SIGILL on a runner without
it, before it prints a single line. That is the rocksdb:mi and rocksdb:ff
failures in the current runs: the same cached binary is gone after 0.1 s with no
output on some jobs, while others pass the test.

PORTABLE=1 keeps the binary runnable wherever the cache delivers it, and the
measured time no longer depends on which machine built the cache: locally
fillrandom takes 10.0 s native and 10.2 s portable.
A run's own output goes to <test>-<alloc>-out.txt and that file does not reach a
CI log, so a test that dies says nothing beyond its name: in the failing rocksdb
jobs the log shows the run starting and the next test starting 0.1 s later, with
no error text anywhere. Report the exit status - naming the signal when the run
was killed by one - and the tail of the output file, on stderr so buildkit
records it.
build-bench-env.sh goes away in this branch, so its new hoard and tcmalloc
patches are kept as files under patches/ and the Makefile applies them; the
vm.max_map_count step and its comment come over unchanged.
The branch changes only build-bench-env.sh, which this branch deletes, so the
merge itself is empty here; the make-world equivalent is the PORTABLE=1 in
rocksdb_ENV that follows.
The same change as !33, for the make world. CI caches bench-env per platform
while RocksDB compiles with -march=native when PORTABLE is unset, so a db_bench
built on one CPU generation dies with SIGILL on a runner of another - that is
the rocksdb:mi and rocksdb:ff failures in the current runs. Locally the portable
binary costs 10.2 s against 10.0 s native on fillrandom.
Guarder resolves the real pthread_create with
dlopen("libpthread.so.0", RTLD_NOLOAD).  Since glibc 2.34 that library is an
empty compatibility stub that nothing loads, so the handle comes back NULL and
dlsym(NULL, name) searches the global scope from the front - which finds
guarder's own interposer.  Every pthread_create then recursed into itself until
the 128-entry thread table was full and guarder aborted with "maximum
concurrent thread limit reached (128)"; an interposer mounted in front of
libguarder.so counts 128 creations and no joins for "./mstress 4 50 25".  That
is the mstressN and rptestN failure in the gd jobs on ubuntu and fedora, and
with the fallback both return to exit 0.  RTLD_NEXT starts the search after
libguarder.so, at the real libc; the same file already resolves malloc and free
that way.  larsonN-sized still fails, for a reason unrelated to the lookup.
The branch changes only build-bench-env.sh, which this branch deletes, so the
merge itself is empty here apart from the new patches/gd.patch; the make-world
call to patch follows.
The same change as 801c4bf, for the make world: apply patches/gd.patch before
building guarder. Only aarch64 had its own rule here, and it would have become
incomplete on the other platforms, so the rule now covers both and keeps just
the getentropy fix conditional.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants