Skip to content

Turbopack: Implement TraceRawVcs and NonLocalValue correctly for Effects#89133

Merged
bgw merged 3 commits intocanaryfrom
bgw/effect-trace-raw-vcs
Mar 24, 2026
Merged

Turbopack: Implement TraceRawVcs and NonLocalValue correctly for Effects#89133
bgw merged 3 commits intocanaryfrom
bgw/effect-trace-raw-vcs

Conversation

@bgw
Copy link
Member

@bgw bgw commented Jan 28, 2026

In subsequent PRs, I want to store a ResolvedVc (specifically, a FileSystemPath, which contains a Vc<Box<dyn FileSystem>>) inside of an Effect.

To do this in a way that wouldn't break a hypothetical future tracing garbage collector, we must implement TraceRawVcs on Effect.

The previous PR changed the Effect type from a closure to a trait in order to enable this.

@nextjs-bot nextjs-bot added created-by: Turbopack team PRs by the Turbopack team. Turbopack Related to Turbopack with Next.js. labels Jan 28, 2026
Copy link
Member Author

bgw commented Jan 28, 2026

@bgw bgw requested review from lukesandberg and sokra January 28, 2026 00:07
@bgw bgw marked this pull request as ready for review January 28, 2026 00:07
@nextjs-bot
Copy link
Collaborator

nextjs-bot commented Jan 28, 2026

Tests Passed

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 28, 2026

Merging this PR will degrade performance by 3.83%

❌ 2 regressed benchmarks
✅ 15 untouched benchmarks
⏩ 3 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation packages-bundle.js[full] 959 ms 992 ms -3.32%
Simulation react-dom-client.development.js[full] 394.2 ms 409.9 ms -3.83%

