Repository navigation
Conversation
…index once (ASSET-628) TtpfReader.CreateDds re-read and re-parsed the whole texture pool index for every texture, so rpf9dump ttpf did the index work once per texture instead of once per pool. Upstream 3196f23, the direct child of the old pin e293917, caches the parsed index keyed by path, length and write time. Synthetic 16,000-texture pool: 44.0 s -> 8.4 s, byte-identical DDS output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
One difference from the upstream merge of PR #14: I confirmed the cancellation difference on Windows with a synthetic pool. After warming the cache, The two reported exit-code test failures are covered by #6999. The tests blocked the old fixed temporary filename; with that test fix they pass with both decoder versions I compared in #4687. No game data. AI-assisted (Codex). Re-tested the updated pin in AWC Opus check on the same pin. I ran |
3196f23 is the feature-side parent of upstream's merge of the index cache. The merge commit adds a cancellation check before the cache lookup and re-checks the pool's length and write time after parsing, so pin that. It also brings in the rest of that upstream merge: one TtpfReader tile pattern row, 48 kHz Opus durations for 32 kHz AWC streams, and the PSIN metadata scanner.
|
Thanks, you're right. I moved the pin to the merge commit |
tupacfan04
left a comment
There was a problem hiding this comment.
The cache removes the per-texture re-parse, but “reads the pool index once” is not true.
tools/rpf9dump/Program.cs:76callsTtpfReader.Inspect, which still callsReadIndexfresh (Core/TtpfReader.cs:86) and does not populate the cache.Program.cs:94then callsCreateDds→ReadIndexCached;lastIndexis null, so the firstCreateDdsparses the index again. That is at least two parses per pool.ReadIndexCachedis not single-flight: several coldCreateDdscalls in theParallel.Forcan all seelastIndex == nulland parse concurrently, up toMaxDegreeOfParallelism.
Fix: have Inspect use ReadIndexCached, pass the inspected index into CreateDds, or add a single-flight cache; otherwise the title/body should say “removes per-texture re-parsing,” not “once.”
Scope risk: the pin 7793a954 is 9 commits / 13 files from the old e2939175, not a single cache fix. It changes a 64 KiB 4-byte-element tile pattern row (-3,3 → 3,-3), which changes DDS output for that profile, and brings AWC Opus/PSIN/archive changes. The synthetic pools do not exercise the changed tile row; tests/test_ttpf_export_resume.py checks output/manifest only, so the old per-texture reads would also pass. Either pin 3196f23 for the cache-only change (pre-cancellation/recheck) or scope this explicitly as an upstream bump and add a tile-row and cancellation/recheck test.
Correct: 7793a954 is the right merge for the cancellation/post-parse recheck guard; the cache is safe to share because Index is immutable; the tested pools are byte-identical; the quadratic per-texture cost is fixed. Synthetic/code-read only; no game files. AI-assisted (OpenCode).
|
Tested 81be629 on Linux, Python 3.12.16, .NET SDK 10.0.404: pass
|
…uses (ASSET-628) The upstream bump to 7793a954 changes one row of TtpfReader's 64 KiB tile pattern table, so DDS output changes for 4-byte elements. Export a 128x128 RGBA8 SW_64KB_D texture through rpf9dump and check that tile offsets 64 and 128 land at pixels (4, 0) and (0, 4), the order ttpf_mips.PATTERNS_64K[2] already tests. Fails at e293917 and 3196f23, passes at 7793a954.
|
@tupacfan04 Thanks, both fair.
@senyurah thanks for re-testing the new pin and the tile order. Windows 11, .NET 10, synthetic data only. AI-assisted. |
KotikVanil
left a comment
There was a problem hiding this comment.
Tested a28a470 / Core pin 7793a954 on Windows x64 with .NET SDK 10.0.403. Release build passed with zero warnings, and the 5 TTPF export/resume tests (including the 4 BPP layout regression) and 93 mip tests passed.
I also tested the library cache in one process with two synthetic pools of the same size. After reading a 16×16 texture, I replaced the pool at the same path with an 8×8 one and restored the original last-write time. CreateDds still returned a 16×16 header and a fresh Inspect saw 8×8. Changing just the timestamp made CreateDds return 8×8 again.
This is a limitation for a long-lived Core caller after external replacement preserving metadata. It does not block the pin for the normal rpf9dump CLI, which starts a fresh process and expects a stable pool for the duration of an export. For broader reuse, an explicit pool session with a held read handle would keep the parsed index and the data on the same snapshot.
AI-assisted (Codex), synthetic fixtures only, no GPU.
|
Thanks @YordiLorenzo and @KotikVanil for testing this on Linux and Windows! @KotikVanil good catch on the same-size swap with the old timestamp put back. You're right, the cache only looks at path, size and write time, so something that keeps Core loaded for a long time could get a stale index. rpf9dump starts a fresh process for every export, so it doesn't run into it here. A proper fix like the pool session you described would need to go into rpf9-explorer itself, so I'm leaving it out of this pin bump. |
|
Security review (static): submodule bump checked, nothing malicious found. I compared the old pin ( Findings come from a static, AI-assisted review of this PR's diff (nothing was executed); they were read by the account owner. This comment text is AI-generated. |
Summary
ASSET-628 (claim, found by
MaxtorCoder).TtpfReader.CreateDdsstarted withReadIndex, sorpf9dump ttpfre-read and re-parsed a texture pool's whole index once per texture. Upstream fixed this in breadbbbb/rpf9-explorer@3196f23 (EdouardSence) and merged it as 7793a954:CreateDdsreuses the parsed index, cached by path, length and write time. The merge adds a cancellation check before the cache lookup and re-checks the pool after parsing.This PR moves the
third_party/rpf9-explorergitlinke293917→7793a954(the merge, not its feature-side parent, per review).The index is still parsed more than once per pool, just not once per texture:
Inspectparses it, then the firstCreateDdsparses it again, and parallel calls that start before the cache is set can each parse it. That is a small constant, not the per-texture cost.Also included from that upstream merge
TtpfReader: one row of the 64 KiB tilePatternstable changes (-3,3→3,-3), which changes DDS output for 4-byte-element SW_64KB_D textures. It now matchestools/ttpf_mips.py'sPATTERNS_64K[2].AwcRecovery.DecodedSampleRate,OpusPreview.cpp).Rpf9PsinRecovery) for the desktop app's full scan, with the CHKS checksum checked.New test
tests/test_ttpf_export_resume.py::test_rbplus_64k_4bpp_tile_order_matches_ttpf_mipsexports a 128×128 RGBA8 SW_64KB_D texture throughrpf9dumpand checks that tile offsets 64 and 128 land at pixels (4, 0) and (0, 4), the orderttpf_mipsalready tests in Python. It fails ate293917and3196f23and passes at7793a954.Tested
Windows 11, .NET SDK 10.0.301, Python 3.13.0. Synthetic pools only, no game data.
e293917(old pin)7793a954With
RPF9DUMP_DLLset to the7793a954build:test_ttpf_export_resume5 OK (including the new test),test_ttpf_mipsOK,test_ttpf_assetsOK (2 skipped). The twotest_rpf9dump_exit_codesfailures seen on Windows also fail at the old pin and are covered by #6999.Not tested: the cancellation and post-parse recheck guards have no test here, since Leonida has no C# test project and the CLI passes no cancellation token (checked by hand in review). Not timed on a retail pool; upstream's commit reports 81 s → 5 s on an 11,241-texture pool.
AI-assisted: yes