#1637
Build the JavaScript engine's C for size
Summary
- Compile the engine's C with
-Osin release builds. At the top of this stack (#1639), a ReleaseSafefxis 209,008 bytes (204 KiB) smaller, and a binary with only the engine is about 181 KiB smaller. - The engine runs a few percent slower. On a workload of 40,000 objects through JSON, filtering, a regex test, and a sort, the best of 42 runs took 168 ms against 162 ms at the default level.
- Keep the C unoptimized with full checks in Debug builds.
Stacked on #1636.
Measurements
ReleaseSafe builds on macOS arm64, in bytes:
| Binary | Default (-O2) | -Os | Saved |
|---|---|---|---|
fx at #1639's head | 12,192,368 | 11,983,360 | 209,008 |
zig build test-js test binary | 1,834,376 | 1,649,464 | 184,912 |
To repeat the fx row, run zig build -Doptimize=ReleaseSafe at #1639's head, then again with -Os removed from the flags in jsEngineModule, and compare zig-out/bin/fx.
For speed, run both builds of the workload in turn rather than one after the other, since single runs on a busy machine vary by more than the difference. The medians of the 42 runs, 186 ms with -Os and 190 ms without, were within that noise.
Activity
2This pull request is a draft
Merging is unavailable until it is marked ready for review.