trace: the queue-0 worker fills its 262,144-event buffer in about 3 s, so a 30 s window keeps only its first tenth, and trace_dropped doesn't say which thread or when #5786

Closed
opened 2026-10-14 10:47:39 +00:00 by eliyarson · 1 comment
eliyarson commented 2026-10-14 10:47:39 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by eliyarson on 2026-10-14T10:47:39Z.


What happens. In a busy scene the queue-0 worker's trace buffer fills about 3.3 s into an APS5_TRACE_SECONDS=150:30 window. After that the trace has no slices for that thread, while the presenter and gpu tracks run to the end of the window. That worker is the thread most performance reports are about. The summary line stays correct, because thread totals keep accumulating after the buffer is full. The only sign is "trace_dropped":true, which doesn't say which thread stopped, when, or how much was lost.

Measured. Hades II, hub after the intro (the #5485 scene), Linux, RTX 3080 Ti, main a0f5916a2 and 665ad7da7, APS5_TRACE_SECONDS=150:30. These are six traces read back from the .json.gz files:

trace queue worker 0x0 slices last worker slice (s into window) presenter / gpu last slice
a0f5916a2 262,050 3.32 29.97 / 30.01
665ad7da7 #1 262,048 3.27 29.97 / 30.00
665ad7da7 #2 262,047 3.25 29.97 / 30.00
665ad7da7 #3 262,049 3.25 29.98 / 30.01
665ad7da7 #4 262,046 3.20 29.99 / 30.02
665ad7da7 #5 262,049 3.27 30.00 / 30.03

Frame p50 in these runs is 31–35 ms, so the worker writes about 80,000 slices of 20 µs or longer per second, roughly 2,600 per frame. All 33 traces we have recorded of this scene (11 on main commits, 22 on a local branch) report trace_dropped=true. (@MarcZX100 asked about this on #5485.)

Why (main 3e577edac):

  • TraceThread::DefaultCapacity = 262144 (Execution/include/PerformanceTrace.hpp:128). Every thread gets the same size through BindThread (src/PerformanceTrace.cpp:138-141; queue workers bind at Driver/Queues/QueueWorker.cpp:87).
  • append sets dropped and returns once the buffer is full (PerformanceTrace.hpp:195-203). Nothing marks where the thread's slices stop.
  • trace_dropped is one flag OR-ed over all threads (:408-410, :431). The same flag is also set when the 512-entry totals table is full (account, :205-222). That second case is different: there the summary totals themselves are incomplete. The summary can't tell the two apart.

A slice is 32 bytes, so the default buffer is 8 MiB per thread. Covering this 30 s window on queue 0 would take about 2.5 M slices, around 80 MiB.

Proposal (opt-in; defaults unchanged):

  1. Report each drop in the summary, per thread and per reason. For example, "trace_dropped":{"queue worker 0x0":{"events_after_s":3.32,"lost":2240000}} for a full event buffer and a separate "totals_full" entry when the totals table overflows, so a reader knows whether the summary numbers are still complete. Also keep a plain boolean for existing readers (for example trace_dropped_any), or keep the boolean under its current name and add the detail as trace_dropped_threads.
  2. Add an instant event trace buffer full on the thread at the time of its first lost slice, so Perfetto shows where the track ends.
  3. Add APS5_TRACE_EVENTS=<n> to size the per-thread buffer (whole number, bounded, malformed value fails the first present, like the other trace switches), and document the memory cost in BUILD.md.
  4. Optionally, have tools/trace_digest.py print the per-thread cut-off.

I can send a PR for this, starting with 1 and 2, unless someone already has it in progress or the trace owners prefer a different shape (for example a ring that keeps the last N events instead of the first N).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5846419168 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/5786). Originally posted by [eliyarson](https://github.com/eliyarson) on 2026-10-14T10:47:39Z. --- **What happens.** In a busy scene the queue-0 worker's trace buffer fills about 3.3 s into an `APS5_TRACE_SECONDS=150:30` window. After that the trace has no slices for that thread, while the presenter and `gpu` tracks run to the end of the window. That worker is the thread most performance reports are about. The summary line stays correct, because thread totals keep accumulating after the buffer is full. The only sign is `"trace_dropped":true`, which doesn't say which thread stopped, when, or how much was lost. **Measured.** Hades II, hub after the intro (the #5485 scene), Linux, RTX 3080 Ti, `main` a0f5916a2 and 665ad7da7, `APS5_TRACE_SECONDS=150:30`. These are six traces read back from the `.json.gz` files: | trace | `queue worker 0x0` slices | last worker slice (s into window) | presenter / gpu last slice | |---|---|---|---| | a0f5916a2 | 262,050 | 3.32 | 29.97 / 30.01 | | 665ad7da7 #1 | 262,048 | 3.27 | 29.97 / 30.00 | | 665ad7da7 #2 | 262,047 | 3.25 | 29.97 / 30.00 | | 665ad7da7 #3 | 262,049 | 3.25 | 29.98 / 30.01 | | 665ad7da7 #4 | 262,046 | 3.20 | 29.99 / 30.02 | | 665ad7da7 #5 | 262,049 | 3.27 | 30.00 / 30.03 | Frame p50 in these runs is 31–35 ms, so the worker writes about 80,000 slices of 20 µs or longer per second, roughly 2,600 per frame. All 33 traces we have recorded of this scene (11 on `main` commits, 22 on a local branch) report `trace_dropped=true`. (@MarcZX100 asked about this on #5485.) **Why** (`main` 3e577edac): - `TraceThread::DefaultCapacity = 262144` (Execution/include/PerformanceTrace.hpp:128). Every thread gets the same size through `BindThread` (src/PerformanceTrace.cpp:138-141; queue workers bind at Driver/Queues/QueueWorker.cpp:87). - `append` sets `dropped` and returns once the buffer is full (PerformanceTrace.hpp:195-203). Nothing marks where the thread's slices stop. - `trace_dropped` is one flag OR-ed over all threads (:408-410, :431). The same flag is also set when the 512-entry totals table is full (`account`, :205-222). That second case is different: there the summary totals themselves are incomplete. The summary can't tell the two apart. A slice is 32 bytes, so the default buffer is 8 MiB per thread. Covering this 30 s window on queue 0 would take about 2.5 M slices, around 80 MiB. **Proposal** (opt-in; defaults unchanged): 1. Report each drop in the summary, per thread and per reason. For example, `"trace_dropped":{"queue worker 0x0":{"events_after_s":3.32,"lost":2240000}}` for a full event buffer and a separate `"totals_full"` entry when the totals table overflows, so a reader knows whether the summary numbers are still complete. Also keep a plain boolean for existing readers (for example `trace_dropped_any`), or keep the boolean under its current name and add the detail as `trace_dropped_threads`. 2. Add an instant event `trace buffer full` on the thread at the time of its first lost slice, so Perfetto shows where the track ends. 3. Add `APS5_TRACE_EVENTS=<n>` to size the per-thread buffer (whole number, bounded, malformed value fails the first present, like the other trace switches), and document the memory cost in BUILD.md. 4. Optionally, have `tools/trace_digest.py` print the per-thread cut-off. I can send a PR for this, starting with 1 and 2, unless someone already has it in progress or the trace owners prefer a different shape (for example a ring that keeps the last N events instead of the first N).
eliyarson commented 2026-10-14 17:20:35 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by eliyarson on 2026-10-14T17:20:35Z.


Fixed by #5808 (APS5_TRACE_EVENTS) and #5813 (per-thread trace_dropped_threads and the trace buffer full event). The optional trace_digest.py cut-off (item 4) isn't done; I'm leaving that for whoever needs it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6174143374 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/5786#issuecomment-6174143374). Originally posted by [eliyarson](https://github.com/eliyarson) on 2026-10-14T17:20:35Z. --- Fixed by #5808 (`APS5_TRACE_EVENTS`) and #5813 (per-thread `trace_dropped_threads` and the `trace buffer full` event). The optional `trace_digest.py` cut-off (item 4) isn't done; I'm leaving that for whoever needs it.
Sign in to join this conversation.
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#5786
No description provided.