Skip to content

Conversation

@bgw
Copy link
Member

@bgw bgw commented Oct 30, 2025

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

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.

@bgw bgw force-pushed the bgw/rm-extra-glob-string-clones branch from 5d855c0 to da8d4c4 Compare October 30, 2025 22:16
@bgw bgw force-pushed the bgw/bincode-traits branch 2 times, most recently from 999a952 to f7ce13a Compare October 30, 2025 22:57
@bgw bgw force-pushed the bgw/rm-extra-glob-string-clones branch from da8d4c4 to 7f3d072 Compare October 30, 2025 22:57
@bgw bgw force-pushed the bgw/bincode-traits branch from f7ce13a to 77a6a79 Compare November 3, 2025 08:27
@bgw bgw changed the base branch from bgw/rm-extra-glob-string-clones to graphite-base/85580 November 5, 2025 00:07
@bgw bgw force-pushed the graphite-base/85580 branch from 7f3d072 to dc20107 Compare November 5, 2025 00:07
@bgw bgw force-pushed the bgw/bincode-traits branch from 77a6a79 to 295ca2d Compare November 5, 2025 00:07
@bgw bgw changed the base branch from graphite-base/85580 to bgw/update-patricia-tree November 5, 2025 00:07
@bgw bgw force-pushed the bgw/bincode-traits branch from 295ca2d to f3589ab Compare November 5, 2025 01:29
@bgw bgw force-pushed the bgw/update-patricia-tree branch 2 times, most recently from 0928c7e to 52f0b9c Compare November 5, 2025 01:30
@bgw bgw force-pushed the bgw/bincode-traits branch 2 times, most recently from 68e86b2 to 26bb161 Compare November 5, 2025 01:40
@bgw bgw force-pushed the bgw/update-patricia-tree branch from 52f0b9c to 0928c7e Compare November 5, 2025 01:40
@bgw bgw force-pushed the bgw/update-patricia-tree branch 2 times, most recently from 439db5f to ad15366 Compare November 5, 2025 21:29
@bgw bgw force-pushed the bgw/bincode-traits branch from 26bb161 to b6273ac Compare November 5, 2025 21:29
@bgw bgw changed the base branch from bgw/update-patricia-tree to graphite-base/85580 November 6, 2025 05:31
@bgw bgw force-pushed the graphite-base/85580 branch from ad15366 to f7b4a8f Compare November 6, 2025 05:32
@bgw bgw force-pushed the bgw/bincode-traits branch from b6273ac to 369f98d Compare November 6, 2025 05:32
@bgw bgw changed the base branch from bgw/turbo-bincode-helpers to graphite-base/85580 November 29, 2025 01:47
@bgw bgw force-pushed the bgw/bincode-traits branch from 8e994ab to a2afb2d Compare November 29, 2025 01:48
@bgw bgw changed the base branch from graphite-base/85580 to bgw/bincode-restricted-bincode-traits November 29, 2025 01:48
@bgw bgw force-pushed the bgw/bincode-restricted-bincode-traits branch from 117cba5 to c17d228 Compare December 1, 2025 05:16
@bgw bgw force-pushed the bgw/bincode-traits branch from a2afb2d to 06d12f7 Compare December 1, 2025 05:16
@bgw bgw changed the title WIP: Turbopack: Implement bincode Encode/Decode traits on all turbo task values Turbopack: Implement bincode Encode/Decode traits on all turbo task values Dec 2, 2025
@bgw bgw force-pushed the bgw/bincode-traits branch from 06d12f7 to 6198395 Compare December 2, 2025 05:46
@bgw bgw requested a review from a team December 2, 2025 05:49
@bgw bgw marked this pull request as ready for review December 2, 2025 05:49
@bgw bgw requested a review from mischnic December 2, 2025 17:05
@bgw bgw force-pushed the bgw/bincode-restricted-bincode-traits branch from c17d228 to c60ce3d Compare December 2, 2025 19:57
@bgw bgw force-pushed the bgw/bincode-traits branch from 6198395 to 5ccd5fb Compare December 2, 2025 19:57
@bgw bgw changed the title Turbopack: Implement bincode Encode/Decode traits on all turbo task values Turbopack: bincode: Implement bincode Encode/Decode traits on all turbo task values Dec 4, 2025
@bgw bgw force-pushed the bgw/bincode-restricted-bincode-traits branch from c60ce3d to deda71f Compare December 4, 2025 18:56
@graphite-app graphite-app bot changed the base branch from bgw/bincode-restricted-bincode-traits to graphite-base/85580 December 4, 2025 19:41
@bgw bgw force-pushed the graphite-base/85580 branch from deda71f to dfc51d0 Compare December 4, 2025 22:33
@bgw bgw force-pushed the bgw/bincode-traits branch from 5ccd5fb to 97031f9 Compare December 4, 2025 22:33
@bgw bgw changed the base branch from graphite-base/85580 to canary December 4, 2025 22:33
@bgw bgw force-pushed the bgw/bincode-traits branch from 97031f9 to 9b32348 Compare December 4, 2025 23:11
@bgw bgw force-pushed the bgw/bincode-traits branch from 9b32348 to d56832e Compare December 4, 2025 23:57
@bgw bgw merged commit 2931550 into canary Dec 5, 2025
296 of 298 checks passed
Copy link
Member Author

bgw commented Dec 5, 2025

Merge activity

  • Dec 5, 1:47 AM UTC: @bgw merged this pull request with Graphite.

@bgw bgw deleted the bgw/bincode-traits branch December 5, 2025 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Bypass Graphite Optimization Ignore Graphite CI optimizations, run the full CI suite. https://graphite.dev/docs/stacking-and-ci created-by: Turbopack team PRs by the Turbopack team. Font (next/font) Related to Next.js Font Optimization. Turbopack Related to Turbopack with Next.js.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants