Skip to content

test: stabilize GVL-release check on fast Apple Silicon runners - #6

Merged
benngarcia merged 1 commit into
masterfrom
fix/gvl-test-window
Nov 21, 2026
Merged

benngarcia merged 1 commit into
masterfrom
fix/gvl-test-window

Conversation

@benngarcia

Copy link
Copy Markdown
Owner

Summary

Fixes the macos-15 Ruby 3.2 CI flake in SafetyTest#test_gvl_released_and_concurrent_thread_safety (run 44871608538).

On Apple Silicon XNNPACK, 40 inferences of heavy_mlp finished in ~20ms. Because the ticker thread calls Thread.pass on every increment, 20ms only allowed ~6 OS thread switches even though the GVL was released.

Changes

  • Gate tick counting strictly to the inference loop (counting = true/false) so pre-start ticks cannot mask a held GVL.
  • Run the inference loop for at least 0.25s (still capped at 2.0s max and >= 5 runs) and assert ticks > 20.

Verification

  • Planted bug check (temporarily calling core->execute directly without rb_thread_call_without_gvl): fails reliably with ticks=2, runs=331, elapsed=0.251s (expected > 20), matching Ruby's 100ms GVL quantum.
  • Real code (bundle exec rake test): 32 runs, 247422 assertions, 0 failures, 0 errors, 0 skips.

@benngarcia
benngarcia merged commit 0d66c9c into master Nov 21, 2026
9 checks passed
@benngarcia
benngarcia deleted the fix/gvl-test-window branch November 21, 2026 06:52
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