next.js
2a9e8426 - [turbopack] RFC: Serialize turbopack objects as u16s instead of fully qualified symbol names (#83193)

Commit
122 days ago
[turbopack] RFC: Serialize turbopack objects as u16s instead of fully qualified symbol names (#83193) Change the serialization strategy for `ValueTypeId`, `TraitTypeId` and `NativeFunction` to use `u16` values instead of the `global_name` (a fully qualified name of the object). For all these objects the value is the index+1 of the corresponding object in the set of all objects sorted by name. This is a deterministic ordering which should ensure we can deserialize them with the same version of turbopack. Potential concerns with this approach: * debuggability in the Persistent Cache (is this even a thing?) * stability of ids across architectures * if different architectures enable/disable turbotasks then ids will change and make the PC database non-portable. Still this should speed up serialization/deserialization by making everything smaller and faster to encode/decode On an optimized build with a fresh `.next` directory, i measured the size of the `.cache/turbopack/vxxxx` directory `benches/module-cost`: change: 2.38Gb (-22%), wrote in 9.5s, compacted in 5.4s head: 3.06Gb bytes, wrote in 10.3s, compacted in 7.6s `vercel-site` change: 4.8Gb(-12%), wrote in 46ss, compacted in 6.2s head: 5.5Gb, wrote in 48s, compacted in 7.6s So a non-trivial size reduction as expected. This should also speed up encoding/decoding but i didnt attempt to directly measure that.
Author
Parents
Loading