Bug 214866 - Profiler resolution is too low
Summary: Profiler resolution is too low
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: Safari 13
Hardware: Mac Unspecified
: P2 Enhancement
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-07-28 01:53 PDT by Radek Pietruszewski
Modified: 2021-03-13 23:57 PST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Radek Pietruszewski 2020-07-28 01:53:11 PDT
Hi. It appears that the Safari/webkit web inspector profiler samples stack traces approximately every 1ms. This is slow, and not suitable for many profiling tasks, since I'm only going to get a handful of samples when trying to hit 60fps, or react to an event in 50ms. By comparison, it appears that Chrome's Timeline profiler samples stacks every 100us.

Is there a technical reason why WebKit's profiler can't go up to 10kHz? If there's a tradeoff (slow processing, significantly degraded performance), can this be made configurable?
Comment 1 Radar WebKit Bug Importer 2020-07-28 16:59:24 PDT
<rdar://problem/66245375>
Comment 2 Saam Barati 2020-07-28 18:23:52 PDT
(In reply to radexpl from comment #0)
> Hi. It appears that the Safari/webkit web inspector profiler samples stack
> traces approximately every 1ms. This is slow, and not suitable for many
> profiling tasks, since I'm only going to get a handful of samples when
> trying to hit 60fps, or react to an event in 50ms. By comparison, it appears
> that Chrome's Timeline profiler samples stacks every 100us.
> 
> Is there a technical reason why WebKit's profiler can't go up to 10kHz? If
> there's a tradeoff (slow processing, significantly degraded performance),
> can this be made configurable?

Last time I measured this it did negatively impact performance of the script being run, and we were trying to find a balance where we didn't introduce so much perturbation that the samples you got were unrepresentative.

I also remember it being difficult to be woken up reliably in 100us.

However, this was a long time ago. We should check again the impact of increasing the resolution.
Comment 3 Radek Pietruszewski 2021-03-13 23:57:44 PST
Hi Saam! I wanted to bump this thread and ask again whether it's possible to increase WebKit's profiler resolution -- or at least make it a configurable option.

I've just upgraded my Mac to an M1 machine, which exacerbates the issue even more -- the faster a dev machine is, the fewer samples for analysis I get.

BTW: I'm not very familiar with the ins and outs of sampling profiling, but I do wonder if instead of being a hardcoded timer, the profiler sampler rate shouldn't be calculated/estimated off of CPU's speed - so that a program would get roughly the same number of samples regardless of how fast a machine is.