Skip to main content

Module build_trace

Module build_trace 

Source
Expand description

The build trace: where a build spent its wall clock, and what its external sorts did — the debugging half of the build record that rete build stores in the kind-7 build-info section.

It is a lap timer, not a profiler. The builders call lap at the end of each phase; the time since the previous lap is charged to that phase, so the phases partition the build’s wall clock and never overlap. Counters (add, max) record what the memory-bounded build’s spill did.

Recording happens only while a Collector is alive on the calling thread — the CLI starts one around a build. Every other caller (the bindings, the browser builder, tests that build in parallel threads) pays one thread-local check per phase and records nothing. That check also keeps the clock out of wasm32-unknown-unknown, where std::time::Instant::now() panics: without a collector it is never called, and on wasm32 the functions are no-ops.

Structs§

Collector
Records the build trace of the current thread for as long as it lives. Starting a second collector on a thread replaces the first.
Trace
What a Collector recorded.

Enums§

Phase
One phase of a build. A closed set, so a reader of the record knows every name it can meet, and a writer can size a record before the build has run.

Functions§

active
True while a collector records on this thread — for a measurement that costs something (a directory walk) and is worth skipping otherwise.
add
Add v to the counter name. A no-op without a collector.
enabled_features
The Cargo features this rete-core was compiled with that change what a build writes or how fast it runs — recorded with the engine identity.
lap
End phase: charge it the wall-clock time since the previous lap (or since the collector started). A no-op without a collector on this thread.
max
Raise the counter name to v if it is lower. A no-op without a collector.
skip
Restart the lap clock without charging anything — for time a caller does not want attributed to the next phase.