Commit 2931550
authored
Turbopack: bincode: Implement bincode Encode/Decode traits on all turbo task values (#85580)
It looks like bincode should reduce the filesystem cache size by ~10% versus pot, because its not a self-describing format. This attempts to add the `bincode::Encode`/`bincode::Decode` traits everywhere, so that we can use those instead of serde.
## Why not use bincode's serde compatibility feature?
- Unfortunately, serde has some bugs/incompatibilities/footguns with non-self-describing formats. `bincode`'s traits avoid this by not exposing features that would be incompatible with a self-describing format. https://docs.rs/bincode/latest/bincode/serde/index.html#known-issues
- `bincode::Encode`/`Decode` are much simpler traits than serde's equivalents, so we'll probably get some rustc build performance and turbopack binary size benefits from using the bincode versions. In cases where we do have to implement these traits by hand, it's much easier than implementing the serde equivalents.
- I'd like to kill `erased-serde` anyways because we're probably paying some performance cost from the large amounts of dynamic dispatch it performs, and we're not getting any benefits from it if we only ever serialize to a single format.
## Forks of Upstream Crates
- I've forked `bincode` here: https://github.com/bgw/bincode/commits/bgw/patches/
- I submitted a patch via email to the maintainer via sourcehut
- Upstream: https://git.sr.ht/~stygianentity/bincode
- Fork: https://git.sr.ht/~bgw/bincode
- This adds a few extra derive features and fixes type bounds on `PhantomData`.
- The type bounds on `PhantomData` aren't very important, and we could work around it in our code.
- We could just fork the derive crate if upstream doesn't want to accept the patches.
- And `virtue` here: bgw/virtue@e386f35
- I've submitted a PR to `virtue` here: bincode-org/virtue#94
- This fixes a bug in the parsing of const enums and generics with defaults.
- We don't hit this very often as most of our types are not generics, so we could work around it in our code if upstream doesn't want to accept the patch.
## Other Notes
- Depends on a patched version of the `bincode` and `virtue` crates to fix a few bugs and add a few new features. I'll work on upstreaming these changes.
- This implements `BorrowDecode` everywhere because the `bincode::Decode` derive macro requires it. I plan to add an attribute in my bincode fork to allow disabling this, and then we can get rid of all of the `BorrowDecode` impls. We don't want/need `BorrowDecode` for turbo task values because everything needs to be owned anyways.1 parent 5118c41 commit 2931550
File tree
181 files changed
+2636
-476
lines changed- crates
- napi
- src/next_api
- next-api
- src
- next-core
- src
- next_app
- next_client_reference
- next_font
- google
- local
- next_image
- next_manifests
- next_root_params
- next_server
- turbopack/crates
- turbo-esregex
- src
- turbo-rcstr
- src
- turbo-tasks-auto-hash-map
- src
- turbo-tasks-backend
- tests
- turbo-tasks-bytes
- src
- turbo-tasks-env
- src
- turbo-tasks-fs
- src
- turbo-tasks-macros/src
- turbo-tasks
- src
- vc
- turbopack-analyze
- src
- turbopack-browser
- src
- ecmascript
- list
- turbopack-core
- src
- chunk
- chunking
- diagnostics
- introspect
- issue
- module_graph
- reference
- resolve
- source_map
- turbopack-css
- src
- turbopack-dev-server
- src
- source
- turbopack-ecmascript-plugins
- src/transform
- turbopack-ecmascript
- src
- analyzer
- chunk
- references
- esm
- side_effect_optimization
- locals
- webpack
- turbopack-image
- src/process
- turbopack-nodejs
- src
- turbopack-node
- src
- source_map
- transforms
- turbopack-test-utils
- src
- turbopack-tests
- tests
- turbopack-wasm
- src
- turbopack
- src/module_options
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
181 files changed
+2636
-476
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 | |
|---|---|---|---|
| |||
451 | 451 | | |
452 | 452 | | |
453 | 453 | | |
454 | | - | |
| 454 | + | |
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
| 459 | + | |
459 | 460 | | |
460 | 461 | | |
461 | 462 | | |
| |||
481 | 482 | | |
482 | 483 | | |
483 | 484 | | |
| 485 | + | |
484 | 486 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
1528 | 1529 | | |
1529 | 1530 | | |
1530 | 1531 | | |
| 1532 | + | |
| 1533 | + | |
1531 | 1534 | | |
1532 | 1535 | | |
1533 | 1536 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
1068 | 1069 | | |
1069 | 1070 | | |
1070 | 1071 | | |
1071 | | - | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
1072 | 1085 | | |
1073 | 1086 | | |
1074 | 1087 | | |
1075 | 1088 | | |
1076 | 1089 | | |
1077 | | - | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
1078 | 1093 | | |
1079 | 1094 | | |
1080 | 1095 | | |
| |||
0 commit comments