perf(tools): bound trace timeline layout memory by the slice cap #28918

Open
JJenkx wants to merge 1 commit from upstream-pr/28918 into main
JJenkx commented 2026-12-04 16:58:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-12-04T16:58:12Z.


What

Select the longest clipped slices directly from an iterator when generating the HTML timeline. Count every visible slice and collect its thread while selecting the bars, so the page retains its thread rows, omitted-slice count, present markers and tie order. The rendering pass keeps at most the requested number of bars plus per-thread state.

Tested

Linux x86-64, Python 3.14.10. All 194 tests in python3 -B -m unittest discover -s tools/tests -p 'test_trace*.py' and the conventions check passed. Compared 600 generated layouts across zero and positive caps, thread filters and clipped windows. The default CLI output was byte-identical on a retained Smurfs village trace with 850,316 visible slices and 5,000 bars drawn. The changes also passed all 33 timeline tests when combined with #28352.

Measured clipping and layout after parsing the same capture once on main 82a605ad2c23 and this branch. CPU time is the median of six alternating runs per version. Python allocation peaks were sampled in separate runs.

Clipping and layout Main This change
CPU time 0.862 s 0.365 s
Peak traced allocations 249.0 MiB 3.2 MiB

The full CLI peaked at about 800 MiB on both versions. Trace loading alone peaked at about 795 MiB.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5650718792 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28918). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-12-04T16:58:12Z. --- ### What Select the longest clipped slices directly from an iterator when generating the HTML timeline. Count every visible slice and collect its thread while selecting the bars, so the page retains its thread rows, omitted-slice count, present markers and tie order. The rendering pass keeps at most the requested number of bars plus per-thread state. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Linux x86-64, Python 3.14.10. All 194 tests in `python3 -B -m unittest discover -s tools/tests -p 'test_trace*.py'` and the conventions check passed. Compared 600 generated layouts across zero and positive caps, thread filters and clipped windows. The default CLI output was byte-identical on a retained [Smurfs village trace](https://github.com/boykopovar/AnyPS5/discussions/8158#discussioncomment-20140953) with 850,316 visible slices and 5,000 bars drawn. The changes also passed all 33 timeline tests when combined with #28352. Measured clipping and layout after parsing the same capture once on main `82a605ad2c23` and this branch. CPU time is the median of six alternating runs per version. Python allocation peaks were sampled in separate runs. | Clipping and layout | Main | This change | | --- | ---: | ---: | | CPU time | 0.862 s | 0.365 s | | Peak traced allocations | 249.0 MiB | 3.2 MiB | The full CLI peaked at about 800 MiB on both versions. Trace loading alone peaked at about 795 MiB. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/28918:upstream-pr/28918'
git switch 'upstream-pr/28918'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/28918'
git switch 'upstream-pr/28918'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/28918'
git switch 'upstream-pr/28918'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/28918'
git switch 'main'
git merge --squash 'upstream-pr/28918'
git switch 'main'
git merge --ff-only 'upstream-pr/28918'
git switch 'main'
git merge 'upstream-pr/28918'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!28918
No description provided.