perf: Reduce per-task allocations in visitor dispatch loop#11986
Merged
anthonyshew merged 1 commit intomainfrom Feb 24, 2026
Merged
perf: Reduce per-task allocations in visitor dispatch loop#11986anthonyshew merged 1 commit intomainfrom
anthonyshew merged 1 commit intomainfrom
Conversation
Two changes to the task dispatch loop in visitor/mod.rs: 1. Use HashMap::remove() instead of .get().clone() when looking up pre-computed task hashes and execution environments. Each task is dispatched exactly once, so we can move the values out instead of deep-cloning (String, EnvironmentVariableMap) per task. 2. Reorder the non-dry dispatch path so reference-only consumers of the TaskId (output_client, telemetry) are built before the final move, eliminating one TaskId clone per task.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Coverage Report
|
anthonyshew
added a commit
that referenced
this pull request
Feb 25, 2026
## Release v2.8.11-canary.28 > [!NOTE] > This release PR was created manually because the [automated release workflow failed](https://github.com/vercel/turborepo/actions/runs/22396672874/job/64834751381) during the "Create Release PR" step. The npm packages were already published successfully. ### Changes - release(turborepo): 2.8.11-canary.27 (#11975) (`09e2557`) - chore: Move git hooks from pre-commit to pre-push and match CI lint checks (#11977) (`68928c0`) - chore: Update AGENTS.md (#11978) (`3887e0d`) - fix: Use correct pnpm version in library release workflow (#11979) (`716229d`) - fix: Fix library release workflow for Trusted Publishing OIDC (#11980) (`f2b57af`) - fix: Use repo setup-node action in library release package job (#11981) (`c8d6fd8`) - fix: Add repository field to @turbo/repository package.json (#11982) (`2865110`) - perf: Replace heap-allocated String with stack-allocated OidHash for git OIDs (#11984) (`24e1937`) - perf: Eliminate redundant syscalls in FSCache fetch and exists (#11985) (`ba1e3bb`) - release(library): 0.0.1-canary.19 (#11983) (`a5bc714`) - perf: Reduce per-task allocations in visitor dispatch loop (#11986) (`53b2b4f`) - docs: Fix same-page anchor links that don't scroll to target (#11989) (`b1d5ec2`) - docs: Mention inputs key in package hash inputs table (#11990) (`6bc216b`) - fix(docs): update sitemap.md to single-line pipe-delimited format (#11976) (`fd15d24`) - fix: Disable husky pre-push hook during release staging (#11991) (`2365307`) - fix: Disable husky pre-push hook in release workflow (#11992) (`71ca25c`)
github-actions Bot
added a commit
that referenced
this pull request
Feb 25, 2026
## Release v2.8.11-canary.29 Versioned docs: https://v2-8-11-canary-29.turborepo.dev ### Changes - release(turborepo): 2.8.11-canary.27 (#11975) (`09e2557`) - chore: Move git hooks from pre-commit to pre-push and match CI lint checks (#11977) (`68928c0`) - chore: Update AGENTS.md (#11978) (`3887e0d`) - fix: Use correct pnpm version in library release workflow (#11979) (`716229d`) - fix: Fix library release workflow for Trusted Publishing OIDC (#11980) (`f2b57af`) - fix: Use repo setup-node action in library release package job (#11981) (`c8d6fd8`) - fix: Add repository field to @turbo/repository package.json (#11982) (`2865110`) - perf: Replace heap-allocated String with stack-allocated OidHash for git OIDs (#11984) (`24e1937`) - perf: Eliminate redundant syscalls in FSCache fetch and exists (#11985) (`ba1e3bb`) - release(library): 0.0.1-canary.19 (#11983) (`a5bc714`) - perf: Reduce per-task allocations in visitor dispatch loop (#11986) (`53b2b4f`) - docs: Fix same-page anchor links that don't scroll to target (#11989) (`b1d5ec2`) - docs: Mention inputs key in package hash inputs table (#11990) (`6bc216b`) - fix(docs): update sitemap.md to single-line pipe-delimited format (#11976) (`fd15d24`) - fix: Disable husky pre-push hook during release staging (#11991) (`2365307`) - fix: Disable husky pre-push hook in release workflow (#11992) (`71ca25c`) - release(turborepo): 2.8.11-canary.28 (#11993) (`5793b0a`) - fix: Use versioned schema URLs in Turborepo skill files (#11994) (`7e48e24`) --------- Co-authored-by: Turbobot <turbobot@vercel.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HashMap::remove()instead of.get().clone()for pre-computed task hash/env lookups — moves values out instead of deep-cloning(String, EnvironmentVariableMap)per taskTaskId(output_client, telemetry) are built before the final move, eliminating oneTaskIdclone per taskWhy
The visitor dispatch loop runs once per task (~1,700 iterations in a large monorepo). Each iteration was:
(String, HashMap<String, String>)from the precomputed map via.get().clone()— even though each task is dispatched exactly onceTaskId(twoCow<str>fields) 3 times when only 2 owned copies are neededSince each task ID appears exactly once in the dispatch stream,
HashMap::remove()moves the value out at zero cost. And reordering reference-only uses before the finalinfo.into_owned()eliminates one clone.Testing
No behavioral change — same tasks dispatched in the same order, same hashes and environments. The only difference is ownership transfer (move vs clone) and evaluation order of independent expressions.