Repository navigation
Speed up replay parsing with more threads and jemalloc - #407
Merged
Merged
Conversation
bneradt
force-pushed
the
speed-up-replay-parsing
branch
2 times, most recently
from
October 13, 2026 23:20
bf4315d to
d6b36d6
Compare
Loading a prod sim replay of 173k transactions in 5,100 files took about 36 seconds before any traffic ran. The time was neither disk nor the host: a cold page cache took as long as a warm one with no I/O wait, and the 48-thread box stayed three quarters idle. Parsing was CPU bound in yaml-cpp, but the parser pool was capped at 12 threads, and glibc malloc spent about a third of the parsing CPU allocating and freeing yaml-cpp's per-element nodes. This patch addresses both. Replay files are now parsed on one thread per hardware thread, and on Linux the binaries link jemalloc as the allocator when pkg-config finds it. The jemalloc link is optional and can be turned off with PV_ENABLE_JEMALLOC=OFF; static builds use it only when its static archive is installed, and otherwise every build keeps the system allocator. The development and CI images now install jemalloc, including the static archive on Alpine, so CI and the static portable release binaries use it too. Together these cut parsing of that replay from about 36 seconds to 12, and the time spent freeing the parsed replay at exit from about 6 seconds to 2. Measured on a 48-thread (2 x 12-core, hyperthreaded) host parsing that replay with a parse-only client: Build Parse time CPU-seconds Total run --------------------------- ---------- ----------- --------- master (12 threads, glibc) 35-37 s ~400 42 s 24 threads, glibc 19 s ~407 26 s 24 threads, jemalloc 13 s ~259 15 s this patch (48, jemalloc) 12-13 s ~495 15.5 s Co-Authored-By: Claude Opus 5.5 (low reasoning) <[email protected]>
bneradt
force-pushed
the
speed-up-replay-parsing
branch
from
October 13, 2026 23:20
d6b36d6 to
9d38659
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Loading a prod sim replay of 173k transactions in 5,100 files took about
36 seconds before any traffic ran. The time was neither disk nor the
host: a cold page cache took as long as a warm one with no I/O wait,
and the 48-thread box stayed three quarters idle. Parsing was CPU bound
in yaml-cpp, but the parser pool was capped at 12 threads, and glibc
malloc spent about a third of the parsing CPU allocating and freeing
yaml-cpp's per-element nodes.
This patch addresses both. Replay files are now parsed on one thread per
hardware thread, and on Linux the binaries link jemalloc as the
allocator when pkg-config finds it. The jemalloc link is optional and
can be turned off with PV_ENABLE_JEMALLOC=OFF; static builds use it only
when its static archive is installed, and otherwise every build keeps
the system allocator. The development and CI images now install
jemalloc, including the static archive on Alpine, so CI and the static
portable release binaries use it too. Together these cut parsing of that
replay from about 36 seconds to 12, and the time spent freeing the
parsed replay at exit from about 6 seconds to 2.
Measured on a 48-thread (2 x 12-core, hyperthreaded) host parsing that
replay with a parse-only client:
🤖 Generated with Claude Code