| 1 | // Regression test for issue #27555: on the optimized `-gc` modes (the default |
| 2 | // `boehm_full_opt`), `main()` calls `GC_set_free_space_divisor(1)` before |
| 3 | // `GC_INIT()`, so the heap is allowed to grow to roughly the live set before |
| 4 | // collecting. That keeps stop-the-world collections rare, which with thread-local |
| 5 | // allocation is what otherwise serializes worker threads on allocation-heavy |
| 6 | // multithreaded HTTP servers. An explicit `GC_FREE_SPACE_DIVISOR` env var is |
| 7 | // applied by `GC_INIT()` afterwards and wins, so the test skips when one is set. |
| 8 | import os |
| 9 | |
| 10 | fn C.GC_get_free_space_divisor() usize |
| 11 | |
| 12 | fn test_free_space_divisor_is_tuned_for_throughput() { |
| 13 | $if gcboehm_opt ? { |
| 14 | if os.getenv('GC_FREE_SPACE_DIVISOR') != '' { |
| 15 | eprintln('skipping: explicit GC_FREE_SPACE_DIVISOR override is set') |
| 16 | assert true |
| 17 | return |
| 18 | } |
| 19 | assert C.GC_get_free_space_divisor() == 1 |
| 20 | } $else { |
| 21 | eprintln('skipping: not an optimized boehm GC build') |
| 22 | assert true |
| 23 | } |
| 24 | } |
| 25 | |