mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-26 06:34:20 +08:00
Partitions were filled by a hash of each function's name, so most calls crossed partitions and the thin link imported their small callees into nearly every partition. The emitter now writes a "; scriptc-group" line before the functions of each source file, and the text partitioner places a group's functions together: a group larger than the mean partition, or than 1 MiB, is divided into a power of two of chunks by name, and chunks go, largest first, to the lighter of two partitions chosen by hash. The 1 MiB bound keeps the code a partition optimizes together, and the inlining within it, from growing when a program has fewer partitions. Modules with fewer than 32 partitions, and functions without a group, keep their name-hash placement: with few partitions per core, the balance of the largest partitions decides the build time more than the imports. The placement still depends only on the module text and the partition count.