Optimize PROFILER_MAIN_THREAD_LABEL

NEW
Assigned to

Status

()

Core
Gecko Profiler
4 years ago
4 years ago

People

(Reporter: BenWa, Assigned: jerry)

Tracking

Trunk
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

4 years ago
Currently PROFILER_MAIN_THREAD_LABEL is implemented as an assert that it really is on the main thread THEN it falls back to the non main thread. We should implement it to properly avoid the TLS lookup and replace PROFILER_LABEL where we can easily confirm that this code is main thread only (most of gecko/layout code).

http://mxr.mozilla.org/mozilla-central/source/tools/profiler/GeckoProfilerImpl.h#233
(Assignee)

Comment 1

4 years ago
If we call PROFILER_MAIN_THREAD_LABEL() in non-main-thread with release build, it stills save the data into TLS PseudoStack. Is my thought right?
Should we assert when we call PROFILER_MAIN_THREAD_LABEL() in non-main-thread?
(Reporter)

Comment 2

4 years ago
If we avoid the TLS and add this on the wrong thread then we'll be modifying the wrong thread' state and exposing ourself to data races. An assertion should be enough here.
(Assignee)

Comment 3

4 years ago
Hi Benwa,

In mozilla_sampler_init(),
http://dxr.mozilla.org/mozilla-central/source/tools/profiler/platform.cpp#440
if we pass tls and non-tls pseudo stack to RegisterCurrentThread(), we also need to modify all series of profiler related function into two version(tls and non-tls version).
For example, we should modify the set_tls_stack_top() function in RegisterCurrentThread() into two version.
Is it true?
You need to log in before you can comment on or make changes to this bug.