RESOLVED FIXED 216190
[MotionMark] RenderLayer::paintLayerContents spends ~5% of the time in MonotonicTime::now() in Multiply
https://bugs.webkit.org/show_bug.cgi?id=216190
Summary [MotionMark] RenderLayer::paintLayerContents spends ~5% of the time in Monoto...
Wenson Hsieh
Reported 2020-09-04 14:09:43 PDT
See: PaintFrequencyTracker::begin()
Attachments
Patch (4.94 KB, patch)
2020-09-04 15:24 PDT, Wenson Hsieh
no flags
Patch (6.41 KB, patch)
2020-09-04 15:25 PDT, Wenson Hsieh
simon.fraser: review-
v2 (8.72 KB, patch)
2020-09-04 17:51 PDT, Wenson Hsieh
no flags
v3 (for EWS) (12.50 KB, patch)
2020-09-04 22:02 PDT, Wenson Hsieh
no flags
v3 (with test fix) (12.54 KB, patch)
2020-09-05 16:26 PDT, Wenson Hsieh
no flags
Wenson Hsieh
Comment 1 2020-09-04 15:24:12 PDT Comment hidden (obsolete)
Wenson Hsieh
Comment 2 2020-09-04 15:24:48 PDT
Comment on attachment 408031 [details] Patch (Wrong patch :|)
Wenson Hsieh
Comment 3 2020-09-04 15:25:27 PDT
Said Abou-Hallawa
Comment 4 2020-09-04 15:35:35 PDT
Comment on attachment 408032 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=408032&action=review > Source/WebCore/rendering/RenderLayer.cpp:4632 > + SinglePaintFrequencyTracking singlePaintFrequencyTracking(m_paintFrequencyTracker, FrameView::currentPaintTimeStamp() ?: MonotonicTime::now(), shouldPaintContent); FrameView::currentPaintTimeStamp() ?: MonotonicTime::now() Does this change compile?
Simon Fraser (smfr)
Comment 5 2020-09-04 15:44:50 PDT
Comment on attachment 408032 [details] Patch This all relies on sCurrentPaintTimeStamp which is updated from FrameView::willPaintContents(), but there can be paints that don't hit FrameView::willPaintContents() in they only touch non-main compositing layers.
Simon Fraser (smfr)
Comment 6 2020-09-04 15:45:35 PDT
^ if they only It might also be fine to use the timestamp of the last Page::updateRendering() that maybe we stash somewhere?
Wenson Hsieh
Comment 7 2020-09-04 16:14:10 PDT
(In reply to Simon Fraser (smfr) from comment #6) > ^ if they only > > It might also be fine to use the timestamp of the last > Page::updateRendering() that maybe we stash somewhere? Sounds good! I’ll update this to stash a timestamp on `Page` in `Page::finalizeRenderingUpdate`, and then consult this timestamp in `RenderLayer::paintLayerContents`.
Wenson Hsieh
Comment 8 2020-09-04 17:51:40 PDT
Wenson Hsieh
Comment 9 2020-09-04 22:02:47 PDT
Created attachment 408065 [details] v3 (for EWS)
Wenson Hsieh
Comment 10 2020-09-05 14:30:08 PDT
Thanks for taking a look! Since EWS doesn’t run debug WK2 tests, I figured I’d run them locally before landing. In doing so, I discovered that this actually causes the test "http/tests/security/navigate-when-restoring-cached-page.html" to assert underneath `PaintFrequencyTracker::end()`: Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 com.apple.JavaScriptCore 0x0000000137fa24fe WTFCrash + 14 (Assertions.cpp:295) 1 com.apple.WebCore 0x000000011ad9911b WTFCrashWithInfo(int, char const*, char const*, int) + 27 (Assertions.h:671) 2 com.apple.WebCore 0x000000011f10a58b WebCore::PaintFrequencyTracker::end() + 107 (PaintFrequencyTracker.h:70) 3 com.apple.WebCore 0x000000011f10a51a WebCore::SinglePaintFrequencyTracking::~SinglePaintFrequencyTracking() + 42 (PaintFrequencyTracker.h:99) 4 com.apple.WebCore 0x000000011f0c53e5 WebCore::SinglePaintFrequencyTracking::~SinglePaintFrequencyTracking() + 21 (PaintFrequencyTracker.h:97) 5 com.apple.WebCore 0x000000011f0c060a WebCore::RenderLayer::paintLayerContents(WebCore::GraphicsContext&, WebCore::RenderLayer::LayerPaintingInfo const&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>) + 4442 (RenderLayer.cpp:4779) 6 com.apple.WebCore 0x000000011f0bf42d WebCore::RenderLayer::paintLayerContentsAndReflection(WebCore::GraphicsContext&, WebCore::RenderLayer::LayerPaintingInfo const&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>) + 445 (RenderLayer.cpp:4413) 7 com.apple.WebCore 0x000000011f0be2fa WebCore::RenderLayer::paintLayerWithEffects(WebCore::GraphicsContext&, WebCore::RenderLayer::LayerPaintingInfo const&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>) + 1370 (RenderLayer.cpp:4395) 8 com.apple.WebCore 0x000000011f0bd460 WebCore::RenderLayer::paintLayer(WebCore::GraphicsContext&, WebCore::RenderLayer::LayerPaintingInfo const&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>) + 368 (RenderLayer.cpp:4330) 9 com.apple.WebCore 0x000000011f0c3ec8 WebCore::RenderLayer::paintList(WebCore::RenderLayer::LayerList, WebCore::GraphicsContext&, WebCore::RenderLayer::LayerPaintingInfo const&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>) + 200 (RenderLayer.cpp:4831) 10 com.apple.WebCore 0x000000011f0c015b WebCore::RenderLayer::paintLayerContents(WebCore::GraphicsContext&, WebCore::RenderLayer::LayerPaintingInfo const&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>) + 3243 (RenderLayer.cpp:4729) 11 com.apple.WebCore 0x000000011f0bf42d WebCore::RenderLayer::paintLayerContentsAndReflection(WebCore::GraphicsContext&, WebCore::RenderLayer::LayerPaintingInfo const&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>) + 445 (RenderLayer.cpp:4413) 12 com.apple.WebCore 0x000000011f0be2fa WebCore::RenderLayer::paintLayerWithEffects(WebCore::GraphicsContext&, WebCore::RenderLayer::LayerPaintingInfo const&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>) + 1370 (RenderLayer.cpp:4395) 13 com.apple.WebCore 0x000000011f0bd460 WebCore::RenderLayer::paintLayer(WebCore::GraphicsContext&, WebCore::RenderLayer::LayerPaintingInfo const&, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>) + 368 (RenderLayer.cpp:4330) 14 com.apple.WebCore 0x000000011f0bd162 WebCore::RenderLayer::paint(WebCore::GraphicsContext&, WebCore::LayoutRect const&, WebCore::LayoutSize const&, WTF::OptionSet<WebCore::PaintBehavior>, WebCore::RenderObject*, WTF::OptionSet<WebCore::RenderLayer::PaintLayerFlag>, WebCore::RenderLayer::SecurityOriginPaintPolicy, WebCore::EventRegionContext*) + 386 (RenderLayer.cpp:4188) 15 com.apple.WebCore 0x000000011e769a2a WebCore::FrameView::paintContents(WebCore::GraphicsContext&, WebCore::IntRect const&, WebCore::Widget::SecurityOriginPaintPolicy, WebCore::EventRegionContext*) + 1930 (FrameView.cpp:4320) 16 com.apple.WebCore 0x000000011e9cc8d4 WebCore::ScrollView::paint(WebCore::GraphicsContext&, WebCore::IntRect const&, WebCore::Widget::SecurityOriginPaintPolicy, WebCore::EventRegionContext*) + 740 (ScrollView.cpp:1277) 17 com.apple.WebCore 0x000000011e769287 WebCore::FrameView::traverseForPaintInvalidation(WebCore::GraphicsContext::PaintInvalidationReasons) + 263 (FrameView.cpp:4175) 18 com.apple.WebCore 0x000000011e76917a WebCore::FrameView::invalidateControlTints() + 26 (FrameView.h:659) 19 com.apple.WebCore 0x000000011e7482ea WebCore::FrameView::updateControlTints() + 218 (FrameView.cpp:4159) 20 com.apple.WebCore 0x000000011e747bc3 WebCore::FocusController::setActiveInternal(bool) + 99 (FocusController.cpp:912) 21 com.apple.WebCore 0x000000011e747aec WebCore::FocusController::setActivityState(WTF::OptionSet<WebCore::ActivityState::Flag>) + 236 (FocusController.cpp:896) 22 com.apple.WebCore 0x000000011e7c511b WebCore::Page::setActivityState(WTF::OptionSet<WebCore::ActivityState::Flag>) + 219 (Page.cpp:2106) 23 com.apple.WebKit 0x000000010d08a060 WebKit::WebPage::setActivityState(WTF::OptionSet<WebCore::ActivityState::Flag>, unsigned long long, WTF::Vector<WebKit::CallbackID, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc> const&) + 672 (WebPage.cpp:3286) 24 com.apple.WebKit 0x000000010d089a07 WebKit::WebPage::reinitializeWebPage(WebKit::WebPageCreationParameters&&) + 679 (WebPage.cpp:844) 25 com.apple.WebKit 0x000000010cb93ac6 WebKit::WebProcess::createWebPage(WTF::ObjectIdentifier<WebCore::PageIdentifierType>, WebKit::WebPageCreationParameters&&) + 342 (WebProcess.cpp:723) It looks like Page::updateRendering() hadn’t been called yet when we try to paint while updating control tints, so the timestamp we pass to SinglePaintFrequencyTracking ends up being 0.
Wenson Hsieh
Comment 11 2020-09-05 14:39:34 PDT
> It looks like Page::updateRendering() hadn’t been called yet when we try to > paint while updating control tints, so the timestamp we pass to > SinglePaintFrequencyTracking ends up being 0. I think I can fix this by making not tracking paint frequency for paints that are just for paint invalidation (i.e., `GraphicsContext` contains `m_paintInvalidationReasons`)...
Wenson Hsieh
Comment 12 2020-09-05 16:26:25 PDT
Created attachment 408103 [details] v3 (with test fix)
EWS
Comment 13 2020-09-05 18:36:16 PDT
Committed r266677: <https://trac.webkit.org/changeset/266677> All reviewed patches have been landed. Closing bug and clearing flags on attachment 408103 [details].
Radar WebKit Bug Importer
Comment 14 2020-09-05 18:37:15 PDT
Note You need to log in before you can comment on or make changes to this bug.