RESOLVED INVALID 201412
[FTW] Cache Gradients in the WebContent process
https://bugs.webkit.org/show_bug.cgi?id=201412
Summary [FTW] Cache Gradients in the WebContent process
Brent Fulgham
Reported 2019-09-02 18:29:26 PDT
Profiling shows that creating Gradient brushes are one of the highest remaining hot spots in MotionMark runs, especially in Suits. This benchmark ends up applying one of a set of gradients to different elements, and creating and destroying these gradient brushes each time we paint is hugely wasteful. This patch adds a local cache to the Direct2D Gradient object that caches the constructed gradient.
Attachments
Patch (4.73 KB, patch)
2019-09-02 19:22 PDT, Brent Fulgham
andersca: review-
Brent Fulgham
Comment 1 2019-09-02 19:22:36 PDT
Brent Fulgham
Comment 2 2019-09-02 23:12:18 PDT
Sadly, this change showed no improvement when A/B testing Motion ark. :(
Anders Carlsson
Comment 3 2019-09-03 13:43:42 PDT
Comment on attachment 377869 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=377869&action=review Probably worth coming up with a cache eviction strategy - otherwise the hash maps will just grow indefinitely. > Source/WebCore/platform/graphics/win/GradientDirect2D.cpp:59 > +static HashMap<unsigned, COMPtr<ID2D1LinearGradientBrush>> linearGradients; > +static HashMap<unsigned, COMPtr<ID2D1RadialGradientBrush>> radialGradients; These will introduce global constructors. > Source/WebCore/platform/graphics/win/GradientDirect2D.cpp:85 > + unsigned hash = this->hash(); It's not enough to just use the hash value here. If two different gradients happens to hash to the same value, one of them will get the wrong brush. > Source/WebCore/platform/graphics/win/GradientDirect2D.cpp:98 > + m_gradient->AddRef(); Seems like it would be better if PlatformGradient was a COMPtr; that would get rid of the manual memory management here.
Note You need to log in before you can comment on or make changes to this bug.