RESOLVED FIXED 224586
Use WTF::Function instead of std::function in SVGPropertyAnimatorFactory::attributeAnimatorCreator
https://bugs.webkit.org/show_bug.cgi?id=224586
Summary Use WTF::Function instead of std::function in SVGPropertyAnimatorFactory::att...
Alex Christensen
Reported 2021-04-14 16:29:28 PDT
Use WTF::Function instead of std::function in SVGPropertyAnimatorFactory::attributeAnimatorCreator
Attachments
Patch (22.75 KB, patch)
2021-04-14 16:35 PDT, Alex Christensen
no flags
Patch (22.73 KB, patch)
2021-04-14 19:17 PDT, Alex Christensen
no flags
Patch (21.94 KB, patch)
2021-04-15 10:00 PDT, Alex Christensen
no flags
Alex Christensen
Comment 1 2021-04-14 16:35:17 PDT
Geoffrey Garen
Comment 2 2021-04-14 16:39:36 PDT
Comment on attachment 426061 [details] Patch EWS too angry
Alex Christensen
Comment 3 2021-04-14 19:17:14 PDT
Darin Adler
Comment 4 2021-04-15 08:49:05 PDT
Comment on attachment 426068 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=426068&action=review > Source/WebCore/ChangeLog:9 > + sizeof(WTF::Function<void()>) is 8. > + sizeof(std::function<void()>) is 48. What about total memory use? I’m wondering if we should even allow std::function if it uses more memory, but maybe this is more about "what's in the top level of the object and what's on the heap"? > Source/WebCore/svg/properties/SVGPropertyAnimatorFactory.h:112 > + Pair { SVGNames::colorAttr->impl(), std::make_pair(SVGValueProperty<Color>::create, SVGPropertyAnimatorFactory::createColorAnimator) }, Is there a good reason we are using std::make_pair instead of just brace syntax? Could we make this even tighter?
Chris Dumez
Comment 5 2021-04-15 08:51:24 PDT
(In reply to Darin Adler from comment #4) > Comment on attachment 426068 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=426068&action=review > > > Source/WebCore/ChangeLog:9 > > + sizeof(WTF::Function<void()>) is 8. > > + sizeof(std::function<void()>) is 48. > > What about total memory use? I’m wondering if we should even allow > std::function if it uses more memory, but maybe this is more about "what's > in the top level of the object and what's on the heap"? > > > Source/WebCore/svg/properties/SVGPropertyAnimatorFactory.h:112 > > + Pair { SVGNames::colorAttr->impl(), std::make_pair(SVGValueProperty<Color>::create, SVGPropertyAnimatorFactory::createColorAnimator) }, > > Is there a good reason we are using std::make_pair instead of just brace > syntax? Could we make this even tighter? My understanding is that std::function tries to be smart about when to store the data inline or do a heap allocation. It makes this determination based on the size of the data. WTF::Function always does a heap allocation no matter the size of the data.
Alex Christensen
Comment 6 2021-04-15 10:00:10 PDT
Alex Christensen
Comment 7 2021-04-15 10:14:00 PDT
Comment on attachment 426112 [details] Patch I'm not sure about heap/inline memory use total, but I do know that inside a HashMap we want inline to be smaller.
Alex Christensen
Comment 8 2021-04-15 10:38:56 PDT
Darin Adler
Comment 9 2021-04-15 11:24:57 PDT
(In reply to Alex Christensen from comment #7) > I'm not sure about heap/inline memory use total, but I do know that inside a > HashMap we want inline to be smaller. Sure, but at a certain point for hash tables we will do that by putting the whole thing on the heap, not by building the capability into classes. For something we are using as widely as WTF::Function our lens should be broader than just suitability in hash tables.
Note You need to log in before you can comment on or make changes to this bug.