Skip to content

Optimize processImportSpecifier by computing shouldFollowImportsFromFile once per file#3052

Merged
VaguelySerious merged 3 commits into
mainfrom
copilot/process-import-specifier-optimization
Jul 24, 2026
Merged

Optimize processImportSpecifier by computing shouldFollowImportsFromFile once per file#3052
VaguelySerious merged 3 commits into
mainfrom
copilot/process-import-specifier-optimization

Conversation

Copilot AI commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Description

processImportSpecifier was calling shouldFollowImportsFromFile(filePath, forceFollowImports) once for every import specifier in a file, even though the result only depends on filePath and forceFollowImports. Hoist that evaluation into processFile and pass the boolean result down:

  • processFile now computes shouldFollow once before iterating specifiers.
  • processImportSpecifier now accepts a shouldFollow: boolean argument instead of forceFollowImports: boolean.
// Before
await Promise.all(
  specifiers.map((specifier) =>
    processImportSpecifier(filePath, specifier, forceFollowImports)
  )
);

// After
const shouldFollow = await shouldFollowImportsFromFile(filePath, forceFollowImports);
// ...
await Promise.all(
  specifiers.map((specifier) =>
    processImportSpecifier(filePath, specifier, shouldFollow)
  )
);

How did you test your changes?

  • Ran the @workflow/builders test suite (fast-discovery.test.ts and related files pass).
  • Verified the change with Biome lint/format on the modified file.

PR Checklist - Required to merge

  • 📦 pnpm changeset was run to create a changelog for this PR
    • Use the correct semver bump type: patch for bug fixes, minor for new features, major for breaking changes.
    • Use pnpm changeset --empty if you are changing documentation or workbench apps
  • 🔒 DCO sign-off passes (run git commit --signoff on your commits)
  • 📝 Ping @vercel/workflow in a comment once the PR is ready, and above checklist is complete

@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview, Comment Jul 23, 2026 10:49pm
example-nextjs-workflow-webpack Ready Ready Preview, Comment Jul 23, 2026 10:49pm
example-workflow Ready Ready Preview, Comment Jul 23, 2026 10:49pm
workbench-astro-workflow Ready Ready Preview, Comment Jul 23, 2026 10:49pm
workbench-express-workflow Ready Ready Preview, Comment Jul 23, 2026 10:49pm
workbench-fastify-workflow Ready Ready Preview, Comment Jul 23, 2026 10:49pm
workbench-hono-workflow Ready Ready Preview, Comment Jul 23, 2026 10:49pm
workbench-nestjs-workflow Ready Ready Preview, Comment Jul 23, 2026 10:49pm
workbench-nitro-workflow Ready Ready Preview, Comment Jul 23, 2026 10:49pm
workbench-nuxt-workflow Ready Ready Preview, Comment Jul 23, 2026 10:49pm
workbench-sveltekit-workflow Ready Ready Preview, Comment Jul 23, 2026 10:49pm
workbench-tanstack-start-workflow Ready Ready Preview, Comment Jul 23, 2026 10:49pm
workbench-vite-workflow Ready Ready Preview, Comment Jul 23, 2026 10:49pm
workflow-docs Ready Ready Preview, Comment, Open in v0 Jul 23, 2026 10:49pm
workflow-swc-playground Ready Ready Preview, Comment Jul 23, 2026 10:49pm
workflow-tarballs Ready Ready Preview, Comment Jul 23, 2026 10:49pm
workflow-web Ready Ready Preview, Comment Jul 23, 2026 10:49pm

@changeset-bot

changeset-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 10fad5b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
@workflow/builders Patch
@workflow/astro Patch
@workflow/cli Patch
@workflow/nest Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/nuxt Patch
@workflow/rollup Patch
@workflow/sveltekit Patch
@workflow/vite Patch
@workflow/vitest Patch
workflow Patch
@workflow/world-testing Patch
@workflow/core Patch
@workflow/web-shared Patch
@workflow/web Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@shuding
shuding marked this pull request as ready for review July 22, 2026 15:16
@shuding
shuding requested review from a team and ijjk as code owners July 22, 2026 15:16
@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

Passed Failed Skipped Total
✅ ▲ Vercel Production 1455 0 239 1694
✅ 💻 Local Development 1621 0 227 1848
✅ 📦 Local Production 1621 0 227 1848
✅ 🐘 Local Postgres 1621 0 227 1848
✅ 🪟 Windows 154 0 0 154
✅ 📋 Other 1020 0 212 1232
✅ vercel-multi-region 27 0 0 27
Total 7519 0 1132 8651

