ghostty: limit the amount of build cores#446056
Conversation
|
Cc the folks who reported build failures in the original PR: @eyJhb @ulrikstrid @Mic92 @Enzime Could y'all give this a go and see if it works? |
|
Also I'm not sure who to contact here, but the only one I know who's actively working on Zig stuff is @RossComputerGuy — it seems that the Zig build hook currently doesn't specify the |
|
|
Still no? Hmm... What happens if you turn off parallel building altogether? |
What would I need to do, to try that? Also, my comment was wrong in the other PR regarding how many cores I have. I'm building on a remote builder which has 64 cores :) |
|
I think it's |
5dfa5c8 to
429c48e
Compare
This is again because Zig's hook does not correctly (or even really try to...) handle regular controls of build parallelism like other hooks 🫠 |
|
I don't have my computer available right now but will try when I can. i have however tried just adding |
|
I'm honestly surprised that it even worked for other Zig-based software like TigerBeetle and Bun then... Maybe we were all just collectively really lucky that we never ran into any parallelism-based bugs yet |
|
I think non‐ Edit: Ah, #446056 (comment) would explain it. |
|
✨ It never worked in the first place ✨ |
I'm actually working on a PR to add that in
I've tried building Bun and oddly enough, I don't think I've seen this problem on my Ampere hardware which is Arm. Last time I touched Bun, I had 64 cores. I have 128 cores and I remember updating zig and running a nixpkgs-review on it to build everything and Ghostty passing. It's possible this is only a problem on x86. I'm running some builds right now to verify this. |
|
It's entirely plausible that Bun isn't (ab)using |
|
Hmm, and it's always possible because I've got Arm cores that the difference in performance compared to x86 could have an impact. I've seen this, my individual cores are slower than most x86 hardware but together they're strong. |
|
I said in #445326 but i'll say here as well: this pr allows for successful build on my machine |
|
I just opened #446063 to add support for using |
|
Ghostty 1.2 is on Zig 0.14, though. 1.1.3 wouldn't work for sure |
|
|
Disregard my success report—it was run on my laptop which has 16 cores so the bug doesn't apply |
|
Oh that is disgusting. But it should work. At this point since I'm not nearly qualified enough to try to fix the bug at its source, I'm tempted to go with this anyways so we can at least get Ghostty in Hydra first. |
b6766fe to
b58cdc0
Compare
|
@Mic92 I modified your approach and used a shell script wrapper instead of manually replicating what the hook currently does. Could you give it a whirl? |
b58cdc0 to
43c085b
Compare
For some bizarre reason Zig contains a bug where the compiler would crash when a large enough file is embedded AND when too many cores are used during compilation. This has been causing Hydra builds to repeatedly fail, while Ofborg and manual testing by maintainers were never able to reproduce the failure. However, given this is preventing Ghostty 1.2 from landing in the binary cache, we need to work around it somehow. 24 cores should be *more* than enough for now, but if it still doesn't work we can lower the threshold even further. Links to upstream discussions: * ziglang/zig#25297 * ziglang/zig#22867 * ghostty-org/ghostty#8676 Fixes NixOS#445326
43c085b to
fb8d932
Compare
|
|
|
Let's freaking go |
|
|
Builds on my Threadripper now, 64 physical cores |
|
Shouldn't we limit this in zig itself as this could effect any package big enough? |
|
Not really. The only way this triggers is if you embed a lot of strings directly into the binary, which apparently is not the case for TigerBeetle, Bun, River, etc. It also heavily depends on just how many strings are embedded - in Ghostty 1.2 we added new Unicode tables that I suspected brought our total usage over the "limit". In reality there isn't a single limit, but rather the limit decreases as core count goes up, so the limit we want to set is completely dependent on the needs of any given project. Given all of this and the fact that upstream Zig has marked the root issue as something they'd like to iron out for 0.15.2, I don't think it makes sense to add this wrapper to the compiler itself. If that fix does land in 0.15.2 I might even consider backporting the 1.2.x releases to use Zig 0.15 instead of 0.14 — my original plan is to switch to Zig 0.15 for 1.3.x, but plans might have to change now. |
However what we should introduce in our zig builder is -j$NIX_BUILD_CORES... but this is orthogonal to this PR. |
|
I'd be happy to see this merged given that multiple people have confirmed that this works for them :) (I don't have the perms myself. Yet.) |
That would be #446063 I believe |
For some bizarre reason Zig contains a bug where the compiler would crash when a large enough file is embedded AND when the builder has too many cores. (It doesn't matter how many cores Zig has been specified to use via the
-jflag — the only way to fix this bug is to use CPU scheduling tools to prevent Zig from using more than 32 cores.) This has been causing Hydra builds to repeatedly fail, while Ofborg and manual testing by maintainers were never able to reproduce the failure. However, given this is preventing Ghostty 1.2 from landing in the binary cache, we need to work around it somehow.Links to upstream discussions:
Fixes #445326
Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.Add a 👍 reaction to pull requests you find important.