mozilla::MarkerThreadId::CurrentThread is slow
Categories
(Core :: Gecko Profiler, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox128 | --- | fixed |
People
(Reporter: julienw, Assigned: jcristau)
References
Details
(Whiteboard: [fxp] [sp3])
Attachments
(1 file)
I noticed a large profiler overhead in https://share.firefox.dev/3PRC02T while profiling a speedometer 3 workload.
From this profile, mozilla::MarkerThreadId::CurrentThread
seems to be very visible especially (in addition to the usual suspects around capturing a backtrace in a buffer).
According to padenot, we should look at using pthread_self
instead of gettid
(that does a syscall):
syscall(SYS_gettid) -- took: 513.187 ms [0.513187us per iteration]
pthread_self -- took: 0 ms [0us per iteration]
11044057845185138688
getttid -- took: 504.234 ms [0.504234us per iteration]
11044058531219138688
Updated•2 years ago
|
Reporter | ||
Comment 1•2 years ago
|
||
See also bug 1721569 which has some prior thoughts on this.
Updated•2 years ago
|
Comment 2•2 years ago
|
||
The severity field is not set for this bug.
:canova, could you have a look please?
For more information, please visit BugBot documentation.
Comment 3•11 months ago
|
||
I experimented using pthread_self
instead of gettid
at the time but stopped working on it after encountering some issues:
pthread_self
returns an opaque value as oppose togettid
. It might make it harder to see when we need the real tid number after capturing a profile.- If I remember correctly, it broke some things in the frontend. I was suspecting that the number wasn't getting serialized properly into the buffer.
Although second issue can be solved quickly, I still have doubts on the first one. Julien suggested that we could use a thread local storage for this as well to make the consecutive accesses a lot faster. It's worth experimenting with that.
Assignee | ||
Comment 4•11 months ago
|
||
Updated•11 months ago
|
Reporter | ||
Updated•11 months ago
|
Updated•11 months ago
|
Reporter | ||
Comment 5•9 months ago
|
||
Profiling: https://browserbench.org/Speedometer3.0/?iterationCount=20&suite=TodoMVC-Lit
Profile from latest central: https://share.firefox.dev/3QJdkJ8
Profile with the patch: https://share.firefox.dev/3wolcZX
We can clearly see that the syscall
function is much less present. Also the profiler category goes from 12% to 7.7% (-34%).
Reporter | ||
Comment 6•9 months ago
|
||
Nazım and I were curious about Android, so here is a profile on the same workload on firefox Nightly (build from May 8) on my Android phone (Android 12):
https://share.firefox.dev/4dCUzkA
It looks like all profiler-related syscall calls come from the backtrace capture, no gettid spotted there.
Comment 8•9 months ago
|
||
bugherder |
Description
•