As discussed, I've added queue_time to TaskTimeObserver::DidProcessTask and removed base::TaskObserver from the LoAF monitor, so the worker congestion monitor uses a single task observer to get the queue time. PTAL.
// base::TaskObserver. Captures each task's scheduled start time (queue_time /Scott HaseleyMaybe we can add queue_time to TaskTimeObserver instead? WDYT @shas...@chromium.org
Joone HurSounds reasonable to me. I guess the caveat is it's not always set, but probably fine to document given GetDesiredExecutionTime() has the same behavior.
It would be good to use one or the other rather than a different type of observer for main vs. worker, if possible. IIRC the main difference is TaskTimeObserver ignores tasks that run in nested run loops, which should only affect the main thread (% devtools pausing, I think).
Done
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
LG % a few comments. I'll wait for Noam to take another pass, but the guts of it LG.
TimeTicks queue_time) = 0;Can we rename this:
```suggestion
TimeTicks desired_execution_time) = 0;
```
given it maps to `GetDesiredExecutionTime()`?
FinalizeCongestedMoment();Will this entry be consumed by anything? I think the worker will stop running tasks after this?
// A congested moment is an interval during which the task queue staysnit: there are multiple task queues with different priorities, so "the task queue" is a bit of a simplification. It's probably worth rephrasing (here and below), and I think it's find, but please double-check that this matches the model you're using here (i.e. `desired_execution_time` of `task_N+1` can be less than `desired_execution_time` of `task_N`).
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
Really nice work.
I would want to see how the processing model looks like in the spec, but iterating on top of this prototype seems good.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +1 |
Will this entry be consumed by anything? I think the worker will stop running tasks after this?
You're right. Shutdown() is only called from WorkerGlobalScope::Dispose(), so this entry can never be consumed. I'll remove this call.
// A congested moment is an interval during which the task queue staysnit: there are multiple task queues with different priorities, so "the task queue" is a bit of a simplification. It's probably worth rephrasing (here and below), and I think it's find, but please double-check that this matches the model you're using here (i.e. `desired_execution_time` of `task_N+1` can be less than `desired_execution_time` of `task_N`).
As you suggested, I reworded the comment to avoid the "the task queue" simplification (it now describes the thread staying saturated with pending work).
As far as I understand, task_N+1's desired execution time can be earlier than task_N's (different priorities, or a delayed setTimeout task). To handle this, the code uses `std::min(scheduled, prev_scheduled_start_)` for the interval start.
The current model should work, but I'll continue to verify this when I extend congested moments to the main thread.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
Can we rename this:
```suggestion
TimeTicks desired_execution_time) = 0;
```given it maps to `GetDesiredExecutionTime()`?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Exportable changes to web-platform-tests were detected in this CL and a pull request in the upstream repo has been made: https://github.com/web-platform-tests/wpt/pull/61673.
When this CL lands, the bot will automatically merge the PR on GitHub if the required GitHub checks pass; otherwise, ecosystem-infra@ team will triage the failures and may contact you.
WPT Export docs:
https://chromium.googlesource.com/chromium/src/+/main/docs/testing/web_platform_tests.md#Automatic-export-process
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
LoAF: Report worker congestion from a saturated task queue
The Long Animation Frame (LoAF) API today reports only individual long
tasks in Web Workers. A worker's event loop can also be saturated by a
flood of consecutive short tasks: no single task is long enough to be
reported on its own, but together they keep the loop busy past the 200ms
congestion threshold. This congestion is invisible to developers even
though it blocks the worker just as effectively as a single long task.
This CL lets the LoAF API detect such congestion in a Web Worker and
report it as a long-animation-frame entry. Congestion is detected by
queuing delay: a task that was already scheduled before the previous
task started running means two tasks were queued at once (backlog depth
>= 2). This is what separates real congestion from a steady async
iteration, which keeps the loop busy without ever building a backlog and
must not be reported.
Once a congested moment opens, consecutive tasks are folded into a
single saturated interval for as long as the thread does not actually go
idle between them. The interval ends when the queue drains (a real idle
gap), and is reported once as a single entry covering the whole
interval.
For a congestion entry, scriptCount counts every top-level script entry
point folded into the interval even when scripts[] is empty (each task
is under the 5ms attribution threshold), and blockingDuration is the
span beyond the 200ms threshold.
The behavior is gated behind the LongAnimationFrameWorker flag, so
default behavior is unchanged. Main-thread congestion is handled in a
separate CL.
Run with --enable-blink-features=LongAnimationFrameWorker.
Design Doc:
https://docs.google.com/document/d/13tERlM0Cd8gKUDC01-lQeW4oNllKs4AKdEGw41bnH4k/edit?usp=sharing
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
The WPT PR for this CL has been merged upstream! https://github.com/web-platform-tests/wpt/pull/61673
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |