Title: [197588] trunk/Source/WebCore
Revision
197588
Author
[email protected]
Date
2016-03-04 13:56:46 -0800 (Fri, 04 Mar 2016)

Log Message

Max out timer throttling immediately for pre-render pages
https://bugs.webkit.org/show_bug.cgi?id=155038

Reviewed by Chris Dumez.

If a hidden page has never been visible, no need to gently ramp into throttling - treat it
the same as a page that has been viewed, but has been in the background for a long time.

Why? The throttling mechanism scales with the amount of background work by shifting the
limit - once all background pages have maxed out the limit, they should no longer be burden
of the system. However the mechanism doesn't currently do anything to accelerate towards
the limit based on the number of pages in the ramp up phase, and ramp up duration is
proportional to limit (so ramping up to a high limit takes a long time). So if you quickly
create a large number of hidden pages the system may be under excessive load for a while,
as we slowly ramp up to a limit that will adequately constrain resource consumption.
In cases where a large number of hidden pages are rapidly generated, many likely remain in
the pre-render state, so this mitigation should typically help.

* page/Page.cpp:
(WebCore::Page::updateDOMTimerAlignmentInterval):
    - if m_isPrerender then m_timerAlignmentInterval is set to the limit.
(WebCore::Page::setIsPrerender):
    - When this changes updateDOMTimerAlignmentInterval().

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (197587 => 197588)


--- trunk/Source/WebCore/ChangeLog	2016-03-04 21:48:33 UTC (rev 197587)
+++ trunk/Source/WebCore/ChangeLog	2016-03-04 21:56:46 UTC (rev 197588)
@@ -1,5 +1,31 @@
 2016-03-04  Gavin Barraclough  <[email protected]>
 
+        Max out timer throttling immediately for pre-render pages
+        https://bugs.webkit.org/show_bug.cgi?id=155038
+
+        Reviewed by Chris Dumez.
+
+        If a hidden page has never been visible, no need to gently ramp into throttling - treat it
+        the same as a page that has been viewed, but has been in the background for a long time.
+
+        Why? The throttling mechanism scales with the amount of background work by shifting the
+        limit - once all background pages have maxed out the limit, they should no longer be burden
+        of the system. However the mechanism doesn't currently do anything to accelerate towards
+        the limit based on the number of pages in the ramp up phase, and ramp up duration is
+        proportional to limit (so ramping up to a high limit takes a long time). So if you quickly
+        create a large number of hidden pages the system may be under excessive load for a while,
+        as we slowly ramp up to a limit that will adequately constrain resource consumption.
+        In cases where a large number of hidden pages are rapidly generated, many likely remain in
+        the pre-render state, so this mitigation should typically help.
+
+        * page/Page.cpp:
+        (WebCore::Page::updateDOMTimerAlignmentInterval):
+            - if m_isPrerender then m_timerAlignmentInterval is set to the limit.
+        (WebCore::Page::setIsPrerender):
+            - When this changes updateDOMTimerAlignmentInterval().
+
+2016-03-04  Gavin Barraclough  <[email protected]>
+
         Unify determination of page timer alignment
         https://bugs.webkit.org/show_bug.cgi?id=155031
 

Modified: trunk/Source/WebCore/page/Page.cpp (197587 => 197588)


--- trunk/Source/WebCore/page/Page.cpp	2016-03-04 21:48:33 UTC (rev 197587)
+++ trunk/Source/WebCore/page/Page.cpp	2016-03-04 21:56:46 UTC (rev 197588)
@@ -1244,11 +1244,20 @@
         break;
 
     case TimerThrottlingState::EnabledIncreasing:
-        ASSERT(m_timerThrottlingStateLastChangedTime);
-        double throttledDuration = monotonicallyIncreasingTime() - m_timerThrottlingStateLastChangedTime;
-        double minimumAlignmentInterval = std::max(DOMTimer::hiddenPageAlignmentInterval(), throttledDuration);
-        m_timerAlignmentInterval = std::min(minimumAlignmentInterval, m_timerAlignmentIntervalIncreaseLimit);
-        needsIncreaseTimer = m_timerAlignmentInterval < m_timerAlignmentIntervalIncreaseLimit;
+        // For pages in prerender state maximum throttling kicks in immediately.
+        if (m_isPrerender)
+            m_timerAlignmentInterval = m_timerAlignmentIntervalIncreaseLimit;
+        else {
+            ASSERT(m_timerThrottlingStateLastChangedTime);
+            m_timerAlignmentInterval = monotonicallyIncreasingTime() - m_timerThrottlingStateLastChangedTime;
+            // If we're below the limit, set the timer. If above, clamp to limit.
+            if (m_timerAlignmentInterval < m_timerAlignmentIntervalIncreaseLimit)
+                needsIncreaseTimer = true;
+            else
+                m_timerAlignmentInterval = m_timerAlignmentIntervalIncreaseLimit;
+        }
+        // Alignment interval should not be less than DOMTimer::hiddenPageAlignmentInterval().
+        m_timerAlignmentInterval = std::max(m_timerAlignmentInterval, DOMTimer::hiddenPageAlignmentInterval());
     }
 
     // If throttling is enabled, auto-increasing of throttling is enabled, and the auto-increase
@@ -1479,6 +1488,7 @@
 void Page::setIsPrerender()
 {
     m_isPrerender = true;
+    updateDOMTimerAlignmentInterval();
 }
 
 PageVisibilityState Page::visibilityState() const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to