aboutsummaryrefslogtreecommitdiff
path: root/src/link.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2025-06-12 09:56:37 +0100
committermlugg <mlugg@mlugg.co.uk>2025-06-12 17:51:31 +0100
commit5bb5aaf932b8ed30aebfbb0036e1532abfc6af46 (patch)
tree059ef1f8ab00e70585895068e5561681d49514f5 /src/link.zig
parentf9a670d46de3c62be16202f186eacfee6ec096d4 (diff)
downloadzig-5bb5aaf932b8ed30aebfbb0036e1532abfc6af46.tar.gz
zig-5bb5aaf932b8ed30aebfbb0036e1532abfc6af46.zip
compiler: don't queue too much AIR/MIR
Without this cap, unlucky scheduling and/or details of what pipeline stages perform best on the host machine could cause many gigabytes of MIR to be stuck in the queue. At a certain point, pause the main thread until some of the functions in flight have been processed.
Diffstat (limited to 'src/link.zig')
-rw-r--r--src/link.zig5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/link.zig b/src/link.zig
index ce98ac8929..9bed6b4131 100644
--- a/src/link.zig
+++ b/src/link.zig
@@ -1267,6 +1267,11 @@ pub const ZcuTask = union(enum) {
/// the codegen job to ensure that the linker receives functions in a deterministic order,
/// allowing reproducible builds.
mir: *SharedMir,
+ /// This is not actually used by `doZcuTask`. Instead, `Queue` uses this value as a heuristic
+ /// to avoid queueing too much AIR/MIR for codegen/link at a time. Essentially, we cap the
+ /// total number of AIR bytes which are being processed at once, preventing unbounded memory
+ /// usage when AIR is produced faster than it is processed.
+ air_bytes: u32,
pub const SharedMir = struct {
/// This is initially `.pending`. When `value` is populated, the codegen thread will set