Skip to content

heap_index_census: count verified paths across embedded data - #6072

Open
kacper-serewis wants to merge 2 commits into
ItsNotRexed:mainfrom
kacper-serewis:census-reachable-7101742835
Open

kacper-serewis wants to merge 2 commits into
ItsNotRexed:mainfrom
kacper-serewis:census-reachable-7101742835

Conversation

@kacper-serewis

@kacper-serewis kacper-serewis commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Coordination item 7101742835, D3D-329 follow-up.

Depends on: #5926

Use LLVM diagnostic columns to locate missing dwords, reconcile the printed instruction widths with the declared native code range, then use the translator's CFG traversal and native encoding checks. Feed the verified reachable instructions to the existing load-role and sampler-word analysis. Count an explicit refusal for ambiguous boundaries, encodings, or transfers.

Full private CPU cache comparison across all 26,503 listings in disjoint batches. The #5926 baseline skipped 1,473 for embedded data. This change admits 1,466 of them and refuses seven for uncertain control flow. Only aggregate counts are published.

Sampling instruction classification Before After
Complete four-word load 121,899 188,732
Partial or mixed 0 0
Non-load 99,022 145,909
Unknown 26,053 31,744
Total 246,974 366,385

Each sampler word position has 188,732 direct load tags after the change (121,899 before).

Verification on Windows. All 21 heap census tests and 37 shader IR tests passed. The synthetic census tests cover a branch over data, a reachable unknown word, an indirect transfer, an unresolved diagnostic column and an encoding mismatch. Python compileall, isolated build-script help, three text line-ending tests, changed-file game-data guard and whitespace checks passed. The translator semantic suite passed (6,150 tests, four skips, one expected failure). GPU and driver inapplicable (CPU only).

AI-assisted with Codex.

@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

The new embedded_code reads the whole FSSM file to verify a bounded code range. I kept the 48-byte code range fixed and changed only the length after it. An extra 8 MiB raised peak Python allocations from 135,994 to 8,523,910 bytes. Every run counted one complete sampler and skipped zero listings.

To repeat on 60d4e194, run this script from the checkout root with py -3.14 -I:

import sys, tracemalloc
from pathlib import Path
sys.path.insert(0, str(Path("tests").resolve()))
import test_heap_index_census as t

case = t.HeapIndexCensus()
case.setUp()
try:
    case.embedded_listing("s_branch 1", "010082bf")
    p = Path(case.work.root, "fssm", "ps_embedded.fssm")
    original = p.stat().st_size
    for extra in (0, 1 << 20, 8 << 20):
        with p.open("r+b") as f:
            f.truncate(original + extra)
        tracemalloc.start()
        report = t.hic.census(case.work.disasm)
        peak = tracemalloc.get_traced_memory()[1]
        tracemalloc.stop()
        print(extra, peak, report["groups"]["ps sfi0=smp"]["sampler_load_provenance"])
finally:
    case.tearDown()

Please validate the declared range against the size of the open file, seek to the start, and read only the range. Subtract the range start when indexing the resulting buffer.

All 21 heap census tests and 37 shader IR tests pass on Windows 11 with CPython 3.14.7. As a control, the branch-over-data test fails with the parent census implementation at 84956b70. It skips the listing as embedded data.

AI-assisted.

@Atomic258

Copy link
Copy Markdown
Contributor

Tested 60d4e194 on Windows Server 2022, CPython 3.13.12: pass

  • python -I tests/test_heap_index_census.py -> OK

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

@rideinstead

Copy link
Copy Markdown

✅ Automated security review: CLEAN (commit 60d4e194)

  • No findings.

Scope: static analysis of added diff lines only; no code was executed. Please review findings manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants