mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-30 07:14:39 +08:00
A warm rebuild ran about 3.5 MB of the native compiler's code, but the code was spread over its 69 MB text, so 64 KB fault-around mapped about 20 MB of it. The emitter can now take a function layout: a list of functions in tiers. It writes the listed definitions, generated helpers included, first and by tier, each in a `layout-<tier>` partition group. The LLVM helper compiles each partition's definitions in text order, so the listed ones come first in their partitions, and a helper that places functions by group keeps a tier's definitions in the same partitions. The rest keep their order and their source-file groups. - compile() takes a `functionLayout` file (`<tier> <symbol>` lines, gzip-compressed when the name ends in .gz). Keys leave out module numbers. - build-native-cli.mts uses the committed packages/compiler/native/cli.layout.gz, or the file SCRIPTC_NATIVE_LAYOUT names; an empty value and instrumented builds use none. - scripts/refresh-cli-layout.mjs builds an instrumented compiler, builds the runtime workloads and a corpus slice cold and then unchanged, and reads the functions each run executed from the raw profiles. Tier 1 is `--version` and rebuilds that hit both caches; tier 2 is the other builds. - The release workflow's cli-profile job also collects a layout on the release commit, and the CLI builds use it. Names of closures and generated helpers change with nearby edits, so a committed layout matches fewer functions as main moves on. - Forked lowering and emission workers reset the profile counters after fork and write their profile before _exit, so instrumented builds also count the work done in workers. This applies to refresh-cli-profile.mjs too. Executables the compiler produces are unchanged.