Closed Bug 1476793 Opened 7 years ago Closed 7 years ago

Idle stacks in the JS Helper thread are not marked as idle

Categories

(Core :: Gecko Profiler, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
mozilla63
Tracking Status
firefox63 --- fixed

People

(Reporter: mstange, Assigned: mstange)

References

Details

Attachments

(1 file)

Bug 1405374 has added the ability for JS Helper threads to be profiled by the Gecko Profiler. However, the JS Helper threads currently cannot push label frames to the ProfilingStack, so they also cannot mark samples as belonging to the IDLE category. Once we have a thread activity graph in perf.html, this would cause the thread to look permanently active even when it's idle. The JS engine can't use tools/profiler/public/GeckoProfiler.h, but it *can* use the ProfilingStack (which is defined in js/public/ProfilingStack.h) - it just needs to get a pointer to the current thread's ProfilingStack. And with a bit more code duplication we can also give it RAII- and macro-based profiler label pushing.
Assignee: nobody → mstange
Status: NEW → ASSIGNED
Comment on attachment 8993141 [details] Bug 1476793 - Teach HelperThread how to push/pop profiler label frames, and use this capability to push an IDLE frame when the thread is idle. https://reviewboard.mozilla.org/r/257964/#review264860 ::: js/src/vm/HelperThreads.cpp:50 (Diff revision 1) > GlobalHelperThreadState* gHelperThreadState = nullptr; > > } // namespace js > > + > +// Macros used by the AUTO_PROFILER_* macros below. This comment was copied from GeckoProfiler.h, but isn't necessary here. However, it would be good to have a comment explaining that these macros are identical in function to the same-named ones in GeckoProfiler.h, but they are defined separately because SpiderMonkey can't use GeckoProfiler.h.
Attachment #8993141 - Flags: review?(n.nethercote) → review+
Priority: -- → P1
Comment on attachment 8993141 [details] Bug 1476793 - Teach HelperThread how to push/pop profiler label frames, and use this capability to push an IDLE frame when the thread is idle. https://reviewboard.mozilla.org/r/257964/#review265278 Excellent, thank you for doing the work here! ::: js/src/vm/HelperThreads.cpp:49 (Diff revision 2) > +// These macros are identical in function to the same-named ones in > +// GeckoProfiler.h, but they are defined separately because SpiderMonkey can't > +// use GeckoProfiler.h. > +#define PROFILER_RAII_PASTE(id, line) id ## line > +#define PROFILER_RAII_EXPAND(id, line) PROFILER_RAII_PASTE(id, line) > +#define PROFILER_RAII PROFILER_RAII_EXPAND(raiiObject, __LINE__) > +#define AUTO_PROFILER_LABEL(label, category) \ > + HelperThread::AutoProfilerLabel PROFILER_RAII(this, label, __LINE__, \ > + js::ProfilingStackFrame::Category::category) > + I will be happy when most of this stuff gets moved to mozglue... ::: js/src/vm/HelperThreads.cpp:1879 (Diff revision 2) > > JS::RegisterThreadCallback callback = HelperThreadState().registerThread; > if (callback) { > + profilingStack = > - callback("JS Helper", reinterpret_cast<void*>(GetNativeStackBase())); > + callback("JS Helper", reinterpret_cast<void*>(GetNativeStackBase())); > registered = true; Up to you -- do you prefer keeping the separate registered boolean, or just using profilingStack now? ::: js/src/vm/HelperThreads.cpp:2380 (Diff revision 2) > + if (profilingStack) { > + profilingStack->pushLabelFrame(label, nullptr, this, line, category); > + } Until we finally get around to consolidating coding styles, this shouldn't have braces. ::: js/src/vm/HelperThreads.cpp:2387 (Diff revision 2) > + if (profilingStack) { > + profilingStack->pop(); > + } nor this
Attachment #8993141 - Flags: review?(sphink) → review+
Comment on attachment 8993141 [details] Bug 1476793 - Teach HelperThread how to push/pop profiler label frames, and use this capability to push an IDLE frame when the thread is idle. https://reviewboard.mozilla.org/r/257964/#review265278 > Up to you -- do you prefer keeping the separate registered boolean, or just using profilingStack now? I removed the separate boolean.
Pushed by mstange@themasta.com: https://hg.mozilla.org/integration/autoland/rev/ada1690b63e9 Teach HelperThread how to push/pop profiler label frames, and use this capability to push an IDLE frame when the thread is idle. r=njn,sfink
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: