Make RBS::Location write-barrier protected (backport to 4.0.x)#3024
Open
soutaro wants to merge 1 commit into
Open
Make RBS::Location write-barrier protected (backport to 4.0.x)#3024soutaro wants to merge 1 commit into
soutaro wants to merge 1 commit into
Conversation
Mark the Location TypedData object with RUBY_TYPED_WB_PROTECTED and route every write to the embedded `buffer` VALUE through RB_OBJ_WRITE. Once an object is write-barrier protected, the GC can skip it during minor collections instead of marking it every time, which speeds up GC. All buffer assignments (initialize, initialize_copy, and the three rbs_new_location* constructors) now go through the write barrier so the old-to-young reference from a promoted Location to its Buffer is tracked correctly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #3022 to the
aaa-4.0.xbranch.Summary
Marks the
RBS::LocationTypedData object withRUBY_TYPED_WB_PROTECTEDand routes every write to the embeddedbufferVALUE throughRB_OBJ_WRITE. Once an object is write-barrier protected, the GC can skip it during minor collections instead of marking it on every cycle, which speeds up GC.Details
All
bufferassignments now go through the write barrier so the old-to-young reference from a promotedLocationto itsBufferis tracked correctly:location_initializelocation_initialize_copyrbs_new_locationrbs_new_location2rbs_new_location_from_loc_rangeVerification
aaa-4.0.x.ObjectSpace.dumpreports"wb_protected": truefor aLocation, confirming it becomes skippable in minor GC.GC.verify_internal_consistencypasses at every stage of a stress test that promotesLocations to the old generation and churns the young generation across minor GCs; referencedBuffers stay intact.dup(initialize_copy) path holds up underGC.stress = true.test/rbs/location_test.rbpasses (11 tests, 115 assertions).🤖 Generated with Claude Code
https://claude.ai/code/session_011JK4Acfc1aTzpgpPZxwJLF
Generated by Claude Code