Summary: | Devirtualize CSSValue | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Andreas Kling <kling> | ||||
Component: | CSS | Assignee: | Andreas Kling <kling> | ||||
Status: | RESOLVED FIXED | ||||||
Severity: | Normal | CC: | koivisto, macpherson, mikelawther, webkit.review.bot | ||||
Priority: | P2 | ||||||
Version: | 528+ (Nightly build) | ||||||
Hardware: | Unspecified | ||||||
OS: | Unspecified | ||||||
Bug Depends on: | 71667, 71668, 71671, 71675, 71796, 71800, 71813, 71814, 71824 | ||||||
Bug Blocks: | |||||||
Attachments: |
|
Description
Andreas Kling
2011-11-07 04:41:09 PST
Created attachment 114097 [details]
Patch!
Comment on attachment 114097 [details] Patch! View in context: https://bugs.webkit.org/attachment.cgi?id=114097&action=review r=me > Source/WebCore/css/CSSValue.cpp:214 > + case InitialClass: > + case ImplicitInitialClass: > + delete static_cast<CSSInitialValue*>(this); > + return; This is bit strange. (In reply to comment #2) > (From update of attachment 114097 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=114097&action=review > > r=me > > > Source/WebCore/css/CSSValue.cpp:214 > > + case InitialClass: > > + case ImplicitInitialClass: > > + delete static_cast<CSSInitialValue*>(this); > > + return; > > This is bit strange. Indeed. As I said on IRC, this is a hack to avoid out-of-lining CSSValue::isImplicitInitialValue() since we can't dereference a CSSInitialValue pointer in CSSValue.h. I'll move this to a dedicated CSSValue bit in a future patch. Committed r99592: <http://trac.webkit.org/changeset/99592> Now that these have all landed - what has been the performance improvement? Apologies if this was mentioned/discussed on IRC - I'm not on-channel all the time. (In reply to comment #5) > Now that these have all landed - what has been the performance improvement? > > Apologies if this was mentioned/discussed on IRC - I'm not on-channel all the time. This was done primarily as a memory optimization, so I only verified the lack of performance regressions. As an example, it saves ~100kB on current GMail. OK - thanks. I asked because of the comment in CSSValue.h // NOTE: This class is non-virtual for memory and performance reasons. // Don't go making it virtual again unless you know exactly what you're doing! The memory benefits of devirtualising are clear, but I wanted to understand the performance reasons. So it sounds like there is negligible performance delta between virtual/non-virtual in this case. Note that reducing memory usage of the core data structures can in some cases be a measurable performance win in itself due to improved locality. Yep - totally (improved cache coherency etc). That was why I was interested in any performance measurements that had been done so the gains could be quantified. Or whether any gains from improved memory may have been canceled out due to the increased code size and execution time of the DIY dispatch. (In reply to comment #7) > OK - thanks. I asked because of the comment in CSSValue.h > > // NOTE: This class is non-virtual for memory and performance reasons. > // Don't go making it virtual again unless you know exactly what you're doing! > > The memory benefits of devirtualising are clear, but I wanted to understand the performance reasons. > > So it sounds like there is negligible performance delta between virtual/non-virtual in this case. That sounds about right. I discussed this with Antti, and we simply wanted a sufficiently scary-looking comment so people wouldn't accidentally make the class virtual again. (In reply to comment #9) > Yep - totally (improved cache coherency etc). That was why I was interested in any performance measurements that had been done so the gains could be quantified. Or whether any gains from improved memory may have been canceled out due to the increased code size and execution time of the DIY dispatch. I suspect that if anything, the DIY dispatch is actually faster than virtual calls, as it can synergize better with CPU branch prediction. |