Comparing bgw/effect-trace-raw-vcs (457fced) with canary (43f9017)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on canary (468a40f) during the generation of this report, so 43f9017 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Comment on lines 133 to +144
EffectState::NotStarted(_) => {
let EffectState::NotStarted(inner) = std::mem::replace(
&mut *guard,
EffectState::Started(Event::new(|| || "Effect".to_string())),
) else {
unreachable!();
let EffectState::NotStarted(effect) =
std::mem::replace(&mut *guard, EffectState::Invalid)
else {
unreachable!()
};
State::NotStarted(inner)
let effect: Arc<dyn DynEffect> = Arc::from(effect);
*guard = EffectState::Started(
effect.clone(),
Event::new(|| || "Effect".to_string()),
);
State::NotStarted(effect)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we just capture effect in the match condition and then assign back? i guess that requires an additional clone on the effect Arc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually tried rewriting it that way, using a manual drop(guard) call. The appears to be some limitation of rustc's analysis here that cause it to think that the future is no longer Send because it thinks the mutex guard might get held across an await point (even though it isn't because of the drop(guard) call).

@nextjs-bot
Copy link
Collaborator

nextjs-bot commented Jan 28, 2026

Stats from current PR

✅ No significant changes detected

📊 All Metrics
📖 Metrics Glossary

Dev Server Metrics:

  • Listen = TCP port starts accepting connections
  • First Request = HTTP server returns successful response
  • Cold = Fresh build (no cache)
  • Warm = With cached build artifacts

Build Metrics:

  • Fresh = Clean build (no .next directory)
  • Cached = With existing .next directory

Change Thresholds:

  • Time: Changes < 50ms AND < 10%, OR < 2% are insignificant
  • Size: Changes < 1KB AND < 1% are insignificant
  • All other changes are flagged to catch regressions

⚡ Dev Server

Metric Canary PR Change Trend
Cold (Listen) 455ms 455ms ▁▁▁▁▁
Cold (Ready in log) 437ms 438ms ▁▁▁▁▁
Cold (First Request) 1.099s 1.106s ▁▁▁▁▁
Warm (Listen) 456ms 457ms ▁▁▁▁▁
Warm (Ready in log) 447ms 443ms ▁▁▁▁▁
Warm (First Request) 341ms 340ms ▁▁▁▁▁
📦 Dev Server (Webpack) (Legacy)

📦 Dev Server (Webpack)

Metric Canary PR Change Trend
Cold (Listen) 456ms 455ms ▁█▁▁▁
Cold (Ready in log) 439ms 438ms ▁▆▁▁▁
Cold (First Request) 1.946s 1.941s ▃▅▁▃▃
Warm (Listen) 456ms 455ms ▁█▁▁▁
Warm (Ready in log) 439ms 438ms ▁▆▁▁▁
Warm (First Request) 1.959s 1.950s ▂▅▁▂▂

⚡ Production Builds

Metric Canary PR Change Trend
Fresh Build 3.752s 3.711s ▂▁▁▁▁
Cached Build 3.739s 3.750s ▂▁▁▁▁
📦 Production Builds (Webpack) (Legacy)

📦 Production Builds (Webpack)

Metric Canary PR Change Trend
Fresh Build 14.404s 14.478s ▁▄▁▁▁
Cached Build 14.540s 14.558s ▁▅▁▁▁
node_modules Size 484 MB 484 MB █████
📦 Bundle Sizes

Bundle Sizes

⚡ Turbopack

Client

Main Bundles
Canary PR Change
0-d~0o3ehhgmw.js gzip 151 B N/A -
0~lwfcrlb4v_9.css gzip 115 B 115 B
00h0nz7r436~l.js gzip 13.3 kB N/A -
00ivb_iunbucu.js gzip 13 kB N/A -
01at~wdgj81ve.js gzip 48.9 kB N/A -
02ku7edzc_wf7.js gzip 450 B N/A -
03~yq9q893hmn.js gzip 39.4 kB 39.4 kB
04z94byop2jge.js gzip 155 B N/A -
05s5bqmu.v.s2.js gzip 70.8 kB N/A -
092lcb3fqrrf9.js gzip 8.52 kB N/A -
0aj~xs1l1g8tg.js gzip 8.53 kB N/A -
0dt88d2.q3puq.js gzip 156 B N/A -
0g5sqjyu0dlae.js gzip 65.7 kB N/A -
0h35gmp9u328z.js gzip 8.54 kB N/A -
0h6fkavebp.iz.js gzip 8.47 kB N/A -
0ino_yf1k3h6k.js gzip 10.4 kB N/A -
0l9ef8qyt48q4.js gzip 161 B N/A -
0lqjp7063d~ts.js gzip 156 B N/A -
0mc16gv2x1bet.js gzip 13.7 kB N/A -
0mkdvwb8sm1cs.js gzip 157 B N/A -
0mncpry_rfn-y.js gzip 7.61 kB N/A -
0moy~uao4dl.m.js gzip 9.19 kB N/A -
0n3yn2kt3mgkf.js gzip 162 B N/A -
0oqyjf21.xfvl.js gzip 169 B N/A -
0q50rtpusjy90.js gzip 2.28 kB N/A -
0smgy2grrrlka.js gzip 8.58 kB N/A -
0svcqoqon1z.7.js gzip 154 B N/A -
0t1dzhdfh0txh.js gzip 215 B 215 B
0vt7pofxnk8in.js gzip 10.1 kB N/A -
0z6jc9z0349ap.js gzip 155 B N/A -
0zid7o0-vupvp.js gzip 225 B N/A -
11mdhajjc6875.js gzip 157 B N/A -
11yo3xfd6b147.js gzip 12.9 kB N/A -
12_8n261pygfq.js gzip 156 B N/A -
13.84hqxl_1p7.js gzip 9.76 kB N/A -
138ltu~qb2ydz.js gzip 158 B N/A -
1554wr-t7p6z-.js gzip 8.55 kB N/A -
15tjst79~qy3_.js gzip 1.46 kB N/A -
15z_v00ne4ud0.js gzip 8.47 kB N/A -
17d_m3p4j9w6r.js gzip 5.62 kB N/A -
17yu~3yiu7d2m.js gzip 8.52 kB N/A -
turbopack-0_..jw30.js gzip 4.15 kB N/A -
turbopack-01..hk.z.js gzip 4.13 kB N/A -
turbopack-01..3tdd.js gzip 4.17 kB N/A -
turbopack-02..cl~l.js gzip 4.15 kB N/A -
turbopack-09..wmtl.js gzip 4.16 kB N/A -
turbopack-0a..hs-0.js gzip 4.16 kB N/A -
turbopack-0f..4bnp.js gzip 4.16 kB N/A -
turbopack-0g..7vlj.js gzip 4.16 kB N/A -
turbopack-0p..6se..js gzip 4.16 kB N/A -
turbopack-0r...~ib.js gzip 4.16 kB N/A -
turbopack-0s..dnao.js gzip 4.16 kB N/A -
turbopack-0x..ivz7.js gzip 4.16 kB N/A -
turbopack-15..u41w.js gzip 4.15 kB N/A -
turbopack-16..~kqj.js gzip 4.15 kB N/A -
0.ig-nh6ddby4.js gzip N/A 153 B -
02ff96.~as-xu.js gzip N/A 157 B -
03t__~.5lvgeu.js gzip N/A 5.62 kB -
04d6ll75jqx3r.js gzip N/A 9.19 kB -
04wavr--oh-1-.js gzip N/A 155 B -
0583exyh-yhc7.js gzip N/A 9.76 kB -
072lv63r8dcz~.js gzip N/A 8.58 kB -
075t9dxgbf0m8.js gzip N/A 13.7 kB -
0873k5691ee0i.js gzip N/A 70.8 kB -
09123-xgm97yo.js gzip N/A 160 B -
0a3drqm~aryl6.js gzip N/A 153 B -
0ar1~bwpezfgw.js gzip N/A 13.3 kB -
0c99mq1ez2bke.js gzip N/A 450 B -
0cq-cmde_ws6u.js gzip N/A 8.47 kB -
0fwf102w10o9~.js gzip N/A 8.52 kB -
0gtmn.q_j1v5r.js gzip N/A 10.4 kB -
0h5~v-tahitcf.js gzip N/A 10.1 kB -
0i85sm0i~_x1y.js gzip N/A 48.8 kB -
0ka9wyuwc0va-.js gzip N/A 154 B -
0m8yz2-y.owhu.js gzip N/A 7.6 kB -
0nclq9z6yzzm5.js gzip N/A 1.46 kB -
0nga-9kug7bgp.js gzip N/A 154 B -
0nzumcogektg7.js gzip N/A 8.55 kB -
0p5sjual.nuis.js gzip N/A 13 kB -
0pet9ixg7-64s.js gzip N/A 149 B -
0pzv1cr_lc8sc.js gzip N/A 154 B -
0s.c-cn5eebrx.js gzip N/A 8.47 kB -
0t4u4gi13w~ge.js gzip N/A 65.7 kB -
0tna7lg6q4zne.js gzip N/A 12.9 kB -
0votdfxr5fb5u.js gzip N/A 2.28 kB -
0ykl9bs_qj.5..js gzip N/A 8.52 kB -
0zfen0tnxp4gh.js gzip N/A 8.55 kB -
10wkq1h9jzkg..js gzip N/A 225 B -
12s.i1.5kfw6p.js gzip N/A 168 B -
13yp0tf_.vo3_.js gzip N/A 152 B -
143nm3aj63v.8.js gzip N/A 152 B -
149ndfh8zfcaz.js gzip N/A 8.53 kB -
17vn26efzi_wl.js gzip N/A 154 B -
turbopack-01..1zy5.js gzip N/A 4.15 kB -
turbopack-04..ylsp.js gzip N/A 4.15 kB -
turbopack-05..2tc..js gzip N/A 4.16 kB -
turbopack-0g..j7lx.js gzip N/A 4.15 kB -
turbopack-0g..sg37.js gzip N/A 4.16 kB -
turbopack-0h..1v_h.js gzip N/A 4.16 kB -
turbopack-0i..qamy.js gzip N/A 4.17 kB -
turbopack-0o..hr_c.js gzip N/A 4.16 kB -
turbopack-0t..0nu2.js gzip N/A 4.16 kB -
turbopack-0v..9.j3.js gzip N/A 4.16 kB -
turbopack-0v..v9_z.js gzip N/A 4.16 kB -
turbopack-0x..yhs..js gzip N/A 4.16 kB -
turbopack-0y..l8a..js gzip N/A 4.13 kB -
turbopack-13..jmn~.js gzip N/A 4.16 kB -
Total 463 kB 463 kB ✅ -43 B

Server

Middleware
Canary PR Change
middleware-b..fest.js gzip 713 B 711 B
Total 713 B 711 B ✅ -2 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 431 B 430 B
Total 431 B 430 B ✅ -1 B

📦 Webpack

Client

Main Bundles
Canary PR Change
5528-HASH.js gzip 5.54 kB N/A -
6280-HASH.js gzip 60.6 kB N/A -
6335.HASH.js gzip 169 B N/A -
912-HASH.js gzip 4.59 kB N/A -
e8aec2e4-HASH.js gzip 62.7 kB N/A -
framework-HASH.js gzip 59.7 kB 59.7 kB
main-app-HASH.js gzip 255 B 254 B
main-HASH.js gzip 39.3 kB 39.2 kB
webpack-HASH.js gzip 1.68 kB 1.68 kB
262-HASH.js gzip N/A 4.59 kB -
2889.HASH.js gzip N/A 169 B -
5602-HASH.js gzip N/A 5.55 kB -
6948ada0-HASH.js gzip N/A 62.7 kB -
9544-HASH.js gzip N/A 61.3 kB -
Total 235 kB 235 kB ⚠️ +696 B
Polyfills
Canary PR Change
polyfills-HASH.js gzip 39.4 kB 39.4 kB
Total 39.4 kB 39.4 kB
Pages
Canary PR Change
_app-HASH.js gzip 194 B 194 B
_error-HASH.js gzip 183 B 180 B 🟢 3 B (-2%)
css-HASH.js gzip 331 B 330 B
dynamic-HASH.js gzip 1.81 kB 1.81 kB
edge-ssr-HASH.js gzip 256 B 256 B
head-HASH.js gzip 351 B 352 B
hooks-HASH.js gzip 384 B 383 B
image-HASH.js gzip 580 B 581 B
index-HASH.js gzip 260 B 260 B
link-HASH.js gzip 2.51 kB 2.51 kB
routerDirect..HASH.js gzip 320 B 319 B
script-HASH.js gzip 386 B 386 B
withRouter-HASH.js gzip 315 B 315 B
1afbb74e6ecf..834.css gzip 106 B 106 B
Total 7.98 kB 7.98 kB ✅ -1 B

Server

Edge SSR
Canary PR Change
edge-ssr.js gzip 125 kB 125 kB
page.js gzip 270 kB 270 kB
Total 395 kB 395 kB ⚠️ +212 B
Middleware
Canary PR Change
middleware-b..fest.js gzip 617 B 614 B
middleware-r..fest.js gzip 156 B 155 B
middleware.js gzip 43.9 kB 44 kB
edge-runtime..pack.js gzip 842 B 842 B
Total 45.5 kB 45.6 kB ⚠️ +85 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 715 B 718 B
Total 715 B 718 B ⚠️ +3 B
Build Cache
Canary PR Change
0.pack gzip 4.34 MB 4.33 MB 🟢 12.1 kB (0%)
index.pack gzip 110 kB 110 kB
index.pack.old gzip 109 kB 110 kB
Total 4.56 MB 4.55 MB ✅ -11.3 kB

🔄 Shared (bundler-independent)

Runtimes
Canary PR Change
app-page-exp...dev.js gzip 334 kB 334 kB
app-page-exp..prod.js gzip 182 kB 182 kB
app-page-tur...dev.js gzip 334 kB 334 kB
app-page-tur..prod.js gzip 181 kB 181 kB
app-page-tur...dev.js gzip 330 kB 330 kB
app-page-tur..prod.js gzip 179 kB 179 kB
app-page.run...dev.js gzip 331 kB 331 kB
app-page.run..prod.js gzip 180 kB 180 kB
app-route-ex...dev.js gzip 76.2 kB 76.2 kB
app-route-ex..prod.js gzip 51.8 kB 51.8 kB
app-route-tu...dev.js gzip 76.2 kB 76.2 kB
app-route-tu..prod.js gzip 51.9 kB 51.9 kB
app-route-tu...dev.js gzip 75.8 kB 75.8 kB
app-route-tu..prod.js gzip 51.6 kB 51.6 kB
app-route.ru...dev.js gzip 75.8 kB 75.8 kB
app-route.ru..prod.js gzip 51.6 kB 51.6 kB
dist_client_...dev.js gzip 324 B 324 B
dist_client_...dev.js gzip 326 B 326 B
dist_client_...dev.js gzip 318 B 318 B
dist_client_...dev.js gzip 317 B 317 B
pages-api-tu...dev.js gzip 43.4 kB 43.4 kB
pages-api-tu..prod.js gzip 33 kB 33 kB
pages-api.ru...dev.js gzip 43.4 kB 43.4 kB
pages-api.ru..prod.js gzip 33 kB 33 kB
pages-turbo....dev.js gzip 52.8 kB 52.8 kB
pages-turbo...prod.js gzip 38.6 kB 38.6 kB
pages.runtim...dev.js gzip 52.8 kB 52.8 kB
pages.runtim..prod.js gzip 38.6 kB 38.6 kB
server.runti..prod.js gzip 62.5 kB 62.5 kB
Total 2.96 MB 2.96 MB
📎 Tarball URL
https://vercel-packages.vercel.app/next/commits/457fcedc56314f5e973e393f25a9628f9e730b9f/next

@bgw bgw force-pushed the bgw/effect-trait branch from ad63b21 to a574d15 Compare January 29, 2026 00:28
@bgw bgw force-pushed the bgw/effect-trace-raw-vcs branch 2 times, most recently from c11b2a1 to fd04529 Compare January 31, 2026 05:20
@bgw bgw force-pushed the bgw/effect-trait branch from a574d15 to 86cb33f Compare January 31, 2026 05:20
@bgw bgw force-pushed the bgw/effect-trace-raw-vcs branch from fd04529 to ebd1c55 Compare March 19, 2026 00:01
@bgw bgw force-pushed the bgw/effect-trait branch 2 times, most recently from b7bb365 to 0a0ee57 Compare March 24, 2026 06:19
@bgw bgw force-pushed the bgw/effect-trace-raw-vcs branch from ebd1c55 to d6f9660 Compare March 24, 2026 06:19
@bgw bgw force-pushed the bgw/effect-trait branch from 0a0ee57 to 92cf9a9 Compare March 24, 2026 16:40
@bgw bgw force-pushed the bgw/effect-trace-raw-vcs branch from d6f9660 to e1ace25 Compare March 24, 2026 16:40
@bgw bgw changed the base branch from bgw/effect-trait to graphite-base/89133 March 24, 2026 21:34
@bgw bgw changed the base branch from graphite-base/89133 to canary March 24, 2026 21:35
@bgw bgw force-pushed the bgw/effect-trace-raw-vcs branch from e1ace25 to 7ed4ec1 Compare March 24, 2026 21:35
@bgw bgw force-pushed the bgw/effect-trace-raw-vcs branch from 7ed4ec1 to 457fced Compare March 24, 2026 21:35
@bgw bgw merged commit e2af4d8 into canary Mar 24, 2026
163 of 164 checks passed
Copy link
Member Author

bgw commented Mar 24, 2026

Merge activity

  • Mar 24, 10:15 PM UTC: @bgw merged this pull request with Graphite.

@bgw bgw deleted the bgw/effect-trace-raw-vcs branch March 24, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

created-by: Turbopack team PRs by the Turbopack team. Turbopack Related to Turbopack with Next.js.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants