Repository navigation
Conversation
luckyteagirl
left a comment
There was a problem hiding this comment.
Used is held in a static OnceLock, so its Journal::Drop (which joins and drains the worker) does not run on ordinary process exit. After note() returns, the writer can wait up to COALESCE_WINDOW (25 ms) before opening/writing used-pipelines.txt; if the title exits during that window, those last-used keys are lost. The old synchronous path appended them before returning. Could the normal shutdown path explicitly flush/join this journal, and could a subprocess test record a key then exit without dropping a local Journal? The current drop test only covers a stack-owned journal.
|
Test report: passes on NVIDIA. Exact head Tested
Not tested
Claude Code (Claude Opus 5.5) ran the tests and wrote this report. |
bd9b400 to
ad798f3
Compare
|
@luckyteagirl Great catch — pushed
|
|
Source review of head
Not tested: no build or run of this head on our side. AI use: Gemini (Antigravity) did a first-pass review; Claude Code (Claude Opus 5.5) checked both points against the source at |
ad798f3 to
24e584c
Compare
|
@KDenKC Good catches on both points — pushed
|
|
Checked at AI use: Claude Code (Claude Opus 5.5) checked the source and wrote this. |
Retain sequenced keys when the journal worker cannot start or exits, and append them only after its file handle is gone at a flush boundary. Mark torn retry fragments invalid so they cannot become false preload ranks while complete retried keys keep their order. The worker-start fallback concept was adapted from xcl-dev#2635 by Decodere, authored there with Google Antigravity (Gemini 4 Neon), and reworked for the integrated ordered journal. Windows-GNU cargo check passed; focused tests could not link because x86_64-w64-mingw32-dlltool is unavailable. Assisted-by: Codex (GPT-5.6-sol)
Move used-pipelines.txt directory creation, lazy file open, formatting, and disk writes out of the used::note bind mutex onto a lightweight background writer thread (`xcl-pso-used`) with 25 ms burst coalescing (immediate drain at 64 keys), deterministic `Journal::flush()`, and bounded, lossless process-exit persistence. - Bound initial lock and I/O paths: cap initial `used-pipelines.txt` reads in `used::init_from_path` and `earlier_used_keys` to 16 MiB on a clean newline boundary (`read_used_bounded`), restore the `key == 0` early return before `used::get()` in `used::note`, bound `flush_bounded` initial and post-fallback state-mutex acquisition via `lock_until` with poison recovery across journal paths, and use bounded `flush_used_bounded(500 ms)` on the `XCL_RUN_SECONDS` watchdog thread in `host.rs` before `real::end_title(0)` while keeping `shutdown_used()` on normal game return and `atexit`. - Account for batches already owned by the writer thread: track the writer's active `in_flight` batch (`in_flight`, `in_flight_seq`, `in_flight_fallback_written`) in `JournalState` until `write_batch` finishes so timed-out `flush_bounded` drains (e.g., `ExitProcess` loader-lock stalls via `eh::hk_nt_terminate_process`) and mid-batch writer panic `shutdown()` persist both in-flight and queued keys to `fallback_path` without losing keys or falsely advancing `completed_seq` (and leave both intact when no `fallback_path` is configured or restore them on transient fallback write failure). - Keep `cfg!(test)` isolated from the user's cache file, tolerate I/O failures without panicking or breaking in-memory deduplication, and add regression tests covering bounded lock timeout, in-flight + pending fallback persistence, non-fallback preservation, mid-batch writer panic recovery, and line-boundary bounded reads. Part of xcl-dev#2508 Part of xcl-dev#1833 Assisted-by: Google Antigravity (Gemini 4 Neon)
24e584c to
3dca5a0
Compare
|
Addressed
|
Retain sequenced keys when the journal worker cannot start or exits, and append them only after its file handle is gone at a flush boundary. Mark torn retry fragments invalid so they cannot become false preload ranks while complete retried keys keep their order. The worker-start fallback concept was adapted from xcl-dev#2635 by Decodere, authored there with Google Antigravity (Gemini 4 Neon), and reworked for the integrated ordered journal. Windows-GNU cargo check passed; focused tests could not link because x86_64-w64-mingw32-dlltool is unavailable. Assisted-by: Codex (GPT-5.6-sol)
Retain sequenced keys when the journal worker cannot start or exits, and append them only after its file handle is gone at a flush boundary. Mark torn retry fragments invalid so they cannot become false preload ranks while complete retried keys keep their order. The worker-start fallback concept was adapted from xcl-dev#2635 by Decodere, authored there with Google Antigravity (Gemini 4 Neon), and reworked for the integrated ordered journal. Windows-GNU cargo check passed; focused tests could not link because x86_64-w64-mingw32-dlltool is unavailable. Assisted-by: Codex (GPT-5.6-sol)
Retain sequenced keys when the journal worker cannot start or exits, and append them only after its file handle is gone at a flush boundary. Mark torn retry fragments invalid so they cannot become false preload ranks while complete retried keys keep their order. The worker-start fallback concept was adapted from xcl-dev#2635 by Decodere, authored there with Google Antigravity (Gemini 4 Neon), and reworked for the integrated ordered journal. Windows-GNU cargo check passed; focused tests could not link because x86_64-w64-mingw32-dlltool is unavailable. Assisted-by: Codex (GPT-5.6-sol)
Retain sequenced keys when the journal worker cannot start or exits, and append them only after its file handle is gone at a flush boundary. Mark torn retry fragments invalid so they cannot become false preload ranks while complete retried keys keep their order. The worker-start fallback concept was adapted from xcl-dev#2635 by Decodere, authored there with Google Antigravity (Gemini 4 Neon), and reworked for the integrated ordered journal. Windows-GNU cargo check passed; focused tests could not link because x86_64-w64-mingw32-dlltool is unavailable. Assisted-by: Codex (GPT-5.6-sol)
What is in it
Part of #2508
Part of #1833
pso_async::used::note()(crates/xcl/src/hle/d3d12x/pso_async.rs) previously ran synchronouscreate_dir_all,OpenOptions::open, and unbufferedwriteln!(f, "{key:016x}")syscalls while holding the globalused::nowmutex on the title's command-recording / bind thread (Pending::note_use, called fromresolveandresolve_wait_for). During world-load pipeline bursts, every newly used pipeline serialized bind threads behind disk I/O.Changes (3 files:
crates/xcl/src/hle/d3d12x/pso_async.rs,crates/xcl/src/host.rs,crates/xcl/src/eh.rs):used::Journalbacked by a single lightweight writer thread (xcl-pso-used),Mutex<JournalState>,wake_cv, andflushed_cv.Journal::note(key)performs zero filesystem syscalls on the caller thread or under the state mutex: it inserts intoseen, appends topending(continuing to queue keys whilefallback_pathis set even if writer spawn failed), and notifieswake_cvonly on empty-to-nonempty (1) and burst-threshold (64) transitions.used::note(0)returns early beforeused::get(), avoidingOnceLockinitialization and startup I/O on zero keys.writer_loopcoalesces bursts up to25 ms(draining immediately at64unique keys), movespendingintoin_flight(in_flight,in_flight_seq,in_flight_fallback_written) under the state lock before dropping it for I/O, lazily creates parent directories (only when absent) and opensused-pipelines.txt, performs a single batchedwrite_all+flush, then clearsin_flightand advancescompleted_seq = completed_seq.max(batch_seq). I/O failures clear the cached handle and never panic or break in-memory deduplication.if cfg!(test)isolated from the user's cache file (Journal::in_memory, with a test-onlyXCL_TEST_USED_STATIC_PATHenv hook for subprocess exit verification) and leftcounts()un-flushed (present.rscalls it onPresentX).@Prime1997's#2572review,@luckyteagirl's exit-flush review, and@KDenKC's follow-up review):MAX_USED_FILE_BYTES = 16 MiBandread_used_bounded(path, max_bytes)inused::init_from_pathandearlier_used_keys(), trimming any truncated tail back to the last newline so an oversized or truncated file cannot stall startup or parse a partial hex key.lock_until(mutex, deadline)(try_lockloop with poison recovery, sleeping up to1 msslices untildeadline) and poison recovery across all journal locks soJournal::flush_bounded(timeout)bounds both initial and post-fallback state-mutex acquisition and never deadlocks if another thread is suspended or wedged holdingstateduring termination.Journal::flush_bounded(timeout)accounts for writer-ownedin_flightbatches as well aspending: when timed out (e.g.,xcl-pso-usedblocked on the Windows loader lock duringExitProcess) or stopped, it drains both unwrittenin_flightkeys andpendingkeys tofallback_pathand advancescompleted_seqonly whenappend_to_pathsucceeds (restoringin_flight_fallback_writtenandpendingon transient fallback failure, and leaving both untouched without advancingcompleted_seqwhenfallback_pathisNone).Journal::shutdown(&self)flushes pending keys and joinsxcl-pso-usedthrough a shared&'staticreference (Dropdelegates toshutdown()), then drains any remaining unwrittenin_flight(e.g., mid-batch writer panic whereStopGuardmarkswriter_stopped) andpendingkeys tofallback_path.atexit(on_process_exit)->used::shutdown()whenused::init_from_pathinitializes the file-backed static journal, wiredpso_async::shutdown_used()on normalloader::run_mainreturn incrates/xcl/src/host.rs, wired boundedpso_async::flush_used_bounded(500 ms)on theXCL_RUN_SECONDSwatchdog thread beforereal::end_title(0)so a wedged writer cannot hang the watchdog, and wiredpso_async::flush_used_bounded(100 ms)intocrates/xcl/src/eh.rs::hk_nt_terminate_processalongsidecrate::log::flush().pso_async::used_tests:used_note_does_not_block_on_slow_writerused_burst_coalesces_writes_and_deduplicates_keysused_flush_drop_lazy_file_and_io_error_are_gracefulused_static_once_lock_flushes_on_process_exit(normal/exit/explicit/boundedsubprocess exit paths)used_flush_bounded_timeout_and_spawn_failure_fallback_are_soundused_flush_bounded_respects_timeout_when_state_lock_is_heldused_flush_bounded_persists_writer_in_flight_batch_and_preserves_non_fallback_pending(file-backed in-flight-only timeout, in-flight + pending timeout with monotoniccompleted_seq, non-fallback preservation, and mid-batch writer panicshutdown()recovery)used_bounded_read_caps_oversized_file_on_line_boundaryTested
1.9.2609.5,rustc 1.100.0, debug + releasecargo clippy --all-targets -- -A clippy::approx_constant: 0 new warnings or errors across all 3 modified files (pso_async.rs,host.rs,eh.rs)XCL_ADAPTER=warp,XCL_WARP=1):cargo test -p xcl --lib -- hle::d3d12x::pso_async:: --test-threads=4 --nocapture->22 passed, 0 failed, 0 ignored(3/3 consecutive runs,0.79 seach,0skipped)cargo test --release -p xcl --lib -- hle::d3d12x::pso_async:: --test-threads=4 --nocapture->22 passed, 0 failed, 0 ignored(3/3 consecutive runs,0.78–0.79 s,0skipped)cargo test --release -p xcl --lib -- hle::d3d12x::bind:: --test-threads=4 --nocapture->8 passed, 0 failed, 0 ignoredcargo test --release -p xcl --lib -- eh:: --test-threads=4 --nocapture->6 passed, 0 failed, 0 ignoredcargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1443 passed, 0 failed, 47 ignored across 37 workspace test targets (SKIPPED GPU tests/subcases: wave64-only GPU tests on 32-lane RTX 4060, 3 per-lane wave32 driver-refused subcases,heap_window_out_of_memory_falls_back_to_the_switch_formwithoutXCL_HEAP_WINDOWS=1,pso_measurement_compiles_an_exact_synthetic_recordwithout Windows Developer Mode, and 3 debug-layer tests withoutd3d12SDKLayers.dll)Regression run
main:
PR:
Not tested
TerminateProcessfrom outside the process (which bypasses user-mode hooks andatexit).XCL_HEAP_WINDOWS=1, driver-cache-disabled PSO measurement), non-Windows / Wine hosts, and the 47#[ignore]tests.AI use
used::Journalwriter, bounded initial lock/I/O paths (read_used_bounded,lock_until,XCL_RUN_SECONDSbounded flush), writer in-flight batch tracking and panic/timeout fallback recovery, process-exit flush/shutdown wiring (atexit,host::host_main,eh::hk_nt_terminate_process), unit and subprocess regression tests, and verification runs.