Closed Bug 1367458 Opened 8 years ago Closed 7 years ago

TabGroup::IsBackground() takes 300ms in the content process with telemetry enabled when running

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla56
Performance Impact high
Tracking Status
firefox55 --- fixed
firefox56 --- fixed

People

(Reporter: ehsan.akhgari, Assigned: nika)

References

(Blocks 1 open bug)

Details

Attachments

(2 files, 1 obsolete file)

It is just too expensive. It needs to be cheaper please.
MozReview-Commit-ID: 9HVvV1omF8G
Attachment #8875828 - Flags: review?(ehsan)
Comment on attachment 8875828 [details] [diff] [review] Manage TabGroup::IsBackground passively to avoid Runnable overhead Review of attachment 8875828 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/base/TabGroup.cpp @@ +170,5 @@ > MOZ_ASSERT(mWindows.Contains(aWindow)); > mWindows.RemoveElement(aWindow); > > + if (!aWindow->IsBackground()) { > + mForegroundCount--; Please MOZ_DIAGNOSTIC_ASSERT(mForegroundCount > 0); before doing so. @@ +272,5 @@ > +{ > + MOZ_RELEASE_ASSERT(NS_IsMainThread()); > + > + if (aIsNowBackground) { > + MOZ_ASSERT(mForegroundCount > 0); I think this needs to be a diagnostic assert cause if we get this wrong we'll underflow... @@ +285,5 @@ > { > MOZ_RELEASE_ASSERT(NS_IsMainThread()); > > +#ifdef DEBUG > + uint32_t calculated = 0; Nit: how about calling this foregrounded? :-) ::: dom/base/nsGlobalWindow.cpp @@ +10616,2 @@ > bool resetTimers = (!aIsBackground && AsOuter()->IsBackground()); > + mIsBackground = aIsBackground; Do you mind please putting the if branch and the mIsBackground assignment in a helper? It seems like this and the nsGlobalWindow::SetDocShell() function above could use the helper directly which would be a bit less error prone. @@ +15179,5 @@ > MOZ_ASSERT_IF(testGroup, testGroup == toJoin); > #endif > > mTabGroup = mozilla::dom::TabGroup::Join(AsOuter(), toJoin); > + if (!mIsBackground) { per IRC conversation, this needs to move to Join().
Attachment #8875828 - Flags: review?(ehsan) → review-
MozReview-Commit-ID: 9HVvV1omF8G
Attachment #8875848 - Flags: review?(ehsan)
Attachment #8875828 - Attachment is obsolete: true
Comment on attachment 8875848 [details] [diff] [review] Manage TabGroup::IsBackground passively to avoid Runnable overhead Review of attachment 8875848 [details] [diff] [review]: ----------------------------------------------------------------- Thanks!
Attachment #8875848 - Flags: review?(ehsan) → review+
Pushed by michael@thelayzells.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/cc5a10e1d826 Manage TabGroup::IsBackground passively to avoid Runnable overhead, r=ehsan
I think this needs to be backported to beta.
Comment on attachment 8877249 [details] [diff] [review] BETA Manage TabGroup::IsBackground passively to avoid Runnable overhead Approval Request Comment [Feature/Bug causing the regression]: bug 1322184 [User impact if declined]: Slow computations of TabGroup::IsBackground used for Telemetry [Is this code covered by automated tests?]: It is used by every event dispatch [Has the fix been verified in Nightly?]: Just landed [Needs manual test from QE? If yes, steps to reproduce]: No [List of other uplifts needed for the feature/fix]: None [Is the change risky?]: medium-low risk [Why is the change risky/not risky?]: Changes hot code path to use cached value. Shouldn't have any security impact if caching gotten wrong. [String changes made/needed]: None
Attachment #8877249 - Flags: approval-mozilla-beta?
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
Comment on attachment 8877249 [details] [diff] [review] BETA Manage TabGroup::IsBackground passively to avoid Runnable overhead fix perf regression in 55, let's get this in 55b2
Attachment #8877249 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
(In reply to Michael Layzell [:mystor] from comment #8) > [Is this code covered by automated tests?]: It is used by every event > dispatch > [Has the fix been verified in Nightly?]: Just landed > [Needs manual test from QE? If yes, steps to reproduce]: No Setting qe-verify- based on Michael's assessment on manual testing needs.
Flags: qe-verify-
Component: DOM → DOM: Core & HTML
Performance Impact: --- → P1
Whiteboard: [qf:p1]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: