From a recording to disk: who writes what, and when the lock is held
A recording on macOS, from the first check to the files on disk
Five actors: the MCP server, the lock, the script perf_record.sh, the report perf_report.py and the runs folder. Eight numbered steps: the server checks the lock; the script takes it; the script and Instruments write the samplers and the trace; the script starts the report; the report writes the tables and a first summary; the script deletes the trace and applies KEEP_RUNS; the script frees the lock; the server finishes, applies the disk limit and rewrites the summary. The lock is held from step 2 to step 7.
MCP server
recording.py
Lock
recording.lock
Script
perf_record.sh
Report
perf_report.py
Runs folder
perf-runs/
1 check pid
2 mkdir lock, write pid
3 samplers + .trace
4 run perf_report
5 tables, first .json
6 rm .trace, KEEP_RUNS
7 rm lock
8 finish: rewrite .json
lock held, steps 2 to 7
accent: steps 5 and 8
dashed = read only
run by hand (perf_record.sh alone): no steps 1 and 8, so no disk limit
Windows: its own lock code