Skip to content

[Bug #21838] Don't force major GC when there are allocatable slots#15882

Merged
peterzhu2118 merged 1 commit intoruby:masterfrom
peterzhu2118:gc-sweep-finish-heap-force-major-gc
Jan 16, 2026
Merged

[Bug #21838] Don't force major GC when there are allocatable slots#15882
peterzhu2118 merged 1 commit intoruby:masterfrom
peterzhu2118:gc-sweep-finish-heap-force-major-gc

Conversation

@peterzhu2118
Copy link
Copy Markdown
Member

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
--------------  -----------  ----------  ---------  -----------  ----------  ---------  --------------  -------------

[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
    --------------  -----------  ----------  ---------  -----------  ----------  ---------  --------------  -------------
Copy link
Copy Markdown
Member

@byroot byroot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just add [Bug #21838] to link on Redmine.

@peterzhu2118 peterzhu2118 merged commit 8a586af into ruby:master Jan 16, 2026
92 checks passed
@peterzhu2118 peterzhu2118 deleted the gc-sweep-finish-heap-force-major-gc branch January 16, 2026 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants