gengliangwang opened a new pull request, #56086:
URL: https://github.com/apache/spark/pull/56086

   ### What changes were proposed in this pull request?
   
   In `SorterSuite`, the test `"java.lang.ArrayIndexOutOfBoundsException in 
TimSort"` allocates a ~1 GB byte array. Previously this test called 
`System.gc()` unconditionally before the allocation, but `System.gc()` is only 
a hint and may not actually run before the next allocation. This change:
   
   - Adds a `runGC()` helper that uses a `WeakReference` busy-wait to ensure GC 
actually runs (same pattern as `ContextCleanerSuite.runGC()`).
   - Removes the unconditional `System.gc()` call. Instead, the byte-array 
allocation is attempted directly, and if it throws `OutOfMemoryError`, 
`runGC()` is invoked and the allocation is retried once.
   
   ### Why are the changes needed?
   
   The test is flaky in CI with `java.lang.OutOfMemoryError: Java heap space`. 
The preceding test `"SPARK-5984 TimSort bug"` allocates a ~256 MB int array, 
which may not be reclaimed before this test's >1 GB allocation if GC has not 
actually run.
   
   Example failed job: 
https://github.com/gengliangwang/spark/actions/runs/26343824415/job/77552562041
   
   A previous fix (`0390e4b44aa`) added `System.gc()` before the allocation, 
but that is only a hint and does not guarantee GC has run. Doing the GC only on 
the failure path also avoids paying the cost on the happy path.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. Test-only change.
   
   ### How was this patch tested?
   
   Monitor CI stability.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to