New issue
Advanced search Search tips

Issue 692906 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Task

Blocking:
issue 670534



Sign in to add a comment

Add UMA for CPU/power/memory usage of workers.

Project Member Reported by falken@chromium.org, Feb 16 2017

Issue description

We want to understand how much power and memory workers use.

From an internal thread:
"Regarding memory, it's hard to measure the memory usage of a service worker in general because many things are shared among all threads in the renderer process. On the other hand, it's possible to measure some specific things like v8::Isolate's heap consumption, memory usage of Resources fetched by a service worker etc."

"Using CPU-usage as a proxy for power, our metrics[1] are still mainly focused on the renderer main thread. [...] we do have a worker scheduler[2] but it's pretty simplistic. It wouldn't be too hard to extend it to log some worker-specific CPU metrics."

[1] RendererScheduler.ForegroundRendererMainThreadLoad
[2] https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/scheduler/child/worker_scheduler_impl.h?rcl=0&l=18


 
Blocking: 670534
Components: Blink>Scheduling
This would be useful for experimenting/evaluating a task throttling/suspension mechanism that may be introduced (see  issue 670534 ).
Cc: skyos...@chromium.org altimin@chromium.org

Comment 4 by kinuko@chromium.org, Mar 17 2017

Cc: nhiroki@chromium.org falken@chromium.org haraken@chromium.org
I tried to add ThreadLoadTracker in WorkerScheduerImpl and have run it locally for a while to see how it'd look, but I started to wonder it might not be what we want to collect.

Workers or ServiceWorkers are basically created when the page needs it, and then killed / closed after they are no longer needed, therefore if we just measure load by 'task run time' / 'thread uptime' this often ends up around 100%.  We probably want to use different denominator, say, renderer process uptime or something akin, and maybe also should expect that it can go higher than 100% in case there're multiple worker threads running all the time? Any thoughts?

I'd personally interested in seeing (task run time on a worker thread / task run time on the main thread).

Sami and Altimin might have ideas.

Hmm. Maybe would it make more sense to add (task run time on thread X / task run time on all threads)?

I guess what we want to understand is how much time/power of the renderer process is going on what thread.

Comment 7 by kinuko@google.com, Mar 17 2017

Dividing by the task run time of the different thread feels a bit weird to me.. #6 makes more sense and could be interesting to collect but it doesn't seem to give us good info about how busy the process was by itself.
#4: Yes, ThreadLoadTracker was designed with main thread in mind and is not a perfect match for workers. However, even with 100% load being the most common scenario, this data is still useful: by looking at the number of samples we will get worker CPU usage / main thread CPU usage ratio.
Right, I think we basically want some top level breakdown of how CPU time is distributed between the main thread and the worker thread.

What kind of insight/decisions are we hoping to get out of this data and what would we need to collect in order to do that?
I think that we can make this a part of per-task type metrics ( crbug.com/702318 ) with special *Worker task types.
#8: Ok, that's true that # of samples can give us some important meta data too. I can re-polish my patch and put it up for review then.
Project Member

Comment 12 by bugdroid1@chromium.org, Mar 24 2017

NextAction: 2017-03-28
Will wait for a few days, see UMA stats to decide good ReportingInterval and will land the other CL.
NextAction: ----
Owner: altimin@chromium.org
So now we have stats from Stable branch.  Roughly 98.92% sample logs 0% load (i.e. went idle for 98.92%) while roughly 0.35% sample marks 100% load.  Interval rate is 1 sec (while renderer scheduler's interval is 1 min).

Comparing sample numbers for renderers and workers (by multiplying the renderer samples by 60) worker loads are more sampled than renderers, though interval diffs might be introducing some skews / for workers we don't filter out 30+ sec tasks.

Let me tentatively re-assign this to altimin@ so that he can analyze the stats further.  I think possible next steps could be to breakdown workloads by worker types.

Comment 18 by ojan@chromium.org, Jun 26 2017

I think measuring is useful so we can see the amount of impact. But we should throttle worker types that we can associate with a frame/tab when we throttle the frame/tab regardless of what the metrics show us as today's impact. The worker shouldn't be a loophole where a page can use a lot of a user's battery.

The exception to this is workers that are shared across frames/pages (SharedWorker and ServiceWorker are the only ones, right?). For SharedWorker we should only throttle it if all the tabs talking to it are backgrounded. For ServiceWorker, I don't think we should throttle just for principle, but we might need to if we encounter abuses in the wild.

If we wait until there are significant abuses in the wild, it will be harder to curb it then because more people will have built code depending on workers not being throttled, particularly as we get more aggressive about throttling the main thread. They will be extra upset if they move to a worker and then that gets throttled later and there site breaks twice.

Comment 19 by ojan@chromium.org, Jun 26 2017

Cc: ojan@chromium.org
Labels: -Pri-2 -M-58 Pri-3
Labels: -Type-Bug Type-Task
Owner: ----
Status: Available (was: Assigned)
CPU usage is measured now in RendererScheduler.TaskDurationPerThreadType and RendererScheduler.TaskDurationPerTaskType.DedicatedWorker histograms.

Also we believe that it's a good approximation for power usage.

Marking it as available to see if anyone wants to look into memory usage.

Comment 22 by ojan@chromium.org, May 8 2018

Cc: -ojan@chromium.org

Sign in to add a comment