Skip to content

perf: skip no-op intern retain during GC#128

Merged
ianm199 merged 1 commit into
mainfrom
perf/intern-retain-fastpath
Jun 2, 2026
Merged

perf: skip no-op intern retain during GC#128
ianm199 merged 1 commit into
mainfrom
perf/intern-retain-fastpath

Conversation

@ianm199
Copy link
Copy Markdown
Owner

@ianm199 ianm199 commented Jun 2, 2026

Summary

  • skip retain_live_interned_strings sorting/map-retain work when the post-mark scan proves every interned short string is live
  • document the evidence in the performance notes and mark the remaining intern-cache cost as record_live_interned_strings

Why this is safe

record_live_interned_strings pushes one ID for each interned short string that the marker visited. If live_ids.len() == interned_lt.len(), retaining the map would keep every entry, so sorting/deduping the ID list and walking interned_lt is 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_unrooted
  • interned_short_string_cache_does_not_root_unreferenced_string

Evidence

  • Direct Rust A/B, best-of-20 on the same built artifacts:
    • /tmp/lua-rs-intern-baseline vs /tmp/lua-rs-intern-skip
    • gc_pressure: 0.05s -> 0.04s
    • binarytrees: 0.77s -> 0.76s
  • Focused best-of-10 compare:
    • harness/bench/results/20260602T195056Z-b67d54d-compare.tsv
    • gc_pressure: 2.00x
    • binarytrees: 2.02x
    • closure_ops: 2.00x
    • table_hash_pressure: 1.33x noisy watch item
  • Post-packet hotspot:
    • harness/bench/profiles/20260602T194913Z-b67d54d-gc_pressure_x300/summary.txt
    • retain_live_interned_strings drops out of the top 25 leaf frames
    • remaining intern-cache bucket: record_live_interned_strings at 2.6%
  • Post-packet GC cadence:
    • harness/bench/profiles/gc-profile/20260602T195127Z-b67d54d-gc_pressure_x50/gc-rates.tsv
    • unchanged cadence: 6,336.9 collections/run
    • elapsed: 2.34061s over 50 repeated runs

Validation

  • cargo test -p lua-vm interned_short_string_cache --lib
  • cargo test -p lua-gc minor_collect --lib
  • cargo build --release -p lua-cli --bin lua-rs
  • PROFILE_REPEAT=50 bash harness/bench/gc-profile.sh gc_pressure
  • PROFILE_REPEAT=300 bash harness/bench/profile-hotspots.sh gc_pressure 6
  • bash harness/bench/compare.sh --runs 10 --workloads gc_pressure,binarytrees,table_hash_pressure,closure_ops
  • git diff --check
  • make test

Stacked on #127.

@ianm199 ianm199 changed the base branch from perf/vm-value-telemetry to main June 2, 2026 20:54
@ianm199 ianm199 merged commit 437a3a6 into main Jun 2, 2026
3 checks passed
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