Details by Category

✅ ▲ Vercel Production
App Passed Failed Skipped
✅ astro 126 0 28
✅ example 126 0 28
✅ express 126 0 28
✅ fastify 126 0 28
✅ hono 126 0 28
✅ nextjs-turbopack 151 0 3
✅ nextjs-webpack 151 0 3
✅ nitro 126 0 28
✅ nuxt 126 0 28
✅ sveltekit 145 0 9
✅ vite 126 0 28
✅ 💻 Local Development
App Passed Failed Skipped
✅ astro-stable 128 0 26
✅ express-stable 128 0 26
✅ fastify-stable 128 0 26
✅ hono-stable 128 0 26
✅ nextjs-turbopack-canary 135 0 19
✅ nextjs-turbopack-stable 154 0 0
✅ nextjs-webpack-canary 135 0 19
✅ nextjs-webpack-stable 154 0 0
✅ nitro-stable 128 0 26
✅ nuxt-stable 128 0 26
✅ sveltekit-stable 147 0 7
✅ vite-stable 128 0 26
✅ 📦 Local Production
App Passed Failed Skipped
✅ astro-stable 128 0 26
✅ express-stable 128 0 26
✅ fastify-stable 128 0 26
✅ hono-stable 128 0 26
✅ nextjs-turbopack-canary 135 0 19
✅ nextjs-turbopack-stable 154 0 0
✅ nextjs-webpack-canary 135 0 19
✅ nextjs-webpack-stable 154 0 0
✅ nitro-stable 128 0 26
✅ nuxt-stable 128 0 26
✅ sveltekit-stable 147 0 7
✅ vite-stable 128 0 26
✅ 🐘 Local Postgres
App Passed Failed Skipped
✅ astro-stable 128 0 26
✅ express-stable 128 0 26
✅ fastify-stable 128 0 26
✅ hono-stable 128 0 26
✅ nextjs-turbopack-canary 135 0 19
✅ nextjs-turbopack-stable 154 0 0
✅ nextjs-webpack-canary 135 0 19
✅ nextjs-webpack-stable 154 0 0
✅ nitro-stable 128 0 26
✅ nuxt-stable 128 0 26
✅ sveltekit-stable 147 0 7
✅ vite-stable 128 0 26
✅ 🪟 Windows
App Passed Failed Skipped
✅ nextjs-turbopack 154 0 0
✅ 📋 Other
App Passed Failed Skipped
✅ e2e-local-dev-nest-stable 128 0 26
✅ e2e-local-dev-tanstack-start- 128 0 26
✅ e2e-local-postgres-nest-stable 128 0 26
✅ e2e-local-postgres-tanstack-start- 128 0 26
✅ e2e-local-prod-nest-stable 128 0 26
✅ e2e-local-prod-tanstack-start- 128 0 26
✅ e2e-vercel-prod-nest 126 0 28
✅ e2e-vercel-prod-tanstack-start 126 0 28
✅ vercel-multi-region
App Passed Failed Skipped
✅ nextjs-turbopack 27 0 0

📋 View full workflow run

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

📊 Workflow Benchmarks

commit 10fad5b · Thu, 23 Jul 2026 23:01:48 GMT · run logs

Backend: vercel · app: nextjs-turbopack

Metric Scenario Best (ms) P75 (ms) P90 (ms) P99 (ms) Samples
TTFS step 1319 (+32%) 🔻 1415 🔴 (+29%) 🔻 1497 🔴 (+34%) 🔻 1866 🔴 (+10%) 30
TTFS stream 412 (+9.0%) 1408 🔴 (+28%) 🔻 1482 🔴 (+31%) 🔻 1587 🔴 (+25%) 🔻 30
TTFS hook + stream 1470 (+166%) 🔻 1728 🔴 (+23%) 🔻 1781 🔴 (+21%) 🔻 1897 🔴 (+28%) 🔻 30
STSO 1020 steps (1-20) 185 (+1.1%) 294 🔴 (+6.9%) 305 🔴 (+4.8%) 331 🔴 (±0%) 19
STSO 1020 steps (101-120) 198 (+3.1%) 322 🔴 (+1.6%) 567 🔴 (+21%) 🔻 2199 🔴 (+248%) 🔻 19
STSO 1020 steps (1001-1020) 483 (-4.2%) 573 🔴 (-4.0%) 599 🔴 (-9.1%) 816 🔴 (+12%) 19
WO 1020 steps 403452 (-3.3%) 403452 (-3.3%) 403452 (-3.3%) 403452 (-3.3%) 1
SL stream latency 107 (+2.9%) 157 🔴 (-0.6%) 184 🔴 (-9.4%) 263 🔴 (-32%) 💚 30
📜 Previous results (1)

