Skip to content

Add a benchmark for conservative stack scanning in Ractors - #559

Open
eightbitraptor wants to merge 1 commit into
mainfrom
mvh-ractor-conservative-stack
Open

eightbitraptor wants to merge 1 commit into
mainfrom
mvh-ractor-conservative-stack

Conversation

@eightbitraptor

Copy link
Copy Markdown
Member

The Ractor benchmarks keep their live objects in Ruby frames, so none of them makes a worker Ractor's GC scan a deep machine stack where some objects are referenced only from C stack slots.

This commit adds ractor-conservative-stack. Each worker bounces Ruby -> C -> Ruby through a small C extension whose frames hold live VALUEs, interior pointers, C pointers and scalars. At the bottom of the stack it allocates garbage and runs a minor GC. Each frame checks the objects that only its C stack slots reference as it returns, so a missed conservative root raises RactorStackScan::CorruptionError.

The benchmark builds its extension with extconf.rb and make into build/, where the key covers the sources and the Ruby build, and we ignore that directory.

The Ractor benchmarks keep their live objects in Ruby frames, so none
of them makes a worker Ractor's GC scan a deep machine stack where
some objects are referenced only from C stack slots.

This commit adds ractor-conservative-stack. Each worker bounces
Ruby -> C -> Ruby through a small C extension whose frames hold live
VALUEs, interior pointers, C pointers and scalars. At the bottom of the
stack it allocates garbage and runs a minor GC. Each frame checks the
objects that only its C stack slots reference as it returns, so a
missed conservative root raises RactorStackScan::CorruptionError.

The benchmark builds its extension with extconf.rb and make into
build/<key>, where the key covers the sources and the Ruby build, and
we ignore that directory.
@eightbitraptor
eightbitraptor force-pushed the mvh-ractor-conservative-stack branch from fdae401 to 516c291 Compare October 19, 2026 16:06
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.

1 participant