diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-06-13 18:59:52 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-06-14 17:15:13 -0400 |
| commit | 22690efcc2378222503cb8aaad26a6f4a539f5aa (patch) | |
| tree | 2dc41347d1db482beccbae41f8ecd078dc3ee9fe /src/Compilation.zig | |
| parent | 47c4d4450281bfddebf89cbad4f9c1fdcc7b0b65 (diff) | |
| download | zig-22690efcc2378222503cb8aaad26a6f4a539f5aa.tar.gz zig-22690efcc2378222503cb8aaad26a6f4a539f5aa.zip | |
multi-thread `zig build test-cases`
Instead of always using std.testing.allocator, the test harness now follows
the same logic as self-hosted for choosing an allocator - that is - it
uses C allocator when linking libc, std.testing.allocator otherwise, and
respects `-Dforce-gpa` to override the decision. I did this because
I found GeneralPurposeAllocator to be prohibitively slow when doing
multi-threading, even in the context of a debug build.
There is now a second thread pool which is used to spawn each
test case. The stage2 tests are passed the first thread pool. If it were
only multi-threading the stage1 tests then we could use the same thread
pool for everything. However, the problem with this strategy with stage2
is that stage2 wants to spawn tasks and then call wait() on the main
thread. If we use the same thread pool for everything, we get a deadlock
because all the threads end up all hanging at wait() and nothing is
getting done. So we use our second thread pool to simulate a "process pool"
of sorts.
I spent most of the time working on this commit scratching my head trying
to figure out why I was getting ETXTBSY when spawning the test cases.
Turns out it's a fundamental Unix design flaw, already a known, unsolved
issue by Go and Java maintainers:
https://github.com/golang/go/issues/22315
https://bugs.openjdk.org/browse/JDK-8068370
With this change, the following command, executed on my laptop, went from
6m24s to 1m44s:
```
stage1/bin/zig build test-cases -fqemu -fwasmtime -Denable-llvm
```
closes #11818
Diffstat (limited to 'src/Compilation.zig')
0 files changed, 0 insertions, 0 deletions
