Repository navigation
Conversation
Grimkeh
left a comment
There was a problem hiding this comment.
Independent Linux CPU review
What changed: ArchetypeSwaps sorts/dedupes into a table and uses lower_bound when size ≥ 512; last enabled entry still wins. New swap_table_checks in mods_test.
Checked: diff + expanded mods_test.cpp cases. Looks correct for the large-table path.
No game files. Full mods_test link is Windows-oriented on this host.
|
Tested b5901f8 (already contains main 867d922) under Wine: pass On: Linux, Ubuntu 24.04, cross-built with clang-cl 19.1.1 + xwin SDK (RelWithDebInfo), tests run by
AI-assisted (Claude Code). |
al3xar
left a comment
There was a problem hiding this comment.
Independent Windows verification of b5901f8c9 (AI-assisted).
- Environment: Windows 11 x64, MSVC 19.44.35230.0 (Ninja Release), Windows SDK 10.0.26100.0, CPU-only test, no game files.
- Build & test:
mods_testbuilt cleanly with 0 warnings and passed (mods_test: 65 checks, 0 failures, exit 0). - Code review:
std::stable_sortona.first < b.firstfollowed by in-place compaction preserves last-entry-wins semantics both within a single mod and across enabled mods (<algorithm>already included inruntime/src/mods.h).- Linear scan for
< 512entries andstd::lower_boundwith exact key check for>= 512preserves one-step remapping (no recursive chains/cycles). - Test covers boundary sizes (
0, 1, 8, 511, 512, 513, 1024), duplicate overrides, disabled mods, misses,0/UINT32_MAXboundaries, chains, and cycles.
LGTM.
|
Tested
|
The archetype hook currently scans every swap on each lookup, and loading manifests scans all previous unique hashes for every entry. This change stable-sorts enabled entries once, compacts duplicate hashes with the last entry winning, and uses binary search at 512 unique swaps and above. Smaller tables keep a linear scan. Remapping remains one step; disabled mods and duplicate precedence are unchanged.
Claim: PERF-MOD-SWAP-LOOKUP, posted before implementation: #9065 (comment) . AI-assisted (Codex).
Synthetic CPU measurement on an i7-12700K / Windows 11 Pro N 26200 / MSVC 19.44.35230,
/O2 /EHsc /std:c++20: median of five separate runs per revision, alternating run order, pinned to logical CPU 0. Each case uses 131,072 pregenerated queries repeated four times, shuffled even source hashes and odd destinations, and verifies the result sum. Before is867d922f09b86583859796a174df89555fb32da8; after isb5901f8c9cc2f7028b0f88553489fa25b2c2d07d. The benchmark finished before this PR's translator suite started.At 1,024 and 16,384 swaps, mixed lookups improve about 4.1x and 40.9x respectively. Construction medians are 154.5 → 36.5 microseconds and 33.56 → 1.04 milliseconds; construction is timed once per size per process, with input creation outside the timer. The conservative cutoff avoids the hit-heavy slowdown measured with binary search at 128 entries. Small-table results vary in both directions (including a 64-entry miss slowdown from 19.96 to 23.47 ns and 511-entry misses from 135.44 to 146.80 ns); this does not establish an improvement for small mod sets or game frame rates. Real mod counts and lookup distributions were not measured. Construction temporarily retains all enabled entries and stable-sort scratch space before duplicate compaction.
Validation at
b5901f8c9cc2f7028b0f88553489fa25b2c2d07d:modsandshader_libraryCTests 2/2 pass.mods_testhas 65 checks, 0 failures.447 files, 5957 tests, 2 files failed in 299 s with 20 jobs: test_image_atomics_guard, test_image_store_d16. The failures are the same pre-existingtest_image_atomics_guard(47 subtest failures) andtest_image_store_d16(one assertion) observed on this unchanged translator tree in earlier baseline checks; this is not a fully green suite.python -m compileall -q make_game.py tools tests,python -I make_game.py --help,git diff --check, andscripts/check_no_game_data.pypass.Fresh coordination-board comments and all-state symbol/topic searches found no competing swap-table implementation. Pairwise
git merge-tree --write-treechecks are clean with main and related PRs #6059, #7271, #7006, #8114, #8254, #8348 and #8445. No implementation dependency. The CLI argument work EGEN-GTA6RT-ARCHETYPE-ARG remains separate.No game files used. GPU present: RTX 3070, driver 610.88; GPU and in-game behavior were not exercised. Linux/macOS untested.
Standalone synthetic benchmark and reproduction
Save the following outside the repository as
swap_bench.cpp. From an MSVC developer shell, compile it separately against each checkout'sruntime/srcdirectory:Run each binary five times in alternating order and take the median per CSV row. Columns are unique swaps, mode, construction microseconds, nanoseconds per lookup. The source below is the exact harness used; the compiler input and CPU affinity are identical for both revisions.