From 1630d1f6c7a7a074b30497bc5b5e311806eb5e59 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 3 Aug 2026 02:24:37 +0000 Subject: [PATCH] Keep GC disabled during GC_test#test_stress_and_stress= `GC.stress = true` runs a full GC on every allocation, and each `assert_send_type` allocates heavily while parsing the method type and type checking the call trace. Since #3059 stopped `test_enable` from leaking a disabled GC into the rest of the suite, stress mode is finally live during this test, and the five assertions between `GC.stress = 0` and `GC.stress = false` turn the whole stdlib suite from 193s into 827s -- 647s of it inside this one method. The cost scales with heap size, so it is far worse in the full suite than when the file runs alone. The assertions only check the types of the return values, so no GC needs to actually run. Disable GC for the duration and restore both the stress mode and the previous enabled state afterwards. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01NtDw9t8cMiaqT2s8wwSsDt --- test/stdlib/GC_test.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/stdlib/GC_test.rb b/test/stdlib/GC_test.rb index 27f5db629..dd9fdea6e 100644 --- a/test/stdlib/GC_test.rb +++ b/test/stdlib/GC_test.rb @@ -76,6 +76,10 @@ def test_stat def test_stress_and_stress= old_stress = GC.stress + # Stress mode runs a full GC on every allocation, and the assertions below allocate + # heavily while parsing and type checking. Only the types of the return values matter + # here, so keep GC disabled and let stress mode stay inert. + was_disabled = GC.disable assert_send_type '() -> (Integer | bool)', GC, :stress @@ -92,6 +96,7 @@ def test_stress_and_stress= end ensure GC.stress = old_stress + GC.enable unless was_disabled end def test_total_time