nsRFPService::ReduceTimePrecisionImpl is slow
Categories
(Core :: Security, defect, P2)
Tracking
()
People
(Reporter: smaug, Unassigned)
References
Details
(Keywords: perf:responsiveness)
Reporter | ||
Updated•4 years ago
|
Reporter | ||
Comment 1•4 years ago
|
||
Dealing with timestamps should be very fast, but looks like ReduceTimePrecisionImpl ends up even doing allocations.
Reporter | ||
Updated•4 years ago
|
Reporter | ||
Updated•4 years ago
|
Reporter | ||
Comment 3•4 years ago
|
||
https://share.firefox.dev/34EK2EC
https://farre.github.io/web-tools/rIC/index.html is a testcase.
Ensure "Show total allotted remaining time per update" and
"Use requestAnimationFrame" and
"Respect time remaining" are checked
and "Time to spend in idle callback" is 10
and click Toggle
Reporter | ||
Comment 4•4 years ago
•
|
||
In that test it is expected that lots of time is spent in TimeRemaining, but looks like nsRFPService::ReduceTimePrecisionImpl is adding
quite a bit overhead there.
Is it RandomMidpoint calls which are slow? They are using a lock(!) in this super hot code path.
Comment 5•4 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #4)
In that test it is expected that lots of time is spent in TimeRemaining, but looks like nsRFPService::ReduceTimePrecisionImpl is adding
quite a bit overhead there.
Is it RandomMidpoint calls which are slow? They are using a lock(!) in this super hot code path.
I'm not very great at using the profiler but I would expect that - yes. https://bugzilla.mozilla.org/show_bug.cgi?id=1655777#c9 has some suggestions for narrowing down what part of the code the issue is in.
We could probably just remove the lock. We might hit race conditions: the impact of doing so would mean that individual timestamps might be jittered using the incorrect random values. But it would be very difficult for an attacker to control this, determine if it happened, or actually exploit this in a meaningful way. We could also look at the possibility of removing jitter entirely....
Comment 6•4 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #3)
https://share.firefox.dev/34EK2EC
https://farre.github.io/web-tools/rIC/index.html is a testcase.
Ensure "Show total allotted remaining time per update" and
"Use requestAnimationFrame" and
"Respect time remaining" are checked
and "Time to spend in idle callback" is 10
and click Toggle
I'm not so sure if I read the profiler correctly, but from this, I found there are some mozilla::detail::MutexImpl::lock
above some nsRFPService::ReduceTimePrecisionImpl
calls. And the only place which uses mutex lock in ReduceTimePrecision
is RandomMidpoint
.
Updated•4 years ago
|
Reporter | ||
Comment 7•4 years ago
|
||
https://bugzilla.mozilla.org/show_bug.cgi?id=1686930 is another instance, there this shows up really badly.
Reporter | ||
Comment 9•4 years ago
|
||
I profiled https://farre.github.io/web-tools/rIC/index.html again and it looked fine.
Updated•4 years ago
|
Reporter | ||
Comment 10•3 years ago
|
||
(hmm, why the needinfo wasn't cleared in comment 9)
Updated•3 years ago
|
Description
•