perf(tools): scan trace slices once for the slowest frames #28916
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28916"
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?
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-12-04T16:28:54Z.
What
The slowest-frame section of
trace_digest.pyused to scan all captured slices for each requested frame. Walk the sorted slices once per thread and accumulate only their intersections with the selected frames. The report keeps its frame ranking, clipped contributions and tie order.Tested
Linux 7.3.6 x86-64, Python 3.14.10. All 195 tests in
python3 -B -m unittest discover -s tools/tests -p 'test_trace*.py'pass. The new test checks a slice spanning two selected frames with an unselected frame between them, exact-edge exclusions and tied slice totals. Compared the complete digest against main in 750 generated cases and verified byte-identical default JSON and 30-frame Markdown output on a completed trace.Median digest computation time over six alternating runs per version on the same parsed Smurfs village trace, with 280 frame intervals and 850,316 slices. Main was
82a605ad2c23. Parsing and rendering were outside the timed interval.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-04T16:55:04Z.
Review: APPROVED
Verified head
772780c4d3on Windows 11 with Python 3.13.7, applied to a copy oftools/(plusdocs/run-report-fixtures) frommain2fbf8b4391.python -m unittest discover -s tools/tests -p 'test_trace*.py': 195 tests OK (1 skipped). Main has 194 OK.worstof 0, 1, 2, 5 or 30) and compareddigest(...)["slowest_frames"]between main and this PR. There were 0 differences. 2,171 cases had slices in their slowest frames and 846 had tied slice totals, so tie order is covered.worst=10.092 s vs 0.095 s,worst=50.138 s vs 0.098 s,worst=300.481 s vs 0.106 s. Same shape as the table in the PR.Reading it: the single pass depends on each thread's slices being sorted by start time, which
Trace.__init__already guarantees, and on the frames being consecutive, non-overlapping intervals fromTrace.frames. The per-frameCounteris filled in the same thread and slice order as before, somost_commonbreaks ties the same way.Not run: Linux or a real capture.
AI-assisted: yes (Claude Code)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.