Open Bug 1574815 Opened 5 years ago Updated 2 years ago

Profiling on Windows cannot effectively have a sampling interval smaller than 2ms

Categories

(Core :: Gecko Profiler, defect, P3)

defect

Tracking

()

People

(Reporter: mozbugz, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

Looking at Windows profiles, usually captured with the default 1ms interval, the actual interval between samples is actually around 2ms.

It would be interesting to know why that is, and fix it if possible.

(In the meantime, I'll open a separate bug to change the default to 2ms, to reflect what can actually be achieved.)

Sleep(1) on Windows usually sleeps around 1.8ms. We haven't found a way to sleep for a shorter time than that, other than busy-looping.
Some native Windows profilers use a kernel driver for this, see bug 1379286.

Thank you Markus.

I see that setting an interval strictly smaller than 1ms uses a busy loop:
https://searchfox.org/mozilla-central/rev/5912f376ab6a17afcba2b7654586013158ed64b5/tools/profiler/core/platform-win32.cpp#235-238

I'll do some measuring and see if we could use that busy loop to make 1ms work as it should. But in that case, we may still want to make 2ms the default (bug 1574816) to avoid using running that busy loop unless the user really wants to.

That sounds fine. But please make the "overhead" scale in the popup jump into the red zone when a busy loop interval is selected. With multiple processes, running one busy loop per process really kills us. It would be more palatable if we had a central sampling scheduler thread across all processes.

Oh, and there needs to be migration code that moves an existing 1ms setting to 2ms, we don't want to suddenly start hanging people's machines due to an old default setting.

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.