Skip to content

Release completed statement temporaries before exit-hook workloads - #35

Merged
284km merged 1 commit into
mainfrom
fix/finished-statement-gc-roots
Nov 7, 2026
Merged

284km merged 1 commit into
mainfrom
fix/finished-statement-gc-roots

Conversation

@284km

@284km 284km commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

The driver carries the final top-level statement's temporary-allocation interval into exit hooks. A test runner invoked from at_exit can consequently keep a large set of discarded setup objects alive for its entire run. Ruby's Unicode case suite retained roughly 190,000 conversion exceptions, making each later collection expensive.

Start a fresh statement interval once the top-level body has finished. The result is already explicitly rooted in gc_hold; globals, captured values, pending exceptions, and registered handlers keep their existing roots. No GC thresholds, test inputs, or CI limits change.

Validation:

  • The new regression fails on the baseline and matches Ruby 4.0.9 on the candidate, while checking that captured values survive collection.
  • A 20,000-error exit-hook benchmark retained 20,000 errors before and 126 after (conservative roots can retain incidental handles). Twenty subsequent collections changed from 0.99–1.35 seconds to 0.033–0.042 seconds in two local runs.
  • The Unicode test_UTF-8_upcase_ascii body changed from approximately 121 to 7.5 seconds, with all 40,569 assertions passing. Initialization is separate; these are local measurements, not a whole-CI speedup.
  • All 509 corpus programs match Ruby with the hash index ON and OFF. The added regression also matches on Linux.
  • Nested exit callbacks with captured values match Ruby under GC stress.
  • The full Unicode file completes in 554 seconds within the unchanged 600-second limit: 422 tests, 1,831,104 assertions, 64 failures and 4 errors. Re-running all 68 failing cases on the unchanged baseline reproduced every failure/error report exactly. Completion is not Ruby conformance.

CI for this head passed all 29 jobs. All 758 CRuby test files were collected from 8 shards with no missing files or infrastructure errors. This confirms complete measurement, not full Ruby conformance. The local integration of #32–#36 with main f7ee263 also passed all 515 corpus programs with hash indexing ON and OFF. The full Unicode suite completed within the unchanged limit with the same 68 baseline failure/error reports. The TCP regressions and native compaction-deferral checks also passed.

@284km 284km left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed a4eb486 against 7ac8c4c. No actionable findings introduced by this change.

The reset sits after top-level execution and before shutdown callbacks. I checked fb_wm_stmt's allocation intervals and the surrounding root paths: the final value is already in gc_hold, while globals, captured environments, pending exceptions, registered callbacks, and suspended Fiber frames retain their existing roots.

Validation:

  • Fresh O2 build using the CI-pinned Mere 991f299b compiler and mgz revision.
  • The new regression fails on the 23ce853 baseline with normal GC in both index modes, then matches Ruby 4.0.9 on this head with indexing enabled/disabled, both normally and with MERE_RUBY_GC_STRESS=100.
  • Focused exit probes covering normal completion, an unrescued exception with attached values, exit(7), and top-level return matched Ruby's stdout and exit status under GC stress in both index modes. These probes also exercised nested callback captures, globals/class state, and a suspended Fiber resumed during shutdown.
  • Array, Hash, and object results printed by --eval-print survived shutdown collections and matched the baseline in both index modes under GC stress.
  • Four existing corpus programs covering exit hooks, exceptions, collection inside methods, and suspended Fiber values matched Ruby in both index modes.
  • Two default benchmark runs per revision retained 20,000 errors on 23ce853 and 84 on this head. Twenty subsequent collections took 0.809–0.854 s before and 0.0220–0.0226 s after; stdout matched Ruby. Other validation ran concurrently, so these are local workload measurements.
  • CI for this exact head reports 510/510 corpus programs matching Ruby and a successful Linux build. Broader CI jobs remain pending. I did not repeat the full corpus, Linux runs, or Unicode-suite measurements locally.
  • git diff --check passed.

Comment thread m_driver.mere Resolved

@284km 284km left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up review of a4eb486: the head is unchanged from my previous review, which had no actionable findings. That assessment still stands.

The existing exit-root regression was also rerun successfully with indexing ON/OFF on #36's updated head, which includes this exact change. The earlier focused exception, captured-value, suspended-Fiber, and result-print validation remains applicable; unchanged measurements were not repeated.

At this check, 27 of 28 CI jobs for this head have passed, with the last CRuby shard still pending and no failed jobs. This remains a separate CI completion condition.

Comment thread m_driver.mere Resolved
@284km
284km marked this pull request as ready for review November 7, 2026 08:14
@284km
284km merged commit 35efd9b into main Nov 7, 2026
29 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