perf: enable Turbopack filesystem cache for agents-manage-ui builds#2045
perf: enable Turbopack filesystem cache for agents-manage-ui builds#2045nick-inkeep merged 3 commits intomainfrom
Conversation
Enable experimental turbopackFileSystemCacheForBuild in Next.js config and persist .next/cache across GitHub Actions runs. When turbo remote cache has a miss (source files changed), Turbopack can now do an incremental rebuild using the persisted function-level cache instead of compiling from scratch. Local benchmarks show ~45% speedup on warm incremental builds (14s vs 26s) with 3x less CPU usage. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
|
There was a problem hiding this comment.
PR Review Summary
(0) Total Issues | Risk: Low
🔴❗ Critical (0) ❗🔴
None
🟠⚠️ Major (0) 🟠⚠️
None
🟡 Minor (0) 🟡
None
💭 Consider (1) 💭
💭 1) agents-manage-ui/next.config.ts:19-21 Experimental flag enabled unconditionally
Issue: The turbopackFileSystemCacheForBuild: true flag is enabled for all environments (local dev, CI, production) rather than being gated to specific contexts.
Why: This is low risk since the flag only affects build performance, not runtime behavior. If cache artifacts ever become corrupted, a clean build still works. However, some teams prefer gating experimental features to CI only for production builds.
Fix: If preferred, gate the flag: turbopackFileSystemCacheForBuild: !!process.env.CI. However, keeping it enabled everywhere also provides local dev benefits, which may be the intended design.
Refs: next.config.ts:19-21
✅ APPROVE
Summary: This is a well-implemented CI performance optimization. The cache key strategy is sound with a proper three-tier fallback hierarchy (exact match → dependency match → any previous). The implementation correctly separates Next.js build cache from Turborepo's remote cache (turbo.json already excludes .next/cache/**). Both CI and Cypress workflows receive identical cache configuration enabling cross-workflow cache sharing. The experimental flag has been dogfooded by Vercel for 1+ year and only affects build time, not runtime behavior. Ship it! 🚀
Discarded (5)
| Location | Issue | Reason Discarded |
|---|---|---|
.github/workflows/ci.yml:59-66 |
Cache key strategy is well-designed | Positive observation, not actionable |
| Multi-file | Cache configuration correctly duplicated | Positive observation, not actionable |
turbo.json:34 |
turbo.json correctly excludes .next/cache | Positive observation, not actionable |
.github/workflows/release.yml |
Release workflow doesn't include cache | Informational - intentional design choice |
.github/workflows/ci.yml:60 |
Actions use mutable version tags | Pre-existing pattern, not introduced by this PR |
Reviewers (2)
| Reviewer | Returned | Main Findings | Consider | While You're Here | Inline Comments | Pending Recs | Discarded |
|---|---|---|---|---|---|---|---|
pr-review-devops |
6 | 0 | 1 | 0 | 0 | 0 | 5 |
pr-review-standards |
0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Total | 6 | 0 | 1 | 0 | 0 | 0 | 5 |
Add a type export to change the source hash and force a turbo cache miss, while the GitHub Actions restore-key fallback restores the .next/cache from the first run. This verifies that the warm incremental Turbopack build is faster than cold. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
PR Review Summary
(0) Total Issues | Risk: Low
Delta Review Scope
This re-review is scoped to changes since the previous review:
- Commit:
97d1a5cc— "test: trigger second CI run to verify warm Turbopack cache" - Changed file:
agents-manage-ui/src/lib/utils.ts(+1 line)
🔴❗ Critical (0) ❗🔴
None
🟠⚠️ Major (0) 🟠⚠️
None
🟡 Minor (0) 🟡
None
💭 Consider (0) 💭
None
Delta Analysis
Change: Added export type CssTemplate = ReturnType<typeof String.raw>; to co-locate a type export with the existing css constant.
Assessment:
- ✅ Correctness: The type correctly extracts the return type of
String.raw(a template literal tag function) - ✅ Purpose: Intentional test change to verify Turbopack filesystem cache behavior on incremental builds
- ✅ Impact: Type-only export — no runtime impact, no breaking changes
- ✅ Quality: Well-placed next to the related
cssexport
This is a trivial, intentional change with no review concerns.
🕐 Pending Recommendations (1)
- 💭
next.config.ts:19-21— Experimental flag enabled unconditionally (optional gating consideration from prior review)
✅ APPROVE
Summary: The delta since the last review is a single type export added to trigger a second CI run — this validates the Turbopack cache optimization that is the core of this PR. The previous review approved the main implementation; this follow-up commit introduces no concerns. Ready to ship! 🚀
Reviewers (0)
| Reviewer | Returned | Main Findings | Consider | While You're Here | Inline Comments | Pending Recs | Discarded |
|---|---|---|---|---|---|---|---|
| orchestrator-only | 1 | 0 | 0 | 0 | 0 | 1 | 0 |
| Total | 1 | 0 | 0 | 0 | 0 | 1 | 0 |
Note: Delta was trivial (1 type export to trigger CI). No subagent reviewers dispatched — orchestrator-only assessment.
Removes the test type export that was flagged by knip as unused. The warm cache verification succeeded (7.2s vs 85-105s cold). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
PR Review Summary
(0) Total Issues | Risk: Low
Delta Review Scope
This re-review is scoped to changes since the previous review:
- Commit:
9edbb4ab— "fix: remove unused CssTemplate type export" - Changed file:
agents-manage-ui/src/lib/utils.ts(-1 line)
🔴❗ Critical (0) ❗🔴
None
🟠⚠️ Major (0) 🟠⚠️
None
🟡 Minor (0) 🟡
None
💭 Consider (0) 💭
None
Delta Analysis
Change: Removed export type CssTemplate = ReturnType<typeof String.raw>; from utils.ts.
Assessment:
- ✅ Correctness: Clean removal of unused type export
- ✅ Purpose: Cleanup of test code that was added in the previous commit (
97d1a5cc) to verify Turbopack filesystem cache behavior - ✅ Impact: No runtime or type impact — the type was never used
- ✅ Quality: Proper cleanup after validation testing
This is a trivial housekeeping change with no review concerns.
🕐 Pending Recommendations (1)
- 💭
next.config.ts:19-21— Experimental flag enabled unconditionally (optional gating consideration from prior review)
✅ APPROVE
Summary: The delta since the last review is a single line deletion — removing a test type export that was added to trigger CI for cache validation. The main implementation (Turbopack filesystem cache config + workflow caching) was approved in prior reviews. This cleanup commit introduces no concerns. Ship it! 🚀
Reviewers (0)
| Reviewer | Returned | Main Findings | Consider | While You're Here | Inline Comments | Pending Recs | Discarded |
|---|---|---|---|---|---|---|---|
| orchestrator-only | 1 | 0 | 0 | 0 | 0 | 1 | 0 |
| Total | 1 | 0 | 0 | 0 | 0 | 1 | 0 |
Note: Delta was trivial (1 line deletion to clean up test code). No subagent reviewers dispatched — orchestrator-only assessment.
Enable turbopackFileSystemCacheForBuild in agents-docs and persist .next/cache in CI via a dedicated GHA cache step. This targets the largest CI bottleneck (agents-docs cold build: 3.7-6.3min, 40-56% of CI time) with the same incremental caching approach used for agents-manage-ui in #2045. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* perf: enable Turbopack filesystem cache for agents-docs builds Enable turbopackFileSystemCacheForBuild in agents-docs and persist .next/cache in CI via a dedicated GHA cache step. This targets the largest CI bottleneck (agents-docs cold build: 3.7-6.3min, 40-56% of CI time) with the same incremental caching approach used for agents-manage-ui in #2045. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: include agents-core in docs cache key hash Add packages/agents-core/src/** to agents-docs cache key source hash for consistency with agents-manage-ui pattern, since agents-docs imports from agents-core. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Summary
turbopackFileSystemCacheForBuild(experimental) inagents-manage-ui/next.config.ts.next/cacheacross GitHub Actions runs in both CI and Cypress workflowsProblem
When turbo remote cache has a MISS for
agents-manage-ui(source files changed), Next.js compiles the entire app from scratch every run (~71s in CI). Turbopack's default in-memory compilation writes nothing persistent, so each CI run pays the full compile cost even when only a single component changed.Approach
Turbopack's
turbopackFileSystemCacheForBuildflag serializes function-level compilation artifacts to.next/cache. When restored on the next build, Turbopack only recomputes the changed subgraph.We persist
.next/cacheviaactions/cache(separate from turborepo cache) with a restore-key fallback pattern that enables cross-PR cache sharing — any recent build's cache works as a warm start for any new build.Changes
agents-manage-ui/next.config.tsexperimental.turbopackFileSystemCacheForBuild: true.github/workflows/ci.ymlactions/cachestep foragents-manage-ui/.next/cache.github/workflows/cypress.ymlactions/cachestep foragents-manage-ui/.next/cacheEvidence
Local benchmarks (same codebase, same machine):
~45% speedup on warm incremental builds, 3x CPU reduction.
In CI (where cold builds take ~71s), estimated warm build: ~35-40s.
Cache Key Strategy
Notes
turbo.jsonunchanged —.next/cacheis excluded from turbo outputs by design.next/cache)Test Plan
.next/cacheis restored on second CI run (check GHA cache logs)🤖 Generated with Claude Code