turborepo
4b5410b3 - perf: Send engine callback before tracker bookkeeping and add tracing spans (#11970)

Commit
15 hours ago
perf: Send engine callback before tracker bookkeeping and add tracing spans (#11970) ## 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.
Author
Parents
Loading