Commit 85c3f2e
authored
Turbopack: bincode: Migrate TaskInput serialization to bincode (#86631)
#86338 switches cell storage to use bincode, but it uses a compatibility shim for storing `TaskInput`s using `serde` + `pot`. This PR completes the migration by switching `TaskInput` to use `bincode` as well.
## Benchmark Summary
`next build` is consistently faster across a variety of repositories when persistent caching is enabled, and the resulting cache size is consistently smaller.

`cargo build` runs only slightly faster, but there's potential for improving this further by removing unused `serde` macro derives.
## Benchmarking Notes
Performance measurements (aside from cargo build) are taken using `next build`. This should have proportional benefits for `next dev` too, but `next build` is more reproducible and easier to measure. `canary` refers to `a8f7b5467485647def4c0f4479a0a83bc4a3673a`.
These numbers are taken with persistent caching enabled with an empty cache, so it's the worst-case scenario for the serialization codepath. We don't care nearly as much about the performance of deserialization because it's less common.
## `cargo build -p next-swc-napi`
This makes builds _slightly_ faster. This branch doesn't clean up the serde derives yet, so there's a bunch of unused macro expansion here, so I think this number is actually pretty good.
```
~/next.js $ hyperfine -w 1 -r 5 -p 'git co a8f7b54 && cargo clean' -p 'git co bgw/bincode-task-inputs && cargo clean' 'cargo build -p next-swc-napi' 'cargo build -p next-swc-napi'
Benchmark 1: cargo build -p next-swc-napi
Time (mean ± σ): 237.476 s ± 1.420 s [User: 2001.820 s, System: 84.957 s]
Range (min … max): 235.294 s … 238.862 s 5 runs
Benchmark 2: cargo build -p next-swc-napi
Time (mean ± σ): 232.366 s ± 1.549 s [User: 1945.355 s, System: 83.940 s]
Range (min … max): 230.550 s … 234.485 s 5 runs
Summary
cargo build -p next-swc-napi ran
1.02 ± 0.01 times faster than cargo build -p next-swc-napi
```
## next-site
Using `~/front/apps/next-site` on macos with a M2 Pro. Nothing else was running on the machine.
```
hyperfine -p 'rm -rf .next' -w 2 -r 20 'TURBOPACK_PERSISTENT_CACHE=1 TURBO_ENGINE_IGNORE_DIRTY=1 pnpm next build --turbopack --experimental-build-mode=compile'
du -sh .next/cache/turbopack/
du -s .next/cache/turbopack/
```
#### Canary
```
Benchmark 1: TURBOPACK_PERSISTENT_CACHE=1 TURBO_ENGINE_IGNORE_DIRTY=1 pnpm next build --turbopack --experimental-build-mode=compile
Time (mean ± σ): 14.999 s ± 0.258 s [User: 84.137 s, System: 8.683 s]
Range (min … max): 14.400 s … 15.509 s 20 runs
```
```
855M .next/cache/turbopack/
1751640 .next/cache/turbopack/ (Note: macos measures size in 512B blocks)
```
#### This Branch
```
Benchmark 1: TURBOPACK_PERSISTENT_CACHE=1 TURBO_ENGINE_IGNORE_DIRTY=1 pnpm next build --turbopack --experimental-build-mode=compile
Time (mean ± σ): 14.106 s ± 0.255 s [User: 79.976 s, System: 8.421 s]
Range (min … max): 13.829 s … 14.939 s 20 runs
```
```
767M .next/cache/turbopack/
1571072 .next/cache/turbopack/ (Note: macos measures size in 512B blocks)
```
## vercel-site
Using `~/front/apps/vercel-site` on macos with a M2 Pro. Nothing else was running on the machine.
```
hyperfine -p 'rm -rf .next' -w 2 -r 20 'TURBOPACK_PERSISTENT_CACHE=1 TURBO_ENGINE_IGNORE_DIRTY=1 pnpm next build --turbopack --experimental-build-mode=compile'
du -sh .next/cache/turbopack/
du -s .next/cache/turbopack/
```
#### Canary
```
Benchmark 1: TURBOPACK_PERSISTENT_CACHE=1 TURBO_ENGINE_IGNORE_DIRTY=1 pnpm next build --turbopack --experimental-build-mode=compile
Time (mean ± σ): 93.274 s ± 1.630 s [User: 671.120 s, System: 57.888 s]
Range (min … max): 91.111 s … 96.881 s 10 runs
```
```
4.3G .next/cache/turbopack/
9002568 .next/cache/turbopack/ (Note: macos measures size in 512B blocks)
```
#### This Branch
```
Benchmark 1: TURBOPACK_PERSISTENT_CACHE=1 TURBO_ENGINE_IGNORE_DIRTY=1 pnpm next build --turbopack --experimental-build-mode=compile
Time (mean ± σ): 88.694 s ± 0.963 s [User: 633.801 s, System: 54.576 s]
Range (min … max): 87.357 s … 90.037 s 10 runs
```
```
3.7G .next/cache/turbopack/
7788472 .next/cache/turbopack/ (Note: macos measures size in 512B blocks)
```
## shadcn/ui
Using a low-noise Linux machine: https://github.com/bgw/benchmark-scripts/
```
diff --git a/apps/v4/next.config.mjs b/apps/v4/next.config.mjs
index 7fa0f012..d1137d01 100644
--- a/apps/v4/next.config.mjs
+++ b/apps/v4/next.config.mjs
@@ -27,6 +27,7 @@ const nextConfig = {
},
experimental: {
turbopackFileSystemCacheForDev: true,
+ turbopackFileSystemCacheForBuild: true,
},
redirects() {
return [
```
```
cd ~/shadcn-ui/apps/v4
hyperfine -p 'rm -rf .next' -w 2 'pnpm next build --turbopack --experimental-build-mode=compile'
du -sh .next/cache/turbopack/
du -s .next/cache/turbopack/
```
#### Canary
```
Benchmark 1: pnpm next build --turbopack --experimental-build-mode=compile
Time (mean ± σ): 62.772 s ± 0.939 s [User: 163.153 s, System: 11.170 s]
Range (min … max): 60.739 s … 64.220 s 10 runs
```
```
596M .next/cache/turbopack/
609636 .next/cache/turbopack/ (Note: Linux measures size in 1024B blocks)
```
#### This Branch
```
Benchmark 1: pnpm next build --turbopack --experimental-build-mode=compile
Time (mean ± σ): 59.017 s ± 1.014 s [User: 151.359 s, System: 9.978 s]
Range (min … max): 57.124 s … 60.343 s 10 runs
```
```
491M .next/cache/turbopack/
502240 .next/cache/turbopack/ (Note: Linux measures size in 1024B blocks)
```1 parent 6169e78 commit 85c3f2e
File tree
36 files changed
+474
-509
lines changed- crates
- next-api/src
- next-core/src
- next_client
- next_edge
- next_root_params
- next_server
- turbopack/crates
- turbo-bincode/src
- turbo-tasks-backend
- fuzz
- src
- src
- tests
- turbo-tasks-macros-tests
- tests
- turbo-tasks
- src
- task
- turbopack-cli
- src
- turbopack-core/src/module_graph
- turbopack-dev-server/src/source
- turbopack-ecmascript/src/references
- turbopack-node/src
- transforms
36 files changed
+474
-509
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| 126 | + | |
| 127 | + | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
612 | 612 | | |
613 | 613 | | |
614 | 614 | | |
615 | | - | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
616 | 627 | | |
617 | 628 | | |
618 | 629 | | |
| |||
621 | 632 | | |
622 | 633 | | |
623 | 634 | | |
624 | | - | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
625 | 647 | | |
626 | 648 | | |
627 | 649 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | 212 | | |
217 | 213 | | |
218 | 214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | | - | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
| |||
405 | 408 | | |
406 | 409 | | |
407 | 410 | | |
408 | | - | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
409 | 424 | | |
410 | 425 | | |
411 | 426 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
196 | 197 | | |
197 | 198 | | |
198 | 199 | | |
199 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
200 | 213 | | |
201 | 214 | | |
202 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
49 | | - | |
| 53 | + | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
| |||
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
80 | | - | |
| 84 | + | |
81 | 85 | | |
82 | 86 | | |
83 | 87 | | |
84 | 88 | | |
85 | | - | |
| 89 | + | |
86 | 90 | | |
87 | 91 | | |
88 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | 42 | | |
46 | 43 | | |
47 | 44 | | |
48 | 45 | | |
49 | 46 | | |
50 | 47 | | |
51 | 48 | | |
52 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
981 | 981 | | |
982 | 982 | | |
983 | 983 | | |
984 | | - | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
985 | 997 | | |
986 | 998 | | |
987 | 999 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
63 | 74 | | |
64 | 75 | | |
65 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
0 commit comments