8c32b94

Wed, 22 Jul 2026 15:32:00 GMT · run logs

vercel / nextjs-turbopack

Metric Scenario Best (ms) P75 (ms) P90 (ms) P99 (ms) Samples
TTFS step 146 (+20%) 🔻 415 🔴 (+73%) 🔻 2121 🔴 (+553%) 🔻 2620 🔴 (+508%) 🔻 30
TTFS stream 136 (-12%) 304 🔴 (-10%) 2368 🔴 (+542%) 🔻 4518 🔴 (+876%) 🔻 30
TTFS hook + stream 259 (-16%) 💚 405 🔴 (-12%) 511 🔴 (+0.6%) 2710 🔴 (+336%) 🔻 30
STSO 1020 steps (1-20) 170 (-11%) 289 🔴 (-1.7%) 331 🔴 (-1.8%) 416 🔴 (+19%) 🔻 19
STSO 1020 steps (101-120) 208 (-6.7%) 323 🔴 (+0.6%) 384 🔴 (-21%) 💚 412 🔴 (-18%) 💚 19
STSO 1020 steps (1001-1020) 513 (-15%) 💚 667 🔴 (-15%) 713 🔴 (-18%) 💚 921 🔴 (-17%) 💚 19
WO 1020 steps 441418 (-17%) 💚 441418 (-17%) 💚 441418 (-17%) 💚 441418 (-17%) 💚 1
SL stream latency 86 (-4.4%) 142 🔴 (-5.3%) 226 🔴 (+25%) 🔻 402 🔴 (+76%) 🔻 30

Best/P75/P90/P99 deltas compare against the most recent benchmark run on main at the time of this run. 🔻 flags a delta worse than +15%, 💚 one better than −15%.

Metrics — TTFS: time to first step body (in-deployment start() → first step body, deployment clocks) · STSO: step-to-step overhead (gap between consecutive step bodies) · WO: workflow overhead (whole-run time outside step bodies, in-deployment anchored) · SL: stream latency (in-deployment write → read propagation, readAt - writtenAt)

Scenarios — step: one trivial no-op step, no stream; no hooks, so the run stays in turbo mode (in-process fast path) · stream: one streaming step; no hooks, so the run stays in turbo mode (in-process fast path) · hook + stream: registers a hook before one step, which exits turbo mode (dispatch path) · 1020 steps: 1020 trivial sequential steps; STSO is measured between consecutive steps in the given step ranges, and WO is the whole-run overhead outside step bodies · stream latency: parallel reader/writer steps on a dedicated stream; SL is the in-deployment write->read propagation (readAt - writtenAt)

🔴 marks a percentile over its target (within target is left unmarked). Targets (p75/p90/p99, ms) — TTFS 200/300/600 · SL 50/60/125 · STSO (1-20) 20/30/60 · STSO (101-120) 30/45/90 · STSO (1001-1020) 40/60/120

All metrics are measured from deployment-side timestamps only. Runs are triggered by an in-deployment route that stamps the anchor (clientStart) right before start(), so the CI runner’s request and its path through api.vercel.com sit outside every measured window. TTFS = in-deployment start() → first step body (turbo uses the in-process fast path, non-turbo the dispatch path), and includes the VQS dispatch hop plus any /flow cold start. STSO/WO are measured between step bodies on the deployment. SL is measured inside the workflow (parallel reader/writer steps), so it no longer includes the api.vercel.com read path.

Cold starts are kept in the numbers on purpose — they are part of real bursty-workload latency. The workbench deployment cold-starts the /flow invocation for a large fraction of runs, inflating P75+; the Best column shows the fastest (warm-start) sample for comparison.

@VaguelySerious
VaguelySerious enabled auto-merge (squash) July 23, 2026 23:54
@VaguelySerious
VaguelySerious merged commit b406a04 into main Jul 24, 2026
243 of 248 checks passed
@VaguelySerious
VaguelySerious deleted the copilot/process-import-specifier-optimization branch July 24, 2026 18:29
github-actions Bot added a commit that referenced this pull request Jul 24, 2026
…omFile` once per file (#3052)

Signed-off-by: Copilot <198982749+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Backport PR opened against stable: #3086. (backport job run)

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.

3 participants