Always append the target PID to profiler output paths - #31
Conversation
In cooperative mode Wine re-executes every 32-bit process through the sidecar, so one game launch is several sidecars: the wineboot helpers, the process that starts the game, and the game itself, all inheriting the same X87_PROFILE. The last sidecar to open the path wins, and since the block profiler appends its counter section only after its target exits, the game's profile was routinely truncated by a helper's before it could be finalised. profile_analyze then rejected it as incomplete, with no way to tell which process the surviving file belonged to. Expand %p against the pid behind the task port the sidecar received, for both X87_PROFILE and X87_SAMPLE, before any old output is unlinked or a new file opened. Without %p the paths behave as before. If the target pid cannot be resolved the profiler is disabled with a message rather than writing under the wrong name. Verified under wine-cx-26.3.0-1 on an M2 Max, macOS 26.5, with a 32-bit Direct3D game: one launch produced x87-block-<pid>.prof for each of four cooperative sidecars, and the game's file carried a complete counter section that profile_analyze accepted (2197 blocks). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2553343 to
243630d
Compare
…X87_SAMPLE Our horizonxi-x87 delta only had the X87_SAMPLE half of the %p work (the narrower expandSamplePid). PR athei#31 (profile-pid-path, filed athei#31) generalizes it: a shared expandTargetPid(path, targetPid, variable) covering both X87_PROFILE and X87_SAMPLE, plus the README docs. Adopt PR athei#31's form and drop the now-orphaned expandSamplePid so development carries all of our upstreamed %p work, not half of it. Sticky sampler is unchanged. Verified: cmake build clean; run_tests.sh test_arith 11/11 pass, 0 divergences. %p output-path expansion is config plumbing with no translation effect.
|
Could we drop |
|
@rdbell Can you incorporate my suggestion? |
|
Implemented your suggestion: both profilers now always append Local validation passed: release build, six profiler captures across three filename cases, and 11/11 selected x87 loop configurations. Work by Claude Fable 5.1 and GPT-6 Astra. |
When multiple Wine processes inherit the same profiler path, their sidecars can truncate one another's captures. Both
X87_PROFILEandX87_SAMPLEnow always append.<pid>using the attached target's PID:/tmp/game.profbecomes/tmp/game.prof.12345. The same behavior applies to--sample.The suffix is simple concatenation, applied before opening or unlinking output. There is no placeholder or extension parsing;
%pis literal. Sampling windows use<file>.<pid>.windows. If the target PID is unavailable, that profiler is disabled with a diagnostic before touching files.README and command-line help document the output names. A bounded integration test, also added to CI, runs two targets concurrently against shared configured paths and checks both profilers, finalized block counters, sampling windows, environment/CLI configuration, literal
%p, extensionless names, and preservation of existing files.Validation on Apple Silicon, macOS 26.5:
python3 scripts/test_profile_paths.py: all three cases passed, covering six target processes.bash scripts/run_tests.sh --no-build test_x87_loop: 11 passed, 0 failed across the selected configurations.Work by Claude Fable 5.1 and GPT-6 Astra.