Skip to content

Speed up replay parsing with more threads and jemalloc - #407

Merged
bneradt merged 1 commit into
yahoo:masterfrom
bneradt:speed-up-replay-parsing
Oct 13, 2026
Merged

bneradt merged 1 commit into
yahoo:masterfrom
bneradt:speed-up-replay-parsing

Conversation

@bneradt

@bneradt bneradt commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

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 threads, jemalloc) 12-13 s ~495 15.5 s

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings October 13, 2026 22:34
@bneradt bneradt self-assigned this Oct 13, 2026
@bneradt bneradt added the enhancement New feature or request label Oct 13, 2026

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@bneradt
bneradt force-pushed the speed-up-replay-parsing branch 2 times, most recently from bf4315d to d6b36d6 Compare October 13, 2026 23:20
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
bneradt force-pushed the speed-up-replay-parsing branch from d6b36d6 to 9d38659 Compare October 13, 2026 23:20
@bneradt
bneradt merged commit 0d61ffd into yahoo:master Oct 13, 2026
6 checks passed
@bneradt
bneradt deleted the speed-up-replay-parsing branch October 13, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants