Record the runtime headers a PGO profile was trained with and warn when they change

The floating-point helpers in simd.h and simd_fp.h inline into every lifted function before llvm-profdata matches
the profile, so the fpcheap change left pgo-v143 with a fifth of its weight while recomp/ stayed the same and
make_release saw nothing. pgo.py merge now reads the instrumented build's Ninja deps log and stores the digests of
the runtime/ headers the generated objects include (cpu.h, simd.h, simd_fp.h); make_release warns when one differs
or a record has none. docs/building.md says to retrain after a change to those headers, and build_game.py names the
libiconv-2.dll that MSYS2's SDL3.dll needs in deps-mingw/bin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-11-09 18:50:36 +03:00
1 parent bdcfb42c07
commit 2d2c6782af
4 files changed
+85 -16

No files matched your search

+10 -5
View File
@@ -165,9 +165,12 @@ with it too: hot paths laid out straight, hot calls inlined, code that never ran
bench ran 12-15% faster per frame and a fight outside the training about 6%. The installer builds with
`data/pgo-<ver>.profdata` of the release when the update has one, else at -O1.
A profile only fits the generated C it was trained on: functions are matched by name and control-flow hash, so a
function whose C changes loses its counts without a warning. Retrain after a lifter or generator change, from a clean
`recomp/`. The instrumented build needs llvm-mingw, as MSYS2's clang has no profile runtime:
A profile only fits the code it was trained on: functions are matched by name and control-flow hash, so a function
whose code changes loses its counts without a warning. That code is the generated C plus the runtime headers it
includes (`cpu.h`, `simd.h`, `simd_fp.h`), whose inline helpers become part of every lifted function: a change to the
floating-point helpers once left a profile with a fifth of its weight and 2% of its gain. Retrain after a lifter or
generator change or a change to those headers, from a clean `recomp/`. The instrumented build needs llvm-mingw, as
MSYS2's clang has no profile runtime:
```powershell
$llvm = "toolchain\llvm-mingw-<date>\llvm-mingw-<date>-ucrt-x86_64"
@@ -182,8 +185,10 @@ Scripted runs from saves (`tools/run_game.py`) add to the same file. Then:
.venv\Scripts\python tools\pgo.py merge build\v143-pgogen --version v143
```
writes `build\pgo\pgo-v143.profdata` and its record (`.json`: the `recomp/` tree it fits). `make_release.py` ships every
profile of `build\pgo` in `data\` and warns when a record names another `recomp/` tree than the one released.
writes `build\pgo\pgo-v143.profdata` and its record (`.json`: the `recomp/` tree it fits and the digests of the runtime
headers the generated C included, read from the build's Ninja deps log). Merge from the checkout the instrumented build
was made in. `make_release.py` ships every profile of `build\pgo` in `data\` and warns when a record names another
`recomp/` tree than the one released or a header differs.
## Linux (in progress)