summaryrefslogtreecommitdiff
path: root/gc/mmtk/src/api.rs
AgeCommit message (Collapse)Author
2025-12-22[ruby/mmtk] Implement Ruby heapPeter Zhu
This heap emulates the growth characteristics of the Ruby default GC's heap. By default, the heap grows by 40%, requires at least 20% empty after a GC, and allows at most 65% empty before it shrinks the heap. This is all configurable via the same environment variables the default GC uses (`RUBY_GC_HEAP_FREE_SLOTS_GOAL_RATIO`, `RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO`, `RUBY_GC_HEAP_FREE_SLOTS_MAX_RATIO`, respectively). The Ruby heap can be enabled via the `MMTK_HEAP_MODE=ruby` environment variable. Compared to the dynamic heap in MMTk (which uses the MemBalancer algorithm), the Ruby heap allows the heap to grow more generously, which uses a bit more memory but offers significant performance gains because it runs GC much less frequently. We can see in the benchmarks below that this Ruby heap heap gives faster performance than the dynamic heap in every benchmark, with over 2x faster in many of them. We see that memory is often around 10-20% higher with certain outliers that use significantly more memory like hexapdf and erubi-rails. We can also see that this brings MMTk's Ruby heap much closer in performance to the default GC. Ruby heap benchmark results: -------------- -------------- ---------- --------- bench ruby heap (ms) stddev (%) RSS (MiB) activerecord 233.6 10.7 85.9 chunky-png 457.1 1.1 79.3 erubi-rails 1148.0 3.8 133.3 hexapdf 1570.5 2.4 403.0 liquid-c 42.8 5.3 43.4 liquid-compile 41.3 7.6 52.6 liquid-render 102.8 3.8 55.3 lobsters 651.9 8.0 426.3 mail 106.4 1.8 67.2 psych-load 1552.1 0.8 43.4 railsbench 1707.2 6.0 145.6 rubocop 127.2 15.3 148.8 ruby-lsp 136.6 11.7 113.7 sequel 47.2 5.9 44.4 shipit 1197.5 3.6 301.0 -------------- -------------- ---------- --------- Dynamic heap benchmark results: -------------- ----------------- ---------- --------- bench dynamic heap (ms) stddev (%) RSS (MiB) activerecord 845.3 3.1 76.7 chunky-png 525.9 0.4 38.9 erubi-rails 2694.9 3.4 115.8 hexapdf 2344.8 5.6 164.9 liquid-c 73.7 5.0 40.5 liquid-compile 107.1 6.8 40.3 liquid-render 147.2 1.7 39.5 lobsters 697.6 4.5 342.0 mail 224.6 2.1 64.0 psych-load 4326.7 0.6 37.4 railsbench 3218.0 5.5 124.7 rubocop 203.6 6.1 110.9 ruby-lsp 350.7 3.2 79.0 sequel 121.8 2.5 39.6 shipit 1510.1 3.1 220.8 -------------- ----------------- ---------- --------- Default GC benchmark results: -------------- --------------- ---------- --------- bench default GC (ms) stddev (%) RSS (MiB) activerecord 148.4 0.6 67.9 chunky-png 440.2 0.7 57.0 erubi-rails 722.7 0.3 97.8 hexapdf 1466.2 1.7 254.3 liquid-c 32.5 3.6 42.3 liquid-compile 31.2 1.9 35.4 liquid-render 88.3 0.7 30.8 lobsters 633.6 7.0 305.4 mail 76.6 1.6 53.2 psych-load 1166.2 1.3 29.1 railsbench 1262.9 2.3 114.7 rubocop 105.6 0.8 95.4 ruby-lsp 101.6 1.4 75.4 sequel 27.4 1.2 33.1 shipit 1083.1 1.5 163.4 -------------- --------------- ---------- --------- https://github.com/ruby/mmtk/commit/c0ca29922d
2025-12-20[ruby/mmtk] Implement fast path for bump pointer allocatorPeter Zhu
Adding a fast path for bump pointer allocator can improve allocation performance. For the following microbenchmark with MMTK_HEAP_MIN=100MiB: 10_000_000.times { String.new } Before: 810.7 ms ± 8.3 ms [User: 790.9 ms, System: 40.3 ms] After: 777.9 ms ± 10.4 ms [User: 759.0 ms, System: 37.9 ms] https://github.com/ruby/mmtk/commit/0ff5c9f579
2025-12-20[ruby/mmtk] Call rb_bug when Ruby mutator thread panicsPeter Zhu
This will allow the Ruby backtrace, memory mapping, etc. to be outputted when a Ruby mutator thread panics. https://github.com/ruby/mmtk/commit/d10fd325dd
2025-07-29[ruby/mmtk] Fix warnings from cargo fmtPeter Zhu
https://github.com/ruby/mmtk/commit/84975a8840
2025-07-29[ruby/mmtk] Fix clippy warningsPeter Zhu
https://github.com/ruby/mmtk/commit/45f991578e
2025-05-30[ruby/mmtk] Fix environment variable parsingKunshan Wang
Ues more idiomatic rust approaches. https://github.com/ruby/mmtk/commit/ef125f9eae
2025-05-30[ruby/mmtk] Fix clippy warnings and formatting.Kunshan Wang
We also enable `#![warn(unsafe_op_in_unsafe_fn)]` in the whole mmtk_ruby crate. https://github.com/ruby/mmtk/commit/8b8025f71a
2025-02-24[ruby/mmtk] Trigger forced GC in GC.startKunshan Wang
We now use `MMTK::handle_user_collection_request(true, ...)` to force triggering a GC instead of enabling GC temporarily. https://github.com/ruby/mmtk/commit/02ef47f818
2025-02-10[ruby/mmtk] Set Immix as the default planPeter Zhu
https://github.com/ruby/mmtk/commit/e52b973611
2025-01-17[ruby/mmtk] Add mmtk_heap_max to GC.configPeter Zhu
https://github.com/ruby/mmtk/commit/6a78ffaf16
2025-01-16[ruby/mmtk] Add mmtk_heap_min to GC.configPeter Zhu
https://github.com/ruby/mmtk/commit/5bbac70c69
2025-01-16[ruby/mmtk] Add mmtk_heap_mode to GC.configPeter Zhu
https://github.com/ruby/mmtk/commit/810f897603
2025-01-15[ruby/mmtk] Add mmtk_plan to GC.configPeter Zhu
https://github.com/ruby/mmtk/commit/67da9ea5b8
2025-01-14[ruby/mmtk] Add mmtk_worker_count to GC.configPeter Zhu
https://github.com/ruby/mmtk/commit/836a9059cb
2025-01-14[ruby/mmtk] Exit with error message if MMTK_PLAN is invalidPeter Zhu
https://github.com/ruby/mmtk/commit/79ce2008a3
2025-01-14[ruby/mmtk] Exit with error message if MMTK_HEAP_MODE is invalidPeter Zhu
https://github.com/ruby/mmtk/commit/c8b1f4c156
2025-01-13[ruby/mmtk] Exit with error message if MMTK_HEAP_MAX is invalidPeter Zhu
https://github.com/ruby/mmtk/commit/4a24d55d91
2025-01-13[ruby/mmtk] Exit with error message if MMTK_HEAP_MIN is invalidPeter Zhu
https://github.com/ruby/mmtk/commit/1d2f7b9cfc
2025-01-13[ruby/mmtk] Exit with error message if MMTK_THREADS is invalidPeter Zhu
https://github.com/ruby/mmtk/commit/5c5c454f65
2024-12-05[ruby/mmtk] Support setting the mmtk thread count with MMTK_THREADSMatt Valentine-House
https://github.com/ruby/mmtk/commit/e4d6b56824
2024-11-22[ruby/mmtk] [Feature #20860] Implement Mark-Sweep with MMTKPeter Zhu
This commit implements the mark-sweep algorithm using MMTk and allows customizing the plan using MMTK_PLAN. https://github.com/ruby/mmtk/commit/6fea5e5ffc Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-11-22[ruby/mmtk] [Feature #20860] Implement NoGC with MMTkPeter Zhu
This commit only supports initializing MMTk with NoGC and object allocation. https://github.com/ruby/mmtk/commit/39aa10e537 Co-Authored-By: Kunshan Wang <wks1986@gmail.com>