GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Remove global rmem page slab by ianks · Pull Request #392 · msgpack/msgpack-ruby Conversation
|
| warm, paired (no-slab this PR vs slab, not ractor-safe) | Δ | 95% CI |
|---|---|---|
| wall time | −0.1% | −0.8% to +4.9% |
| CPU | −0.3% | −1.9% to +3.9% |
| allocations | identical | — |
Memory usage seems fine as well, with the bare-xmalloc (this PR) having a higher peak as decay time increases (this is expected, and not a problem).
| sustained decode | slab (today) | xmalloc (this PR) |
|---|---|---|
dirty_decay_ms:10000 (default) |
43 MiB | 102 MiB |
dirty_decay_ms:1000 |
33 MiB | 34 MiB |
| peak (live working set) | ~113 MiB | ~114 MiB |
ruby --yjit)Generated by /tmp/msgpack_format_yjit_pr_body.py from raw benchmark/ips output; table values were parsed, not hand-entered.
ruby 4.0.4 (2026-05-12 revision b89eb1bcbf) +YJIT +PRISM [arm64-darwin25]bundle exec rake compile && bundle exec ruby --yjit -Ilib -Iext <generated bench>benchmark/ips warmup 15s, measurement 60s per case2026-06-15T22:14:36Z; finished: 2026-06-15T22:29:47Zorigin/master: 09c914dPR branch: b82fefc| benchmark | origin/master | PR branch | delta |
|---|---|---|---|
| pack-plain | 5.729M i/s (±2.7%) | 5.349M i/s (±1.3%) | -6.6% |
| pack-structured | 2.873M i/s (±2.8%) | 2.787M i/s (±1.2%) | -3.0% |
| pack-extended | 2.077M i/s (±1.8%) | 1.913M i/s (±2.1%) | -7.9% |
| unpack-plain | 4.809M i/s (±1.1%) | 4.553M i/s (±1.4%) | -5.3% |
| unpack-structured | 1.100M i/s (±1.6%) | 1.058M i/s (±1.2%) | -3.8% |
| unpack-extended | 1.523M i/s (±3.2%) | 1.462M i/s (±2.6%) | -4.0% |
Warming up --------------------------------------
pack-plain 500.901k i/100ms
pack-structured 274.579k i/100ms
pack-extended 201.774k i/100ms
unpack-plain 437.897k i/100ms
unpack-structured 108.509k i/100ms
unpack-extended 149.952k i/100ms
Calculating -------------------------------------
pack-plain 5.729M (± 2.7%) i/s - 343.618M in 60.030490s
pack-structured 2.873M (± 2.8%) i/s - 172.436M in 60.066053s
pack-extended 2.077M (± 1.8%) i/s - 124.696M in 60.046588s
unpack-plain 4.809M (± 1.1%) i/s - 288.574M in 60.010534s
unpack-structured 1.100M (± 1.6%) i/s - 66.082M in 60.098069s
unpack-extended 1.523M (± 3.2%) i/s - 91.321M in 60.032914s
Warming up --------------------------------------
pack-plain 419.123k i/100ms
pack-structured 261.892k i/100ms
pack-extended 186.273k i/100ms
unpack-plain 422.506k i/100ms
unpack-structured 103.562k i/100ms
unpack-extended 144.592k i/100ms
Calculating -------------------------------------
pack-plain 5.349M (± 1.3%) i/s - 321.048M in 60.029030s
pack-structured 2.787M (± 1.2%) i/s - 167.349M in 60.053708s
pack-extended 1.913M (± 2.1%) i/s - 114.744M in 60.000081s
unpack-plain 4.553M (± 1.4%) i/s - 273.361M in 60.055928s
unpack-structured 1.058M (± 1.2%) i/s - 63.484M in 60.031311s
unpack-extended 1.462M (± 2.6%) i/s - 87.767M in 60.056025s
Sorry, something went wrong.
There was an error while loading. Please reload this page.
msgpack_rmem_* slab allocator
bb0785b to
b82fefc
Compare
|
So the memory arena is something I've always been dubious of the benefit of, so I wouldn't mind getting rid of it. That being said, MessagePack needs way more changes than this to be usable in Ractors. #390 is on my TODO list, I'll come around to it eventually. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The page-recycling slab was a process-global msgpack_rmem_t mutated through an unsynchronized bitmask, so concurrent packing or unpacking could race on it. Drop the slab and serve rmem pages from xmalloc/xfree instead. Modern arena-based mallocs are good at recycling these allocations without maintaining process-global mutable state in msgpack-ruby.
There was an error while loading. Please reload this page.
|
@byroot Added micro-benchmarks to the PR body. On m4 pro with jemalloc, it's slighly faster to just plain xmalloc 🤷🏻 Also, I've removed all Ractor references from this PR, so it should be independently mergeable. Hope you are well! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
msgpack_rmem_* slab allocator
After looking through the C code a bit more, I didn't find any remaining global mutable state that would make The non-shareable I'm tempted to add |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I tried this rebased on master ( The cases from #390:
Also: 8 Ractors, each with its own So once the slab is gone, objects created inside a Ractor work. What's left is on the Ruby side: Diff I used on top of this branch: --- a/ext/msgpack/extconf.rb +++ b/ext/msgpack/extconf.rb have_func("rb_gc_mark_locations", "ruby.h") # Missing on TruffleRuby +have_func("rb_ext_ractor_safe", "ruby.h") # Ruby 3.0+ --- a/ext/msgpack/rbinit.c +++ b/ext/msgpack/rbinit.c RUBY_FUNC_EXPORTED void Init_msgpack(void) { +#ifdef HAVE_RB_EXT_RACTOR_SAFE + rb_ext_ractor_safe(true); +#endif + VALUE mMessagePack = rb_define_module("MessagePack"); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.