Skip to content

Add regression test for cross-thread committed memory growth (#814)#815

Draft
mjp41 wants to merge 10 commits intomainfrom
crossthreadmemorygrowth
Draft

Add regression test for cross-thread committed memory growth (#814)#815
mjp41 wants to merge 10 commits intomainfrom
crossthreadmemorygrowth

Conversation

@mjp41
Copy link
Member

@mjp41 mjp41 commented Feb 24, 2026

Add a perf test that reproduces the workload described in issue #814: a pool of worker threads each allocate large chunks (512KB–16MB) and hand them to a random different worker for deallocation. Every thread both allocates and frees, but always frees objects originally allocated by another thread — the pattern reported to cause unbounded committed memory growth in a game engine.

The test runs for a configurable duration (default 30 s), samples snmalloc's committed memory once per second, and compares the average committed memory in the first quarter of the run against the last quarter. If the ratio exceeds 1.5x the test exits with code 1 (FAIL), making it suitable as a CTest regression gate.

The CMake build system auto-discovers the new test directory, so no CMakeLists.txt changes are needed.

Add a perf test that reproduces the workload described in issue #814:
a pool of worker threads each allocate large chunks (512KB–16MB) and
hand them to a random different worker for deallocation.  Every thread
both allocates and frees, but always frees objects originally allocated
by another thread — the pattern reported to cause unbounded committed
memory growth in a game engine.

The test runs for a configurable duration (default 30 s), samples
snmalloc's committed memory once per second, and compares the average
committed memory in the first quarter of the run against the last
quarter.  If the ratio exceeds 1.5x the test exits with code 1 (FAIL),
making it suitable as a CTest regression gate.

The CMake build system auto-discovers the new test directory, so no
CMakeLists.txt changes are needed.
…20s default

- Track per-worker requested/returned bytes (WorkerStats) to compute
  a live-requested lower bound on expected committed memory.
- Print Live(MB) column showing sum(requested) - sum(returned) across
  all workers at each sample point.
- Compare 2nd vs 4th quarter average committed (skip warm-up Q1) for
  a more accurate growth ratio.
- Increase default duration from 30s to 120s for better signal.
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.

1 participant