fix(vi): drain the present trace on a Windows windowless stop #3266
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3266
Loading…
Reference in a new issue
No description provided.
Delete branch "futondestroyer/Longshot:fix/windows-present-trace-drain-e13"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
On Windows, enable
HOS_PRESENT_TRACEin a windowless game and close it through its stop window while rows are buffered. The game can exit successfully with the last batch missing frompresents.csv.The windowless stop worker now closes the trace stream after the normal close work and before terminating the process. The writer and drain share a lock, so the drain waits for an admitted write and prevents a late present from reopening the file. Read
stop_workerinhost/windows_stop.candhos_vi_present_trace_endinhost/nn_vi.cfirst.Testing
Tested: Windows 11 26H2, RTX 4070, NVIDIA 621.01. Alternated two stock and two fixed windowless launches at the Kokiri Forest checkpoint and closed each through the native stop window. All four game processes and their Builder supervisors exited with code 0. The fixed trace contained every observed present, with complete, contiguous CSV rows. A fifth fixed launch with tracing disabled exited through the same route and produced no CSV. Both builds accepted a Unicode trace path.
The Windows regression on
e13b792fandfbc988fbretained frames 1–4 on stock and 1–5 with the fix under LLVM-MinGW and GCC. Visible-window, control-bridge and normal C runtime exits passed, along with repeat drain, drain before opening, tracing disabled, and watchdog cases. An independent test verified that the drain waits for an admitted write, rejects a late write, and leaves separately buffered output alone. Removing the drain reproduces the missing fifth row. Removing the seal lets the late frame overwrite the trace.Both changed Windows translation units passed syntax checking on the replay and its parent with the Builder’s diagnostic flags. With extra warnings enabled, both revisions report the same missing declarations for
rx_menu_openandrx_display_refresh_mhz. Supplying their existing header for that diagnostic check clears both errors. Formatting, Python lint, workflow lint and a separate commit-range secret scan passed.The gameplay comparison below used the ABI 95 builds it names. The production patch replayed unchanged on ABI 98. The tested 60 FPS active-play route uses the same pacing period, trace stream and windowless stop sequence. The fixture still exercises the native stop route and now also extracts the upstream pacing helpers. The WIP keeps the exact game-free-tested head
fbc988fbone13b792f. It merged cleanly in a local preview against active main754bd6d8, which has the same trace and stop sources ase13b792f.The full strict Windows suite on
fbc988fbrecorded 787 passes, 76 failures and 52 skips. All 76 failures reproduced one13b792fusing the same pinned tools and flags.Strict Windows failures also reproduced on the branch base
tests/test_astc_reuse.pytests/test_capture_copy_helpers.pytests/test_cbuf_table_extent.pytests/test_coverage_run.pytests/test_cv_handoff_threads.pytests/test_cv_signal_race.pytests/test_dev_update.pytests/test_display_pointer.pytests/test_dlss_actor.pytests/test_dlss_checks.pytests/test_dlssg.pytests/test_drawn_writeback.pytests/test_driver_faults.pytests/test_fallback_lanes.pytests/test_fallback_size_policy.pytests/test_fg_scale_sharpen.pytests/test_fixed_share_upscale_shader.pytests/test_fps_overlay_order.pytests/test_fps_stats.pytests/test_fsr4_tune.pytests/test_gpu_choice.pytests/test_helpers_extract.pytests/test_import_hold.pytests/test_import_span.pytests/test_import_windows.pytests/test_jobs_wait_runs_queued.pytests/test_lifter.pytests/test_longshot_builder.pytests/test_lower_atomg_cas.pytests/test_lower_end_at_closing_branch.pytests/test_lower_immediate_not_register.pytests/test_lower_imnmx_wide_immediate.pytests/test_lower_isberd_output.pytests/test_lower_ldg_uniform_order.pytests/test_lower_lea_hi_constant.pytests/test_lower_r2ur_one_register.pytests/test_lower_suld_1d.pytests/test_lower_tld_ms.pytests/test_mask_history_retire.pytests/test_menu_env_on.pytests/test_mirror_inherit.pytests/test_mirror_trim.pytests/test_native_zstd.pytests/test_parity_gates.pytests/test_pcache_stamp.pytests/test_prepare_seed_stamp.pytests/test_prepare_workers.pytests/test_present_acquire_ahead.pytests/test_present_held_image.pytests/test_present_image_free.pytests/test_present_semaphores.pytests/test_program_cache_cleanup.pytests/test_program_cache_reader.pytests/test_program_cache_store_record.pytests/test_program_record_head.pytests/test_push_state.pytests/test_quick_pipelines.pytests/test_report_words.pytests/test_seed_kept_loaded.pytests/test_seed_reader.pytests/test_skip_code.pytests/test_sparse_bc_usage.pytests/test_startup_progress.pytests/test_taau_env_lookup.pytests/test_target_overlap.pytests/test_target_retention.pytests/test_tex_spans_once_a_present.pytests/test_ub_gap.pytests/test_upscale_fallback.pytests/test_upscale_independent.pytests/test_vk_draw_overhead_lean.pytests/test_vram_compact.pytests/test_wb_diff_stale_shadow.pytests/test_wb_learn.pytests/test_wb_pages.pytests/test_xinput_thread.pyStill to test:
SRWLOCKshim and the normal close keeps complete rows. By hand.Measurements
Verdict: The fix kept all observed rows in both closes. Main dropped at least 31 and 25.
Setup: Same Windows 11 PC, RTX 4070 and driver 621.01, two interleaved runs per arm in windowless Kokiri Forest at a 60 FPS cap with frame generation and shader precompile disabled. Both builds used ABI 95, the same Builder and Rust library, and a single refreshed runtime slot. Row loss gives stock credit for one sampled present that might still be waiting to enter the writer. Each relinked host was verified with its own build receipt before launch.
3a0f7d8f7f34360a464df614fc38a2a0c5bf680616f495ecfb04352b452001ee0893d7876242e67fRisks
With tracing enabled, a successful windowless close waits for the trace stream to finish writing. An OS-ending forced stop can still interrupt blocked storage I/O.
Checklist
Ready for review
main; the title is a Conventional Commit. The WIP is pinned to the testede13b792fbase. Refresh against current main before Ready.mise run testpasses (any failure that also fails onmainis named). All Windows strict failures reproduced one13b792funder the same tools and are listed above.main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Tested in game: Windows 11 26H2, RTX 4070, NVIDIA 621.01. In matched ABI 95 windowless Kokiri Forest runs, stock
3a0f7d8fmissed at least 31 and 25 earlier present rows. Fix 16f495ec drained 25 more complete rows at each native WM_CLOSE and retained every observed present. The tracing-off run created no CSV. All five native and Builder exits returned zero. The same trace and stop patch is onfbc988fb, with exact ABI 98 focused and strict game-free results in the description.@review Please review exact head
fbc988fb5f37f183076dc78b50095f3f7bd183a1for the Windows windowless present-trace drain. The ABI 98 source checks reproduce four rows on the branch base and retain all five with the fix. The gameplay figures in the description use the original ABI 95 builds.Recommendation: Approve. The reported Windows gameplay runs show that the drain recovers the missing trace rows. The exact ABI 98 runtime and the shared writer on Linux still need the runs identified by the author before merge. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
The windowless Windows stop now closes the present trace before terminating, preserving buffered rows and sealing the stream against later writes. The shared writer gains a lock when tracing is enabled; the committed tests cover the shutdown routes but do not exercise the writer and drain concurrently.
Should fix (1): not blocking, but worth doing before merging.
tests/test_present_trace.py:245: The checked-in shutdown tests never overlap a present write with the drain, so they do not protect the new lock's purpose. (more on the line) Do: Add a deterministic concurrent fixture that holds an admitted write while the drain starts, verifies that the drain waits, and then checks that a late write cannot reopen the stream.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes: in two interleaved ABI 95 Windows runs per side, the stock builds missed at least 31 and 25 earlier rows, while both fixed runs retained every observed present. The exact-head game-free regression reports four rows on the base and five with the fix; exact-head ABI 98 gameplay remains untested.
Other systems: The writer also runs on Linux and on visible-window and control-bridge exits. The reported game-free checks cover those exit routes, but the native Linux build and runtime remain untested. The lock is used only when tracing is enabled; GPU rendering is not otherwise changed.
Switches: No switches added, changed or removed. HOS_PRESENT_TRACE remains disabled by default.
Reviewed:
fbc988fb5fagainste13b792f1a: Read the repository rules, PR template, standards, commits, diff, changed code and tests, and the relevant present and close call paths. Skimmed the broader nn_vi.c context and source-cutting helper. docs/review-checklist.md and the adjacent Tooling checkout were absent. No recorded run files or translations were changed.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no commands from the project, builds or tests were run. The supplied CI checks are still running.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by futondestroyer. Nothing was run; a maintainer decides.
@ -179,4 +242,4 @@check_csv(path)else:assert not path.exists(), "disabled trace created a file"assert states[0] == states[1] == states[2], "tracing changed pacing/counters"L1 (should fix): The checked-in shutdown tests never overlap a present write with the drain, so they do not protect the new lock's purpose.
When: If the lock operations are removed while the seal remains, the sequential end-twice and end-first cases still pass, even though a stop can close the stream while another thread is writing to it.
Do: Add a deterministic concurrent fixture that holds an admitted write while the drain starts, verifies that the drain waits, and then checks that a late write cannot reopen the stream.
WIP: fix(vi): drain the present trace on a Windows windowless stopto fix(vi): drain the present trace on a Windows windowless stop