Bug 189775 - Improve node statistics for rare data
Summary: Improve node statistics for rare data
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ryosuke Niwa
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-09-19 20:55 PDT by Ryosuke Niwa
Modified: 2018-09-19 23:21 PDT (History)
9 users (show)

See Also:


Attachments
Improved the logging (11.29 KB, patch)
2018-09-19 20:58 PDT, Ryosuke Niwa
simon.fraser: review+
Details | Formatted Diff | Diff
Patch to enable the statistics every 100 nodes (763 bytes, patch)
2018-09-19 23:21 PDT, Ryosuke Niwa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2018-09-19 20:55:49 PDT
Improve node statistics for rare data
Comment 1 Ryosuke Niwa 2018-09-19 20:58:57 PDT
Created attachment 350167 [details]
Improved the logging
Comment 2 Simon Fraser (smfr) 2018-09-19 21:08:16 PDT
Comment on attachment 350167 [details]
Improved the logging

View in context: https://bugs.webkit.org/attachment.cgi?id=350167&action=review

> Source/WebCore/dom/Node.cpp:130
> +static const char* stringForRareDataUseType(NodeRareData::UseType useType)
> +{
> +    switch (useType) {
> +    case NodeRareData::UseType::ConnectedFrameCount:
> +        return "ConnectedFrameCount";
> +    case NodeRareData::UseType::NodeList:
> +        return "NodeList";
> +    case NodeRareData::UseType::MutationObserver:
> +        return "MutationObserver";
> +    case NodeRareData::UseType::TabIndex:
> +        return "TabIndex";
> +    case NodeRareData::UseType::StyleFlags:
> +        return "StyleFlags";
> +    case NodeRareData::UseType::MinimumSize:
> +        return "MinimumSize";
> +    case NodeRareData::UseType::ScrollingPosition:
> +        return "ScrollingPosition";
> +    case NodeRareData::UseType::ComputedStyle:
> +        return "ComputedStyle";
> +    case NodeRareData::UseType::Dataset:
> +        return "Dataset";
> +    case NodeRareData::UseType::ClassList:
> +        return "ClassList";
> +    case NodeRareData::UseType::ShadowRoot:
> +        return "ShadowRoot";
> +    case NodeRareData::UseType::CustomElementQueue:
> +        return "CustomElementQueue";
> +    case NodeRareData::UseType::AttributeMap:
> +        return "AttributeMap";
> +    case NodeRareData::UseType::InteractionObserver:
> +        return "InteractionObserver";
> +    case NodeRareData::UseType::PseudoElements:
> +        return "PseudoElements";
> +    }
> +    return nullptr;
> +}

It would be nicer to implement TextStream& operator<<(TextStream& ts, NodeRareData::UseType) and do the outputting by building a TextStream. Then we can use that for log streams as well.

> Source/WebCore/dom/Node.cpp:175
> +            for (auto type : useTypes) {
> +                UNUSED_PARAM(type);
> +                useTypeCount++;
> +            }

Why not implement OptionSet::numberOfBitsSet() with one of the classic bit-counting algorithms?
Comment 3 Ryosuke Niwa 2018-09-19 21:19:27 PDT
(In reply to Simon Fraser (smfr) from comment #2)
> Comment on attachment 350167 [details]
> Improved the logging
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=350167&action=review
> 
> > Source/WebCore/dom/Node.cpp:130
> > +static const char* stringForRareDataUseType(NodeRareData::UseType useType)
> > +{
> > +    switch (useType) {
> > +    case NodeRareData::UseType::ConnectedFrameCount:
> > +        return "ConnectedFrameCount";
> > +    case NodeRareData::UseType::NodeList:
> > +        return "NodeList";
> > +    case NodeRareData::UseType::MutationObserver:
> > +        return "MutationObserver";
> > +    case NodeRareData::UseType::TabIndex:
> > +        return "TabIndex";
> > +    case NodeRareData::UseType::StyleFlags:
> > +        return "StyleFlags";
> > +    case NodeRareData::UseType::MinimumSize:
> > +        return "MinimumSize";
> > +    case NodeRareData::UseType::ScrollingPosition:
> > +        return "ScrollingPosition";
> > +    case NodeRareData::UseType::ComputedStyle:
> > +        return "ComputedStyle";
> > +    case NodeRareData::UseType::Dataset:
> > +        return "Dataset";
> > +    case NodeRareData::UseType::ClassList:
> > +        return "ClassList";
> > +    case NodeRareData::UseType::ShadowRoot:
> > +        return "ShadowRoot";
> > +    case NodeRareData::UseType::CustomElementQueue:
> > +        return "CustomElementQueue";
> > +    case NodeRareData::UseType::AttributeMap:
> > +        return "AttributeMap";
> > +    case NodeRareData::UseType::InteractionObserver:
> > +        return "InteractionObserver";
> > +    case NodeRareData::UseType::PseudoElements:
> > +        return "PseudoElements";
> > +    }
> > +    return nullptr;
> > +}
> 
> It would be nicer to implement TextStream& operator<<(TextStream& ts,
> NodeRareData::UseType) and do the outputting by building a TextStream. Then
> we can use that for log streams as well.

Yeah, I did consider doing that but that seemed like a lot of rewrites so we should probably do it in a separate patch from this.

> 
> > Source/WebCore/dom/Node.cpp:175
> > +            for (auto type : useTypes) {
> > +                UNUSED_PARAM(type);
> > +                useTypeCount++;
> > +            }
> 
> Why not implement OptionSet::numberOfBitsSet() with one of the classic
> bit-counting algorithms?

I think OptionSet::size() is being added in https://bugs.webkit.org/show_bug.cgi?id=189633. We can simply use that once that's available.
Comment 4 Daniel Bates 2018-09-19 21:33:31 PDT
Comment on attachment 350167 [details]
Improved the logging

View in context: https://bugs.webkit.org/attachment.cgi?id=350167&action=review

> Source/WebCore/dom/Element.cpp:3445
> +#if DUMP_NODE_STATISTICS

I am assuming DUMP_NODE_STATISTICS is always defined.

> Source/WebCore/dom/NodeRareData.h:252
> +#if defined(DUMP_NODE_STATISTICS) && DUMP_NODE_STATISTICS

Is DUMP_NODE_STATISTICS always defined? or not?
Comment 5 Ryosuke Niwa 2018-09-19 23:10:11 PDT
(In reply to Daniel Bates from comment #4)
> Comment on attachment 350167 [details]
> Improved the logging
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=350167&action=review
> 
> > Source/WebCore/dom/Element.cpp:3445
> > +#if DUMP_NODE_STATISTICS

It's always defined in Node.h

> I am assuming DUMP_NODE_STATISTICS is always defined.
> 
> > Source/WebCore/dom/NodeRareData.h:252
> > +#if defined(DUMP_NODE_STATISTICS) && DUMP_NODE_STATISTICS
> 
> Is DUMP_NODE_STATISTICS always defined? or not?

NodeRareData.h can be included in places where Node.h isn't included. In those cases, we don't want to cause a compiler error or include Node.h
Comment 6 Ryosuke Niwa 2018-09-19 23:15:01 PDT
Committed r236241: <https://trac.webkit.org/changeset/236241>
Comment 7 Radar WebKit Bug Importer 2018-09-19 23:15:26 PDT
<rdar://problem/44630168>
Comment 8 Ryosuke Niwa 2018-09-19 23:21:00 PDT
Created attachment 350172 [details]
Patch to enable the statistics every 100 nodes