perf: skip no-op intern retain during GC#128
Merged
Merged
Conversation
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.
Summary
retain_live_interned_stringssorting/map-retain work when the post-mark scan proves every interned short string is liverecord_live_interned_stringsWhy this is safe
record_live_interned_stringspushes one ID for each interned short string that the marker visited. Iflive_ids.len() == interned_lt.len(), retaining the map would keep every entry, so sorting/deduping the ID list and walkinginterned_ltis a no-op. If any cached short string is dead, the lengths differ and the existing prune path still runs.Existing tests cover both reachable and unrooted short-string cache behavior:
interned_short_string_cache_keeps_reachable_string_until_unrootedinterned_short_string_cache_does_not_root_unreferenced_stringEvidence
/tmp/lua-rs-intern-baselinevs/tmp/lua-rs-intern-skipgc_pressure:0.05s -> 0.04sbinarytrees:0.77s -> 0.76sharness/bench/results/20260602T195056Z-b67d54d-compare.tsvgc_pressure:2.00xbinarytrees:2.02xclosure_ops:2.00xtable_hash_pressure:1.33xnoisy watch itemharness/bench/profiles/20260602T194913Z-b67d54d-gc_pressure_x300/summary.txtretain_live_interned_stringsdrops out of the top 25 leaf framesrecord_live_interned_stringsat 2.6%harness/bench/profiles/gc-profile/20260602T195127Z-b67d54d-gc_pressure_x50/gc-rates.tsvValidation
cargo test -p lua-vm interned_short_string_cache --libcargo test -p lua-gc minor_collect --libcargo build --release -p lua-cli --bin lua-rsPROFILE_REPEAT=50 bash harness/bench/gc-profile.sh gc_pressurePROFILE_REPEAT=300 bash harness/bench/profile-hotspots.sh gc_pressure 6bash harness/bench/compare.sh --runs 10 --workloads gc_pressure,binarytrees,table_hash_pressure,closure_opsgit diff --checkmake testStacked on #127.