Skip to content

Fix skipped-target and cache-hit span timing - #7

Merged
JSGette merged 3 commits into
mainfrom
jsgette/6-span-timing
Nov 2, 2026
Merged

JSGette merged 3 commits into
mainfrom
jsgette/6-span-timing

Conversation

@JSGette

@JSGette JSGette commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Fixes #6.

Skipped targets and cache-hit actions reported durations they never took (trace 4a1d125a3ec94e75baa10a7a1daa2628: skipped targets 173 s, GoCompilePkg cache hits 88–161 s).

  • Skipped-targets group no longer spans the build. Bazel 9 reports skips both during analysis and after execution. Every skipped target and the group now share the first skip's timestamp, kept inside the invocation.
  • Targets aborted only via TargetConfigured get a span. Bazel 9 reports some analysis failures without a ConfiguredLabel event; a second report for the same target is ignored.
  • Cache hits take no time. Bazel reports a cache hit with the start/end of the run that filled the cache. A cache hit (cached == true, or before Bazel 10 an action starting before the build) is now a zero-length span at the time Bazel reported it and ranks as zero duration in the lightweight span budget. An explicit cache miss keeps its timing.

Testing

  • bazel test -c opt //...: pass (121 unit tests, new ones for each fix).
  • Two live builds of a repro workspace (second one from disk cache) streamed through conduit serve into Datadog. Bazel reported the cache hits starting ~12.4 s before the build with build 1's 6.42 s / 4.46 s durations; the trace shows them as 0 ms at their report time inside their targets. The executed action keeps its 3.19 s, and both skipped targets sit in a 0 ms group.

Risk

cached_spawn_chain_is_nested_inside_root_window no longer expects cache-hit actions to have nonzero width; that expectation encoded the duration-preserving behavior removed here.

The group span opened at the invocation start and closed at the build
end, while every skipped target inside it is zero-length, so a build
with skipped targets reported them as taking the whole build. Skipped
targets take no time, but Bazel reports them both during analysis and
after execution, so a first-to-last window would still span the build.
Put every skipped target and the group at the first skip's timestamp,
kept inside the invocation. Remove the uncalled on_aborted_label, which
built the same group the old way.
Bazel 9 reports targets that fail analysis through aborted TargetConfigured
events, often without a matching ConfiguredLabel event, so some skipped
targets never got a span. Route those events to on_target_skipped and
ignore a second report for a target that is already skipped.

Refs #6
Bazel reports a cache hit with the start and end time of the run that
filled the cache. Conduit kept that duration and shifted it to the build
start, so cache hits showed minutes of work they never did and won the
lightweight span budget over real slow actions.

A cache hit (cached == true, or, before Bazel 10, an action starting
before the build) is now a zero-length span at the time Bazel reported
it, and ranks as zero duration in the budget. An explicit cache miss
keeps its timing.

Refs #6
@JSGette
JSGette merged commit 0255081 into main Nov 2, 2026
3 checks passed
@JSGette JSGette mentioned this pull request Nov 2, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skipped targets and cache hits report durations they did not take

1 participant