Skip to content

Eliminate global flags#9095

Merged
headius merged 7 commits into
jruby:10.1-devfrom
headius:smaller_flags
Dec 2, 2025
Merged

Eliminate global flags#9095
headius merged 7 commits into
jruby:10.1-devfrom
headius:smaller_flags

Conversation

@headius

@headius headius commented Nov 25, 2025

Copy link
Copy Markdown
Member

This is an experiment to remove or greatly reduce in size the global RubyBasicObject.flags field.

See #9088.

@headius headius added this to the JRuby 10.1.0.0 milestone Nov 25, 2025
@headius headius force-pushed the smaller_flags branch 5 times, most recently from 463fc93 to 02d3ce3 Compare November 26, 2025 17:21
@headius

headius commented Dec 1, 2025

Copy link
Copy Markdown
Member Author

StringIO needs changes to support this, since it accesses and mutates RubyBasicObject.flags directly.

@headius

headius commented Dec 1, 2025

Copy link
Copy Markdown
Member Author

StringIO fixed in ruby/stringio#182 and pending release.

This is a first step toward eliminating the global "flags" field
in favor of type-specific flags.
The implementation of nil and false as a flag should not be visible
from outside the object.
Only NEEDSIMPL is accessed from outside of RubyModule, by Kernel,
but this flag is only used for visibility checking and may be
eliminated at some point.
Frozen as a boolean would still consume a byte, so even if we
eliminated the other two flags (nil and false) it would not save
us any space compared to just leaving all three in a byte-sized
flags field. And obviously without eliminating the other two flags,
we still need to store them. We may revisit this if we can show
that polymorphic "nil" and "false" tests show some benefit (and no
detriment) but ultimately we won't get smaller than 8 bits of space
for the unavoidable frozen flag.
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.
@headius headius changed the base branch from master to 10.1-dev December 2, 2025 16:06
@headius headius marked this pull request as ready for review December 2, 2025 16:18
@headius headius merged commit e23ced2 into jruby:10.1-dev Dec 2, 2025
152 of 153 checks passed
@headius headius deleted the smaller_flags branch December 2, 2025 16:19
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