authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-06-08 16:25:28+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-06-12 13:55:41+01:00
logac745edbbd6687c5898bb3a50bf9d31d86e57b9e
treecca2d95cd7cbb1576e604ef9f4ad46a1b029c990
parentdb5d85b8c89b755bd8865def3bd7114d5d9d4867
signaturelock-open Commit is signed but in an unrecognized format.

compiler: estimate totals for "Code Generation" and "Linking" progress nodes


2 files changed, 21 insertions(+), 14 deletions(-)

src/Compilation.zig+6
......@@ -4202,6 +4202,10 @@ fn performAllTheWork(
42024202 comp.link_task_wait_group.reset();
42034203 defer comp.link_task_wait_group.wait();
42044204
4205 comp.link_prog_node.increaseEstimatedTotalItems(
4206 comp.link_task_queue.queued_prelink.items.len + // already queued prelink tasks
4207 comp.link_task_queue.pending_prelink_tasks, // prelink tasks which will be queued
4208 );
42054209 comp.link_task_queue.start(comp);
42064210
42074211 if (comp.emit_docs != null) {
......@@ -4597,6 +4601,7 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job) JobError!void {
45974601 .value = undefined,
45984602 };
45994603 assert(zcu.pending_codegen_jobs.rmw(.Add, 1, .monotonic) > 0); // the "Code Generation" node hasn't been ended
4604 zcu.codegen_prog_node.increaseEstimatedTotalItems(1);
46004605 if (comp.separateCodegenThreadOk()) {
46014606 // `workerZcuCodegen` takes ownership of `air`.
46024607 comp.thread_pool.spawnWgId(&comp.link_task_wait_group, workerZcuCodegen, .{ comp, func.func, air, shared_mir });
......@@ -7444,6 +7449,7 @@ pub fn queuePrelinkTasks(comp: *Compilation, tasks: []const link.PrelinkTask) vo
74447449/// The reason for the double-queue here is that the first queue ensures any
74457450/// resolve_type_fully tasks are complete before this dispatch function is called.
74467451fn dispatchZcuLinkTask(comp: *Compilation, tid: usize, task: link.ZcuTask) void {
7452 comp.link_prog_node.increaseEstimatedTotalItems(1);
74477453 if (!comp.separateCodegenThreadOk()) {
74487454 assert(tid == 0);
74497455 if (task == .link_func) {
src/link.zig+15-14
......@@ -1290,7 +1290,10 @@ pub const ZcuTask = union(enum) {
12901290
12911291pub fn doPrelinkTask(comp: *Compilation, task: PrelinkTask) void {
12921292 const diags = &comp.link_diags;
1293 const base = comp.bin_file orelse return;
1293 const base = comp.bin_file orelse {
1294 comp.link_prog_node.completeOne();
1295 return;
1296 };
12941297 switch (task) {
12951298 .load_explicitly_provided => {
12961299 const prog_node = comp.link_prog_node.start("Parse Inputs", comp.link_inputs.len);
......@@ -1413,12 +1416,13 @@ pub fn doPrelinkTask(comp: *Compilation, task: PrelinkTask) void {
14131416}
14141417pub fn doZcuTask(comp: *Compilation, tid: usize, task: ZcuTask) void {
14151418 const diags = &comp.link_diags;
1419 const zcu = comp.zcu.?;
1420 const ip = &zcu.intern_pool;
1421 const pt: Zcu.PerThread = .activate(zcu, @enumFromInt(tid));
1422 defer pt.deactivate();
14161423 switch (task) {
14171424 .link_nav => |nav_index| {
1418 const zcu = comp.zcu.?;
1419 const pt: Zcu.PerThread = .activate(zcu, @enumFromInt(tid));
1420 defer pt.deactivate();
1421 const fqn_slice = zcu.intern_pool.getNav(nav_index).fqn.toSlice(&zcu.intern_pool);
1425 const fqn_slice = ip.getNav(nav_index).fqn.toSlice(ip);
14221426 const nav_prog_node = comp.link_prog_node.start(fqn_slice, 0);
14231427 defer nav_prog_node.end();
14241428 if (zcu.llvm_object) |llvm_object| {
......@@ -1440,11 +1444,8 @@ pub fn doZcuTask(comp: *Compilation, tid: usize, task: ZcuTask) void {
14401444 }
14411445 },
14421446 .link_func => |func| {
1443 const zcu = comp.zcu.?;
14441447 const nav = zcu.funcInfo(func.func).owner_nav;
1445 const pt: Zcu.PerThread = .activate(zcu, @enumFromInt(tid));
1446 defer pt.deactivate();
1447 const fqn_slice = zcu.intern_pool.getNav(nav).fqn.toSlice(&zcu.intern_pool);
1448 const fqn_slice = ip.getNav(nav).fqn.toSlice(ip);
14481449 const nav_prog_node = comp.link_prog_node.start(fqn_slice, 0);
14491450 defer nav_prog_node.end();
14501451 switch (func.mir.status.load(.monotonic)) {
......@@ -1468,9 +1469,9 @@ pub fn doZcuTask(comp: *Compilation, tid: usize, task: ZcuTask) void {
14681469 }
14691470 },
14701471 .link_type => |ty| {
1471 const zcu = comp.zcu.?;
1472 const pt: Zcu.PerThread = .activate(zcu, @enumFromInt(tid));
1473 defer pt.deactivate();
1472 const name = Type.fromInterned(ty).containerTypeName(ip).toSlice(ip);
1473 const nav_prog_node = comp.link_prog_node.start(name, 0);
1474 defer nav_prog_node.end();
14741475 if (zcu.llvm_object == null) {
14751476 if (comp.bin_file) |lf| {
14761477 lf.updateContainerType(pt, ty) catch |err| switch (err) {
......@@ -1481,8 +1482,8 @@ pub fn doZcuTask(comp: *Compilation, tid: usize, task: ZcuTask) void {
14811482 }
14821483 },
14831484 .update_line_number => |ti| {
1484 const pt: Zcu.PerThread = .activate(comp.zcu.?, @enumFromInt(tid));
1485 defer pt.deactivate();
1485 const nav_prog_node = comp.link_prog_node.start("Update line number", 0);
1486 defer nav_prog_node.end();
14861487 if (pt.zcu.llvm_object == null) {
14871488 if (comp.bin_file) |lf| {
14881489 lf.updateLineNumber(pt, ti) catch |err| switch (err) {