Bug 60625

Summary: Cleanup RenderSVGPath to offer a non-marker variant
Product: WebKit Reporter: Rob Buis <rwlbuis>
Component: SVGAssignee: Rob Buis <rwlbuis>
Status: RESOLVED WONTFIX    
Severity: Normal CC: eric, krit, pdr, webkit.review.bot, zimmermann
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch eric: review-

Rob Buis
Reported 2011-05-11 07:16:00 PDT
The marker layout info takes a lot of space but is not always needed, for instance for <circle>, <ellipse> and <rect>. So redesign to minimize memory usage in those cases.
Attachments
Patch (11.62 KB, patch)
2011-05-11 13:42 PDT, Rob Buis
no flags
Patch (5.00 KB, patch)
2012-05-08 09:03 PDT, Rob Buis
no flags
Patch (5.22 KB, patch)
2012-05-08 12:20 PDT, Rob Buis
eric: review-
Rob Buis
Comment 1 2011-05-11 13:42:01 PDT
Dirk Schulze
Comment 2 2011-05-11 14:01:46 PDT
Comment on attachment 93173 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=93173&action=review I'm not happy about the virtual functions. They are unnecessary for rect, circle and co. Rob will test if transforming SVGMarkerLayoutInfo m_markerLayoutInfo to an OwnPtr could be an compromise. r- for the meantime. > Source/WebCore/rendering/svg/RenderSVGPath.h:69 > + virtual FloatRect calculateMarkerBoundsIfNeeded() { return FloatRect(); } the '&' is on the wrong place. Doesn't match webkit style. > Source/WebCore/rendering/svg/RenderSVGPath.h:109 > + OwnPtr<SVGMarkerLayoutInfo> &markerLayoutInfo() Ditto.
Rob Buis
Comment 3 2012-05-08 09:03:21 PDT
Build Bot
Comment 4 2012-05-08 09:30:18 PDT
Eric Seidel (no email)
Comment 5 2012-05-08 10:47:37 PDT
If you're trying to reduce the size of RenderSVGShape, seems you should add a COMPILE_ASSERT to verify that it never gets bigger again. We could also just make it OwnPtr<MarkerInfo> instead. I'm not sure the global hash is necessary.
Eric Seidel (no email)
Comment 6 2012-05-08 10:48:30 PDT
I guess what I'm saying is that I don't view this as a "Cleanup". This is not making the code cleaner. It is possibly saving memory in teh common case, but it's making the code harder to follow. The question is if that complexity is worth it.
Rob Buis
Comment 7 2012-05-08 10:56:25 PDT
Hi Eric, (In reply to comment #6) > I guess what I'm saying is that I don't view this as a "Cleanup". This is not making the code cleaner. It is possibly saving memory in teh common case, but it's making the code harder to follow. The question is if that complexity is worth it. Sure, mostly putting the patch up for discussion, I do think markers are rare and the way we now always allocate it is suboptimal though. Cheers, Rob.
Nikolas Zimmermann
Comment 8 2012-05-08 11:09:42 PDT
Comment on attachment 140725 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=140725&action=review Nice approach in general! Some nitpicks: > Source/WebCore/rendering/svg/RenderSVGShape.cpp:58 > +typedef HashMap<const RenderSVGShape*, SVGMarkerLayoutInfo*> MarkerLayoutInfoMap; > +static MarkerLayoutInfoMap* gMarkerLayoutInfoMap = 0; Why don't you keep this in the getMarkerLayoutInfo method, and make it static?? Also it should keep OwnPtr<SVGMarkerLayoutInfo>, this is possible in trunk since a while. > Source/WebCore/rendering/svg/RenderSVGShape.cpp:60 > +SVGMarkerLayoutInfo* getMarkerLayoutInfo(const RenderSVGShape* shape) Proposal (see below as well): SVGMarkerLayoutInfo* markerLayoutInfoForShape(RenderSVGShape*) SVGMarkerLayoutInfo* ensureMarkerLayoutInfoForShape(RenderSVGShape*). I don't think we need const RenderSVGShape here, correct me if I'm wrong. > Source/WebCore/rendering/svg/RenderSVGShape.cpp:428 > + gMarkerLayoutInfoMap = new MarkerLayoutInfoMap(); s/()// > Source/WebCore/rendering/svg/RenderSVGShape.cpp:434 > + SVGMarkerLayoutInfo* markerLayoutInfo = getMarkerLayoutInfo(this); > + if (!markerLayoutInfo) { > + markerLayoutInfo = new SVGMarkerLayoutInfo(); > + gMarkerLayoutInfoMap->add(this, markerLayoutInfo); > + } This should be done in a function named "ensureMarkerLayoutInfo" which gives you a SVGMarkerLayoutInfo* and stashes it in the cache.
Rob Buis
Comment 9 2012-05-08 12:20:52 PDT
Eric Seidel (no email)
Comment 10 2012-05-08 12:36:02 PDT
Comment on attachment 140764 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=140764&action=review I don't like this approach. Unless you have data to suggest this is worth the extra code, I would prefer an OwnPtr/RarePtr approach or leaving the code as-is. If your goal is to make this object smaller, we should have evidence that this actually affects memory usage, and should COMPILE_ASSERT so we never get it bigger. OTherwise we're just making work for ourselves here. :) > Source/WebCore/rendering/svg/RenderSVGShape.cpp:59 > +static SVGMarkerLayoutInfo* getMarkerLayoutInfo(const RenderSVGShape* shape, bool ensure = false) We dont' normally use get in method names. "Precede setters with the word "set". Use bare words for getters. Setter and getter names should match the names of the variables being set/gotten." http://www.webkit.org/coding/coding-style.html > Source/WebCore/rendering/svg/RenderSVGShape.cpp:89 > + delete markerLayoutInfo; You could also have your HashMap OwnPtr the marker and then just always empty the hash map for every shape destruction.
Nikolas Zimmermann
Comment 11 2012-05-09 03:35:37 PDT
(In reply to comment #10) > (From update of attachment 140764 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=140764&action=review > > I don't like this approach. Unless you have data to suggest this is worth the extra code, I would prefer an OwnPtr/RarePtr approach or leaving the code as-is. If your goal is to make this object smaller, we should have evidence that this actually affects memory usage, and should COMPILE_ASSERT so we never get it bigger. OTherwise we're just making work for ourselves here. :) I think its a good idea to only allocate the SVGMarkerLayoutInfo struct if needed, as its not small. Though as Eric correctly pointed out, an OwnPtr<SVGMarkerLayoutInfo> would work as well. Without a proof that Robs approach is superior in terms of memory, we should probably stick with the easier approach.
Dirk Schulze
Comment 12 2014-05-12 06:27:19 PDT
This would need a new approach but don't think that we need to do that.
Note You need to log in before you can comment on or make changes to this bug.