#1637

Build the JavaScript engine's C for size

Draftfazxeswants to merge intofrom

Summary

  • Compile the engine's C with -Os in release builds. At the top of this stack (#1639), a ReleaseSafe fx is 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:

BinaryDefault (-O2)-OsSaved
fx at #1639's head12,192,36811,983,360209,008
zig build test-js test binary1,834,3761,649,464184,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

2

This pull request is a draft

Merging is unavailable until it is marked ready for review.