<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/gc, branch v4.0.4</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>merge revision(s) 8a586af33b59cae93a1bee13c39e87dd087a4a6b: [Backport #21838]</title>
<updated>2026-02-09T23:39:41+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2026-02-09T23:39:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=d5d3fb8b80e81426517bf150ebcab83be4ed996d'/>
<id>d5d3fb8b80e81426517bf150ebcab83be4ed996d</id>
<content type='text'>
	[PATCH] Don't force major GC when there are allocatable slots

	[Bug #21838]

	When we have allocatable slots, we can grow the heap instead of forcing
	a major GC. This prevents major GC to be ran very often in certain situations.
	See the ticket for more details.

	On ruby-bench, we can see that this patch doesn't cause any significant
	regressions:

	    --------------  -----------  ----------  ---------  -----------  ----------  ---------  --------------  -------------
	    bench           master (ms)  stddev (%)  RSS (MiB)  branch (ms)  stddev (%)  RSS (MiB)  branch 1st itr  master/branch
	    activerecord    148.2        0.3         59.2       150.0        0.8         69.7       1.015           0.988
	    chunky-png      435.2        0.3         72.9       438.8        0.1         66.7       0.993           0.992
	    erubi-rails     733.8        1.2         118.7      704.8        0.2         98.3       1.077           1.041
	    hexapdf         1400.4       1.1         247.0      1405.0       0.9         223.7      0.986           0.997
	    liquid-c        32.5         3.3         32.8       32.5         2.1         30.7       1.042           0.999
	    liquid-compile  31.0         1.7         35.1       33.4         3.9         32.8       0.938           0.928
	    liquid-render   84.7         0.4         30.8       86.3         0.4         30.8       0.981           0.982
	    lobsters        594.7        0.6         310.5      596.6        0.4         306.0      1.057           0.997
	    mail            75.6         2.8         53.3       76.9         0.7         53.2       0.968           0.982
	    psych-load      1122.8       1.2         29.2       1145.1       0.4         31.7       0.964           0.981
	    railsbench      1244.7       0.3         115.5      1254.8       1.1         115.2      0.939           0.992
	    rubocop         103.7        0.5         94.1       104.3        0.5         92.4       0.985           0.994
	    ruby-lsp        88.3         0.6         78.5       88.5         1.2         77.9       0.992           0.997
	    sequel          26.9         0.9         33.6       28.3         1.4         32.1       0.954           0.952
	    shipit          1119.3       1.5         171.4      1075.7       2.1         162.5      1.873           1.040
	    --------------  -----------  ----------  ---------  -----------  ----------  ---------  --------------  -------------
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[PATCH] Don't force major GC when there are allocatable slots

	[Bug #21838]

	When we have allocatable slots, we can grow the heap instead of forcing
	a major GC. This prevents major GC to be ran very often in certain situations.
	See the ticket for more details.

	On ruby-bench, we can see that this patch doesn't cause any significant
	regressions:

	    --------------  -----------  ----------  ---------  -----------  ----------  ---------  --------------  -------------
	    bench           master (ms)  stddev (%)  RSS (MiB)  branch (ms)  stddev (%)  RSS (MiB)  branch 1st itr  master/branch
	    activerecord    148.2        0.3         59.2       150.0        0.8         69.7       1.015           0.988
	    chunky-png      435.2        0.3         72.9       438.8        0.1         66.7       0.993           0.992
	    erubi-rails     733.8        1.2         118.7      704.8        0.2         98.3       1.077           1.041
	    hexapdf         1400.4       1.1         247.0      1405.0       0.9         223.7      0.986           0.997
	    liquid-c        32.5         3.3         32.8       32.5         2.1         30.7       1.042           0.999
	    liquid-compile  31.0         1.7         35.1       33.4         3.9         32.8       0.938           0.928
	    liquid-render   84.7         0.4         30.8       86.3         0.4         30.8       0.981           0.982
	    lobsters        594.7        0.6         310.5      596.6        0.4         306.0      1.057           0.997
	    mail            75.6         2.8         53.3       76.9         0.7         53.2       0.968           0.982
	    psych-load      1122.8       1.2         29.2       1145.1       0.4         31.7       0.964           0.981
	    railsbench      1244.7       0.3         115.5      1254.8       1.1         115.2      0.939           0.992
	    rubocop         103.7        0.5         94.1       104.3        0.5         92.4       0.985           0.994
	    ruby-lsp        88.3         0.6         78.5       88.5         1.2         77.9       0.992           0.997
	    sequel          26.9         0.9         33.6       28.3         1.4         32.1       0.954           0.952
	    shipit          1119.3       1.5         171.4      1075.7       2.1         162.5      1.873           1.040
	    --------------  -----------  ----------  ---------  -----------  ----------  ---------  --------------  -------------
</pre>
</div>
</content>
</entry>
<entry>
<title>Move special const check to gc.c for rb_gc_impl_object_moved_p</title>
<updated>2025-12-23T18:54:08+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2025-12-23T17:59:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e2cf92eddc5403316b0d449b02ba403a27610d7b'/>
<id>e2cf92eddc5403316b0d449b02ba403a27610d7b</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/mmtk] Implement Ruby heap</title>
<updated>2025-12-22T21:54:27+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2025-12-22T16:24:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=af30e4714ccb0dabff85298ee2305d84103b98d1'/>
<id>af30e4714ccb0dabff85298ee2305d84103b98d1</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/mmtk] Add a 32 byte heap for allocating smaller objects</title>
<updated>2025-12-21T13:59:28+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2025-12-20T16:42:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=37b98f0df71e85a831677562dc08f6ce6cdae842'/>
<id>37b98f0df71e85a831677562dc08f6ce6cdae842</id>
<content type='text'>
https://github.com/ruby/mmtk/commit/c4cca6c1c3
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/mmtk/commit/c4cca6c1c3
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/mmtk] Implement fast path for bump pointer allocator</title>
<updated>2025-12-21T02:55:12+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2025-12-20T21:08:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=038b158fa30d1b1cda153aeb10dac5f59f966036'/>
<id>038b158fa30d1b1cda153aeb10dac5f59f966036</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/mmtk] Make rb_gc_impl_heap_id_for_size use MMTK_HEAP_COUNT</title>
<updated>2025-12-20T16:41:11+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2025-12-20T16:39:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=6d5605b28a800be19357ec57ff6c8e1118aabca0'/>
<id>6d5605b28a800be19357ec57ff6c8e1118aabca0</id>
<content type='text'>
https://github.com/ruby/mmtk/commit/2185189df4
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/mmtk/commit/2185189df4
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/mmtk] Call rb_bug when Ruby mutator thread panics</title>
<updated>2025-12-20T13:40:00+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2025-12-19T22:16:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=6bf921051ceba1742318e3c92dddd50ba4f05d17'/>
<id>6bf921051ceba1742318e3c92dddd50ba4f05d17</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/mmtk] Extract max object size to MMTK_MAX_OBJ_SIZE</title>
<updated>2025-12-19T22:14:02+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2025-12-19T01:01:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=8274c5e1428b5b88e885857d466822cbadc19761'/>
<id>8274c5e1428b5b88e885857d466822cbadc19761</id>
<content type='text'>
https://github.com/ruby/mmtk/commit/ed9036c295
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/mmtk/commit/ed9036c295
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/mmtk] Extract heap count to MMTK_HEAP_COUNT macro</title>
<updated>2025-12-19T22:13:49+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2025-12-19T01:00:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=ed0fae5b501dea14617103ab5ec2d042f445ed7f'/>
<id>ed0fae5b501dea14617103ab5ec2d042f445ed7f</id>
<content type='text'>
https://github.com/ruby/mmtk/commit/4e789e118b
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/mmtk/commit/4e789e118b
</pre>
</div>
</content>
</entry>
<entry>
<title>Use RBIMPL_ASSERT_OR_ASSUME instead of ASSUME for better errors when it does not hold</title>
<updated>2025-12-16T20:00:27+00:00</updated>
<author>
<name>Benoit Daloze</name>
<email>eregontp@gmail.com</email>
</author>
<published>2025-12-16T10:58:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4d4f414a6062173743af7fe2b88835f16287a6cc'/>
<id>4d4f414a6062173743af7fe2b88835f16287a6cc</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
