Repository navigation
hle: capture DSP impulse responses and command blocks - #39
Conversation
|
Other open pull requests change the same files. Check that they do not do the same work, and agree with their authors on which lands first: the other one will then need a rebase.
This comment is kept up to date automatically and removed when the overlap ends. |
simnJS
left a comment
There was a problem hiding this comment.
Thanks @AliceWood, this is a careful first step for #10:
- it's opt-in and diagnostics-only;
- it's guarded by
ensure_outside_repo; - it writes atomically;
- the child-process test covers the disabled, empty, in-repo and unusable cases with synthetic data.
Two changes before merge:
- Bound the disk use. There is a 4-block limit per stream, but no limit on streams per session, and the IR is written at whatever size
ir_floatsclaims (up to 16 GiB). Please add a session counter likeXTP_XMA_DUMP's 32, and a ceiling on IR bytes (derived from the connection'sir_seconds, or a flat limit). If it's cheap, also check that the range is readable (VirtualQuery), since this is the first code that dereferencesdesc.irand the field hasn't been checked on a title yet. - Keep I/O off the completion path.
XDspSubmitCommandcreates and renames up to 8 files before it publishescompleted, which other title threads poll, and activation writes the whole IR inside the call. Please copy the block (16 KiB at most) and the IR, publish the status first, and hand the writes to a small writer thread.
Optional:
- Resolve
XTP_DSP_DUMPonce, or require an absolute path. The title can change the working folder, so a relative path could land in its install folder. - The output files are always our own zeros. Capturing the output buffer before we clear it would tell us whether the DSP accumulates.
- Recording the command
gainsand the connection'sir_seconds/max_channelsin the capture would help Q5. - A sequence number in the folder name (
stream-000-…) and aninfo!line with the path would make captures easier to match to a session. - One line in the description on why
tempfilebecomes a diagnostics runtime dependency, and a mention ofXTP_DSP_DUMPindocs/analysis/hle.md.
simnJS
left a comment
There was a problem hiding this comment.
Thanks @AliceWood, both requested changes are in:
- captures stop at 32 streams per process and at 4 MiB per IR, and the IR is read through the loader's checked reader;
- the buffers are copied,
completedis published, and only then does one writer thread write the files. The paused-writer test shows the order.
The optional items are covered too. Approving: it's opt-in and diagnostics-only, so the points below can come as a follow-up PR:
Connection::dropwaits onrecv()with no timeout (capture.rs:144). If the writer is stuck on a slow disk, or gone because the process is exiting,XDspDisconnecthangs the title. Arecv_timeoutof a few seconds with a warning is enough, and you could skip the wait when the connection queued nothing.block-N.output.f32leis always our own zeros, so the README line about comparing it with.output-beforedescribes XTP's stub, not the DSP. I'd drop that file. It also saves a checked read per command: each one callsVirtualQuery, and on a large committed heap one call can take milliseconds, longer than an audio block.write_bytesalready writes that range unchecked, so a plain copy ofoutput-beforeis no less safe. I'd keep the checked read for the IR.- The stream folder gets its final name before it is filled. If the process ends mid-write,
params.txtwith noir.f32lelooks the same as an IR left out on purpose. Writing the reason intoparams.txt(ir=oversized/ir=unreadable) would tell them apart. - 4 MiB is about 22 s of mono at 48 kHz, so a full 24 s IR would be dropped. Since
ir_floatsis logged, we can raise the limit after a first real run.
Note for later reworks: read_title_memory is now a public API used by xtp-hle, so any change to the loader's memory checks must keep its contract (false for unmapped, reserved, no-access or guard pages).
What and why
Setting
XTP_DSP_DUMPto an absolute directory outside the repository records data for studying the DSP's impulse-response layout offline. Diagnostics builds capture the first 32 activated streams per process, across connections, and the first four commands per stream. Each numbered directory records the stream descriptor, the connection's IR duration and channel limit, and the impulse response if it is readable and at most 4 MiB.The DSP copies the buffers while the caller still owns them. Windows captures include the input, destination before and after completion, and both gains. Command submission publishes the completion ticket before queueing the owned snapshots. A single background thread writes the files, and disconnect drains queued work. The diagnostics runtime uses
tempfileto give each stream a unique directory and atomically publish complete files.Fixes #10
Depends on: none
Area
xtp-hleDSP activation and submission, the existing checked Windows memory reader inxtp-loader, and the README and HLE analysis. The diff exceeds 400 changed lines because the writer and its regression tests cover bounded capture, caller-owned buffer lifetimes, and completion while the writer is paused.Tests
cargo xtask pr-checkpasses on my machineThe existing Windows DSP fixture produced zero files on upstream
f32d879, six on the initial PR and eight after the review fix, using the same profile and capture setting. The extra files record the command gains and original destination.Both DSP tests passed on
4202785withcargo test --locked -p xtp-hle --lib modules::dspand with--features diagnostics. The test opens 33 connections in one process, checks the 4 MiB boundary and oversized/unreadable responses, and verifies separate and in-place buffers byte for byte. With the writer paused, five commands finish and publish their tickets before any file appears. The loader's existing guard-page and overflow test also passed.In
cargo xtask pr-check --base origin/main, formatting, both Clippy runs, asset policy and conventions passed. The local workspace test step failed on eight GPU tests, all of which also failed on the original upstream baselinef32d879.Provenance
AI assistance: Codex wrote the implementation, review fixes, regression test and docs, and ran the checks. I reviewed the initial commit
bfa5c9f. Direct sources were this issue, the PR review, XTP's DSP code and tests, existing capture code, loader memory reader, runtime asset policy and HLE analysis. The issue and HLE analysis supplied the second-hand description of xcl's observations. No xcl or AnyPS5 source was opened or copied.Checklist
<area>: <summary>; one topic; under 400 changed lines, or the reason is above