Skip to content

Shrink varTableStamp#9091

Merged
headius merged 1 commit intojruby:10.1-devfrom
headius:var_table_stamp_shrink
Dec 2, 2025
Merged

Shrink varTableStamp#9091
headius merged 1 commit intojruby:10.1-devfrom
headius:var_table_stamp_shrink

Conversation

@headius
Copy link
Copy Markdown
Member

@headius headius commented Nov 21, 2025

This PR will experiment with and eventually proceed with changes to reduce the size of the varTableStamp we currently use to guard concurrent, atomic growth of the varTable field.

Initial experiments simply shrink the stamp to a byte, which still accommodates up to 64 concurrent mutators. It may be possible to reduce it to a single bit by forcing other mutators to block for a (very) short time while the var table is being updated, but we'll want to have some tests that show this does not lead to any deadlocks (unlikely, since this code does not trigger further locking) or false positive locks as well as benchmarks to show that we are not adversely impacting concurrent updates (both contended and non-contended).

headius added a commit to headius/jruby that referenced this pull request Dec 2, 2025
With compressed OOPS on HotSpot, we have 4 bytes of slack currently
that can be used to store the full long hash. This may change with
jruby#9095 and jruby#9091 land, which will greatly
reduce the flag overhead of all objects.
This stamp is used to guard atomic access to the varTable field
when it needs to be grown to accommodate more values. The logic
expects that anyone performing such an update will increment the
stamp while updating the the table reference, backing off if the
stamp has changed before finally assigning the new table (allowing
concurrent writers to all attempt growth without a hard lock, with
the first-past-the-post thread winning).

We probably don't need 32 bit for this, since that would
accommodate an absurd 2-4 billion concurrent mutators. Byte range
may be too small, but still handles at least 64 concurrent mutators
with non successfully growing the table large enough for any of the
others to proceed.

This relates to object header size reductions detailed in recent
issues like jruby#9090.
@headius headius changed the base branch from master to 10.1-dev December 2, 2025 15:45
@headius headius force-pushed the var_table_stamp_shrink branch from 17032a1 to 84d0d67 Compare December 2, 2025 15:45
@headius headius added this to the JRuby 10.1.0.0 milestone Dec 2, 2025
@headius headius merged commit 95c9078 into jruby:10.1-dev Dec 2, 2025
153 of 154 checks passed
@headius headius deleted the var_table_stamp_shrink branch December 2, 2025 16:16
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