Skip to content

Comments

perf: Send engine callback before tracker bookkeeping and add tracing spans#11970

Merged
anthonyshew merged 3 commits intomainfrom
dispatch-tracing-and-cache-perf
Feb 23, 2026
Merged

perf: Send engine callback before tracker bookkeeping and add tracing spans#11970
anthonyshew merged 3 commits intomainfrom
dispatch-tracing-and-cache-perf

Conversation

@anthonyshew
Copy link
Contributor

@anthonyshew anthonyshew commented Feb 23, 2026

Summary

Moves the engine callback send in task execute() to fire immediately after output is flushed (output_client.finish()), before the tracker bookkeeping (tracker.cached(), tracker.build_succeeded(), etc.). This unblocks the engine's DAG walker sooner — dependent tasks can be dispatched while the completed task's run summary tracking happens in the background.

Repo Tasks Baseline After Delta
Small (~5 packages) 5 164ms 163ms ~flat
Medium (~125 packages) 70 848ms 864ms ~flat
Large (~1000 packages) 1700 845ms 804ms -41ms (-4.9%)

Profiled with --profile across three monorepos of varying size (full cache hit scenario, median of 5 warm runs).

Changes

Also adds tracing spans throughout the dispatch loop and builder startup for profiling visibility:

  • visit_recv_wait, task_cache_new, exec_context_new in the dispatch loop
  • micro_frontends_from_disk, task_access_setup, turbo_json_loader_setup, root_turbo_json_load, pkg_dep_graph_validate in builder startup

Output ordering is preserved because the callback fires after all log replay and output flushing is complete.

  • crates/turborepo-task-executor/src/exec.rs — Restructured execute() to send callback immediately after output flush, before tracker bookkeeping.
  • crates/turborepo-lib/src/task_graph/visitor/mod.rs — Added visit_recv_wait, task_cache_new, exec_context_new tracing spans.
  • crates/turborepo-lib/src/run/builder.rs — Added tracing spans for uninstrumented startup phases.

@anthonyshew anthonyshew requested a review from a team as a code owner February 23, 2026 21:09
@anthonyshew anthonyshew requested review from tknickman and removed request for a team February 23, 2026 21:09
@vercel
Copy link
Contributor

vercel bot commented Feb 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
examples-basic-web Ready Ready Preview, Comment, Open in v0 Feb 23, 2026 9:27pm
examples-designsystem-docs Building Building Preview, Comment, Open in v0 Feb 23, 2026 9:27pm
examples-gatsby-web Ready Ready Preview, Comment, Open in v0 Feb 23, 2026 9:27pm
examples-kitchensink-blog Ready Ready Preview, Comment, Open in v0 Feb 23, 2026 9:27pm
examples-nonmonorepo Ready Ready Preview, Comment, Open in v0 Feb 23, 2026 9:27pm
examples-svelte-web Ready Ready Preview, Comment, Open in v0 Feb 23, 2026 9:27pm
examples-tailwind-web Ready Ready Preview, Comment, Open in v0 Feb 23, 2026 9:27pm
examples-vite-web Ready Ready Preview, Comment, Open in v0 Feb 23, 2026 9:27pm
turbo-site Ready Ready Preview, Comment, Open in v0 Feb 23, 2026 9:27pm
turborepo-agents Ready Ready Preview, Comment, Open in v0 Feb 23, 2026 9:27pm
turborepo-test-coverage Ready Ready Preview, Comment, Open in v0 Feb 23, 2026 9:27pm

Adds visit_recv_wait, task_cache_new, and exec_context_new spans
to measure where the dispatch loop spends time. Profiling shows
344ms/830ms is idle wait on the engine channel — the bottleneck
is cache restore speed, not dispatch overhead.
Instruments micro_frontends_from_disk, task_access_setup,
turbo_json_loader_setup, root_turbo_json_load, and
pkg_dep_graph_validate to measure the sequential critical path
between package graph construction and task execution.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 23, 2026

Coverage Report

Metric Coverage
Lines 75.06%
Functions 46.80%
Branches 0.00%

View full report

Move the callback.send() in execute() to fire immediately after
output_client.finish(), before the tracker.cached()/build_succeeded
bookkeeping. This unblocks the engine's DAG walk sooner — dependents
can be dispatched while the completed task's summary tracking runs
in the background.

Output ordering is preserved because the callback fires after all
output is flushed, not before.
@anthonyshew anthonyshew force-pushed the dispatch-tracing-and-cache-perf branch from 4d40e0a to 4d55c75 Compare February 23, 2026 21:26
@anthonyshew anthonyshew changed the title perf: Early engine callback for confirmed cache hits perf: Send engine callback before tracker bookkeeping and add tracing spans Feb 23, 2026
@anthonyshew anthonyshew merged commit 4b5410b into main Feb 23, 2026
102 of 103 checks passed
@anthonyshew anthonyshew deleted the dispatch-tracing-and-cache-perf branch February 23, 2026 21:47
github-actions bot added a commit that referenced this pull request Feb 23, 2026
## Release v2.8.11-canary.26

Versioned docs: https://v2-8-11-canary-26.turborepo.dev

### Changes

- release(turborepo): 2.8.11-canary.25 (#11971) (`75406f6`)
- perf: Send engine callback before tracker bookkeeping and add tracing
spans (#11970) (`4b5410b`)

---------

Co-authored-by: Turbobot <turbobot@vercel.com>
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.

1 participant