Skip to content

Commit f3ab1d9

Browse files
committed
cheat sheet: per-file optimization pragmas
inline_depth(1) and optimize("y", off) each unstick a handful of files where /O2's defaults do not match the original; sweep per file rather than guess. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V1TxWi9U7YCQdFQC98RYXy
1 parent 0c67ce0 commit f3ab1d9

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎IMPLEMENTATION_CHEAT_SHEET.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,27 @@ case is a function that returns the ID it was passed: changing `void EntityState
480480
to `int` with a trailing `return entityID;` took SHC_3BB0A8C1_0x004039B0 from 36.4% to 100%. Fix the signature in the
481481
generated header rather than working around the difference.
482482

483+
### Per-file optimization pragmas
484+
485+
`/O2` is a bundle (`/Og /Oi /Ot /Oy /Ob2 /GF /Gy`), and a few translation units in the original were plainly not
486+
built with all of it. Two of its parts are worth testing per file when a function is stuck and the diff shows
487+
structural noise rather than a source bug:
488+
489+
- `#pragma inline_depth(1)` - `/Ob2` inlines things the original did not. `disconnectDPlay` 66.0% -> 87.4% and
490+
`createCompoundAddressBasedOnSelectedProvider` 54.1% -> 61.2%, `checkMultiplayerLaggingPlayers` 90.6% -> 91.0%.
491+
Depth 1 beat depth 0 by about a point on both of the first two; depths 2 and 3 are the same as the default.
492+
- `#pragma optimize("y", off)` - with `/Oy` the optimizer may use `ebp` as a general register and cross-jump
493+
identical epilogues into one. `waitForMultiplayerHost` has two `DAT_HostAnnounced = 1` returns that the original
494+
keeps separate: 87.0% -> 98.9%. Note that putting `/Oy-` on the command line through
495+
`set_source_files_properties` does **not** reproduce this; only the pragma does.
496+
497+
Sweep them rather than guess: patch one file at a time, rebuild, and keep the ones that win. Over the 25
498+
non-matching functions of `GameSynchronyState` only four files wanted either pragma, and
499+
`optimize("s", on)`, `optimize("g", off)`, `optimize("t", off)` and `auto_inline(off)` never won anywhere.
500+
Toggling a file in or out of `cmake/compiler-flags-gl.txt` is worth the same sweep - it found one win
501+
(`receiveAllTransmittedCommands`, +1.3) and showed that the `/GL` entries for `determineGameTicksToPerform` and
502+
`computeLatencyAdjustmentFromMatchTimes` currently measure as no-ops.
503+
483504
### Link-Time Code Generation
484505

485506
A volatile register (usually ECX or EDX) that stays live across a call in the original, without being reloaded, means

0 commit comments

Comments
 (0)