Repository navigation
shader: invalidate watch manifests when sidecar content changes with an older mtime - #3138
Conversation
pigalot
left a comment
There was a problem hiding this comment.
I reviewed 4a7e2542 merged over current codex/native-shader-modules a48d39dc, the PR's base. The merge is clean and git diff --cached --check is clean. #3137 fixes the same issue (#3133) a different way, so I ran each PR's new regressions against the other's build (below).
What I traced.
- Shared parsing:
read_pixel_inputsis a straight extraction of the.psin/.ps57inblock fromread_graphics_request, so the watcher and the request loader now apply the same parse and conflict rules. - What the watcher compares: it compares the canonical description with
<key>.psdep, and both compile paths write.psdepfrom the sameinput.pixel_input_description. So the comparison is against what the manifest was actually compiled from, not against the sidecar bytes as they are on disk at publish time. - The 256-byte cap: a
.psindescription ispsin1 <key> ena= addr=text (parse_pixel_inputscaps the source at 128 bytes), and a.ps57indescription is 12 bytes, so the cap can't refuse a real.psdep. - RTV variants: the watcher reads the base's sidecars through
graphics_psin_pathandreplace_extension(L".a"), so a variant checks its base's.psin/.ps57in.
What I ran. I built compile_dxil native_compute_pack_check native_frozen_request_check native_pixel_ir_dump native_compute_ir_dump in dev and release, then ran
ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(native_compile_dxil_watch|native_startup_request_cache_controls|native_rtv_variant_controls|native_direct_container|native_frozen_request)$'5/5 pass in both presets.
Cross-check with #3137.
- #3137's regressions on this build: I ran #3137's
tests/native_startup_request_cache_check.pyagainst this build, with only its.psinh-file existence assert removed.native_startup_request_cache_controlspasses, so this PR also covers #3137's four cases. - This PR's regressions on #3137's build: run the other way, this PR's
native_compile_dxil_watch_check.pyfails on #3137. The RTV variant keeps its stale manifest when the base gains an older-mtime.ps57in.
Mutants in tools/startup/compile_dxil.cpp. For each, I rebuilt compile_dxil in dev and ran the watch, cache and RTV tests:
| Mutant | Result |
|---|---|
sidecar_changed = current_dep != published_dep; → false |
killed (1 of 3 fails) |
invalid or conflicting sidecar (catch) → sidecar_changed = false |
killed |
unreadable or empty .psdep branch → sidecar_changed = false |
survives |
Restored and rebuilt afterwards; git diff --quiet is clean.
Non-blocking.
- The unreadable-
.psdepbranch isn't pinned. A 0-byte<key>.psdepnext to a published manifest with a valid.psinwould pin it. Today that should withdraw the manifest, and the mutant serves it. - The batch path can leave a stale
.psdep. It writes.psdeponly when the description is non-empty and never removes an old one; the watch path does remove it. If the sidecars disappear between two batch runs, the next watch poll sees"" != published_depand retranslates once. That converges, but removing it in the batch path as well would avoid the extra compile.
Verdict: approve on 4a7e2542. Of the two fixes for #3133, this is the one I'd take. It needs no new cache file, it compares with what the manifest was compiled from, and it covers RTV variants. This targets codex/native-shader-modules, so I'm leaving the merge to the branch owner.
Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10. These are CPU-only checks.
CI: none on this PR (the workflow runs only for main and cpp-migration).
This reply was AI-assisted.
R0Y00
left a comment
There was a problem hiding this comment.
Independently reviewed 4a7e2542 on the exact a48d39dc compiler stack. The watcher resolves an RTV request to the base sidecar and compares canonical parsed content to .psdep, which was produced from the same input as the published stages. That avoids both a second digest file and a fresh read at publish time. The stale-manifest controls cover the base and its RTV variant.
Built compile_dxil native_compute_pack_check native_frozen_request_check native_pixel_ir_dump in dev and release. ctest --test-dir <build> --no-tests=error -j 1 -V -R '^(native_compile_dxil_watch|native_startup_request_cache_controls|native_rtv_variant_controls|native_frozen_request)$' passed 4/4 in both builds, zero skips. The preserved-mtime conflicts withdraw both manifests, unchanged sidecars remain cache hits and the regular watch retry/skip controls pass. Windows 26200.9974, SDK/DXC 10.0.26100.0. Please coordinate this with #3137 and carry a single watcher fix into the #3091 compiler integration, then repeat on the final main base.
|
Agree with both APPROVED reviews: extracting |
Extract read_pixel_input_description() so watch/request paths share exact .psin/.ps57in parsing and conflict detection, compare canonical pixel-input descriptions against <key>.psdep, remove stale .psdep in batch compile_job when pixel inputs are empty, and verify stale preserved-mtime base/RTV sidecars and 0-byte .psdep retranslation in native_compile_dxil_watch_check.py. Refs R0Y00#3133 AI-assisted.
|
Rebased onto
Local verification (
AI-assisted. |
4a7e254 to
e31ffc6
Compare
|
The compiler base #3091 now points to 247530b and this PR conflicts in compile_dxil.cpp. The base has a small guard for older-timestamp slot-57 files and the mixed-sidecar case. Your shared parser and canonical comparison cover the remaining timestamp-preserved stream changes and RTV variants. Please update this PR on the current base, use the shared comparison in place of the narrower watcher guard, and keep the unchanged-cache and old-timestamp controls. This is the follow-up we should carry forward for #3133. |
R0Y00
left a comment
There was a problem hiding this comment.
Reviewed e31ffc6 on compiler base 247530b. The watcher and request reader use the same canonical parser and compare the actual sidecar content to the dependency saved at publication. The controls cover preserved older timestamps for stream and slot-57 inputs, the derived RTV requests, unchanged cache hits and an empty dependency file. Batch and watch now both clear an obsolete dependency.
Debug and Release /O2 each passed five source-built tests: native_compile_dxil_watch, native_startup_request_cache_controls, native_rtv_variant_controls, native_compute_pack and native_frozen_request. Windows 11 26200.9974, SDK 10.0.26100. This approval covers the current stack head. Once the compiler stack is integrated, rerun the required checks on the eventual main target.
Keep R0Y00#3138's sidecar_changed invalidation and the branch's compute dependency_changed/lost checks in the watch request gate.
Fixes #3133 (Refs #3091).
Base:
codex/native-shader-modulesata48d39dc; commit4a7e2542.Root Cause
In tools/startup/compile_dxil.cpp,
is_watch_request_pending()only invalidated a published graphics manifest whenmax(mtime(.psin), mtime(.ps57in)) > mtime(<key>.txt)or when both sidecars disappeared while<key>.psdepexisted. Adding a contradictory.ps57inwith an older timestamp (<= mtime(<key>.txt)) or changing.psin/.ps57incontent while preserving an older timestamp left the stale<key>.txtmanifest on disk.Summary
read_pixel_inputs()in src/shader_compute_request.cpp and exposex2w::read_pixel_input_description()in src/shader_compute_request.h so the watcher and request loader share exact.psin/.ps57inparsing and conflict rules.is_watch_request_pending()in tools/startup/compile_dxil.cpp to compare canonical current sidecar content fromread_pixel_input_description()against published<key>.psdep(marking any mismatch, new sidecar, conflict, or invalid sidecar assidecar_changedregardless of timestamp)..psinand indexed reflected.ps57in), older- vs newer-mtime contradictory.ps57inequivalence (withdrawing<key>.txtwith identical stdout/.fail), preserved-older-mtime.psinand.ps57incontent changes, and base+.rtvvariant invalidation when base gains an older-mtime.ps57in.Verification
cmake --build --preset dev --target compile_dxil native_compute_pack_check native_frozen_request_check native_pixel_ir_dump native_compute_ir_dump: built cleanly.ctest --preset dev --no-tests=error -R '^(native_compile_dxil_watch|native_startup_request_cache_controls|native_rtv_variant_controls|native_direct_container|native_frozen_request)$' -V: 5/5 passed (native_compile_dxil_watch3.47s,native_direct_container24.45s,native_rtv_variant_controls2.29s,native_startup_request_cache_controls1.60s,native_frozen_request0.01s).ctest --preset dev --no-tests=error -R '^native_.*_(controls|ir)$' -j 4 --output-on-failure: 26/26 passed (18.69s).tests/docs_links_check.py: passed (79Markdown files,586links).AI-assisted.