perf(codegen): make -Os the default native optimization level - #8457
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Flip
PERRY_LL_SIZE_OPTso unset means enabled: native compilation now defaults to-Os.PERRY_LL_SIZE_OPT=0/off/false/norestores-O3.#8418 added the knob opt-in "while corpus calibration continues". This is that calibration.
Why:
-Oscosts no measurable runtimeMeasured on the quiet M1 mini under the sweep's bench lock — interleaved, output-checked,
verdict
CLEAN, load 1.51 -> 1.72:Nothing disjoint; everything within 0.8%.
I first measured this on a loaded dev box and got swings from -26% to +21% with the sign
flipping between best and median. That was pure contention — the same failure mode that made
#8412's "0.81x Node" claim not survive scrutiny. The mini is the instrument for this.
So the real trade is compile time against shipped binary size, with runtime unaffected:
+21.3% module codegen on a 4,743-module build, for -346.7 MiB beyond #8418's structural
wins. Smaller artifacts for every user are worth a developer-side build cost.
Scope
On small programs
-Oschanges nothing measurable — hello-world and the corpus binariescome out the same size either way. The win is specific to dense generated bundles. A
size-driven policy that engages only where oversized units exist would avoid paying compile
time on trivial builds; worth considering as a follow-up, but it does not block making the
better default the default.
Tests
Three existing tests encoded the old default and are updated rather than deleted:
compile_plan_defaults_to_o3->compile_plan_defaults_to_oscompile_plan_records_effective_target_and_native_tuningnow expects-Ossize_optimization_flag_is_explicit_and_truthy->size_optimization_is_on_unless_explicitly_disabled,pinning that unset/empty/unknown all enable and only an explicit negative disables
Validation
perry-codegen --lib— 1107 passedscripts/run_lint_gates.sh— all 50 gates-Osas the defaultNote for anyone A/B-ing this: perry builds are not byte-deterministic (the same config
twice produces different bytes), so binary comparison is not a valid check for whether the
flag took effect.
compile_plan_defaults_to_osis the direct proof.