Skip to content

Commit cf844c9

Browse files
committed
build: state the duration of each step of the plan's finish phase
The finish phase took 301 ms of a planned edit of one xlings source; its steps now state their durations under build/stage like the phases: make plan 112 ms and the dependency cache 176 ms.
1 parent 94603a9 commit cf844c9

1 file changed

Lines changed: 47 additions & 18 deletions

File tree

‎src/build/prepare/plan.cpp‎

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,24 +2273,53 @@ std::expected<BuildContext, std::string> phase13_finish(PrepareState& state) {
22732273
ctx.projectRoot= *state.root;
22742274
ctx.outputDir = target_dir(*state.tc, state.fp, state.workRoot);
22752275

2276-
if (auto r = step13_source_packages(state, ctx); !r) return std::unexpected(r.error());
2277-
if (auto r = step13_runner_and_xlings(state, ctx); !r) return std::unexpected(r.error());
2278-
if (auto r = step13_prebuilt_check(state, ctx); !r) return std::unexpected(r.error());
2279-
if (auto r = step13_link_forms(state, ctx); !r) return std::unexpected(r.error());
2280-
if (auto r = step13_make_plan(state, ctx); !r) return std::unexpected(r.error());
2281-
if (auto r = step13_cxx_private_runtime(state, ctx); !r) return std::unexpected(r.error());
2282-
if (auto r = step13_cxx_process_runtime(state, ctx); !r) return std::unexpected(r.error());
2283-
step13_graph_and_schedule(state, ctx);
2284-
if (auto r = step13_build_graph_actions(state, ctx); !r) return std::unexpected(r.error());
2285-
if (auto r = step13_assembly_units(state, ctx); !r) return std::unexpected(r.error());
2286-
if (auto r = step13_windows_resources(state, ctx); !r) return std::unexpected(r.error());
2287-
if (auto r = step13_dependency_cache(state, ctx); !r) return std::unexpected(r.error());
2288-
if (auto r = step13_lockfile(state, ctx); !r) return std::unexpected(r.error());
2289-
if (auto r = step13_runtime_provider_overrides(state, ctx); !r) return std::unexpected(r.error());
2290-
if (auto r = step13_abi_enforcement(state, ctx); !r) return std::unexpected(r.error());
2291-
step13_resolution_json(state, ctx);
2292-
if (auto r = step13_empty_link_check(state, ctx); !r) return std::unexpected(r.error());
2293-
step13_report_packages(state, ctx);
2276+
// Each step states its duration under `build/stage`, as the phases do
2277+
// (build wall-time plan, W9), when the log file or --verbose would show it.
2278+
const bool timing = mcpp::log::is_verbose() || mcpp::log::is_enabled(mcpp::log::Level::info);
2279+
auto timed = [&](std::string_view step, auto&& run) {
2280+
if (!timing) return run();
2281+
const auto t0 = std::chrono::steady_clock::now();
2282+
auto r = run();
2283+
mcpp::log::verbose("build/stage", std::format("plan finish {}: {}ms", step,
2284+
std::chrono::duration_cast<std::chrono::milliseconds>(
2285+
std::chrono::steady_clock::now() - t0).count()));
2286+
return r;
2287+
};
2288+
2289+
if (auto r = timed("source packages", [&] { return step13_source_packages(state, ctx); }); !r)
2290+
return std::unexpected(r.error());
2291+
if (auto r = timed("runner and xlings", [&] { return step13_runner_and_xlings(state, ctx); }); !r)
2292+
return std::unexpected(r.error());
2293+
if (auto r = timed("prebuilt check", [&] { return step13_prebuilt_check(state, ctx); }); !r)
2294+
return std::unexpected(r.error());
2295+
if (auto r = timed("link forms", [&] { return step13_link_forms(state, ctx); }); !r)
2296+
return std::unexpected(r.error());
2297+
if (auto r = timed("make plan", [&] { return step13_make_plan(state, ctx); }); !r)
2298+
return std::unexpected(r.error());
2299+
if (auto r = timed("cxx private runtime", [&] { return step13_cxx_private_runtime(state, ctx); }); !r)
2300+
return std::unexpected(r.error());
2301+
if (auto r = timed("cxx process runtime", [&] { return step13_cxx_process_runtime(state, ctx); }); !r)
2302+
return std::unexpected(r.error());
2303+
timed("graph and schedule", [&] { step13_graph_and_schedule(state, ctx); return 0; });
2304+
if (auto r = timed("build graph actions", [&] { return step13_build_graph_actions(state, ctx); }); !r)
2305+
return std::unexpected(r.error());
2306+
if (auto r = timed("assembly units", [&] { return step13_assembly_units(state, ctx); }); !r)
2307+
return std::unexpected(r.error());
2308+
if (auto r = timed("windows resources", [&] { return step13_windows_resources(state, ctx); }); !r)
2309+
return std::unexpected(r.error());
2310+
if (auto r = timed("dependency cache", [&] { return step13_dependency_cache(state, ctx); }); !r)
2311+
return std::unexpected(r.error());
2312+
if (auto r = timed("lockfile", [&] { return step13_lockfile(state, ctx); }); !r)
2313+
return std::unexpected(r.error());
2314+
if (auto r = timed("runtime provider overrides", [&] { return step13_runtime_provider_overrides(state, ctx); }); !r)
2315+
return std::unexpected(r.error());
2316+
if (auto r = timed("abi enforcement", [&] { return step13_abi_enforcement(state, ctx); }); !r)
2317+
return std::unexpected(r.error());
2318+
timed("resolution json", [&] { step13_resolution_json(state, ctx); return 0; });
2319+
if (auto r = timed("empty link check", [&] { return step13_empty_link_check(state, ctx); }); !r)
2320+
return std::unexpected(r.error());
2321+
timed("report packages", [&] { step13_report_packages(state, ctx); return 0; });
2322+
22942323

22952324
ctx.planNotes = std::move(state.planNotes);
22962325
return ctx;

0 commit comments

Comments
 (0)