<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>186742</bug_id>
          
          <creation_ts>2018-06-16 12:43:26 -0700</creation_ts>
          <short_desc>TreeScopeOrderedMap wastes 132KB of HashTable capacity on nytimes.com</short_desc>
          <delta_ts>2018-07-03 14:30:53 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Layout and Rendering</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Simon Fraser (smfr)">simon.fraser</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>cdumez</cc>
    
    <cc>koivisto</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1433807</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2018-06-16 12:43:26 -0700</bug_when>
    <thetext>Using tooling from bug 186698, loading nytimes.com and running &quot;notifyutil -p com.apple.WebKit.dumpHashTableCapacity&quot; shows:

Wasted capacity: 131912 bytes (used 65208 of 197120 bytes, utilization: 33.08%) - 80 allocations
1   0x1078997a5 WTF::HashTable&lt;WTF::AtomicStringImpl const*, WTF::KeyValuePair&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry&gt;, WTF::KeyValuePairKeyExtractor&lt;WTF::KeyValuePair&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry&gt; &gt;, WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashMap&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry, WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WebCore::TreeScopeOrderedMap::MapEntry&gt; &gt;::KeyValuePairTraits, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt; &gt;::HashTable()
2   0x107899785 WTF::HashMap&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry, WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WebCore::TreeScopeOrderedMap::MapEntry&gt; &gt;::HashMap()
3   0x107899765 WTF::HashMap&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry, WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WebCore::TreeScopeOrderedMap::MapEntry&gt; &gt;::HashMap()
4   0x107899745 WebCore::TreeScopeOrderedMap::TreeScopeOrderedMap()
5   0x107899725 WebCore::TreeScopeOrderedMap::TreeScopeOrderedMap()
6   0x10788e206 WebCore::TreeScope::addElementById(WTF::AtomicStringImpl const&amp;, WebCore::Element&amp;, bool)
7   0x1077630f8 WebCore::Element::updateIdForTreeScope(WebCore::TreeScope&amp;, WTF::AtomicString const&amp;, WTF::AtomicString const&amp;, WebCore::Element::NotifyObservers)
8   0x107762cd2 WebCore::Element::insertedIntoAncestor(WebCore::Node::InsertionType, WebCore::ContainerNode&amp;)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1433808</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2018-06-16 12:43:54 -0700</bug_when>
    <thetext>&lt;rdar://problem/41189300&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1433811</commentid>
    <comment_count>2</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2018-06-16 12:45:11 -0700</bug_when>
    <thetext>Also these call sites:

Wasted capacity: 70928 bytes (used 11440 of 82368 bytes, utilization: 13.89%) - 1273 allocations
1   0x1076fd625 WTF::HashTable&lt;WebCore::Element*, WebCore::Element*, WTF::IdentityExtractor, WTF::PtrHash&lt;WebCore::Element*&gt;, WTF::HashTraits&lt;WebCore::Element*&gt;, WTF::HashTraits&lt;WebCore::Element*&gt; &gt;::HashTable()
2   0x1076fd605 WTF::HashSet&lt;WebCore::Element*, WTF::PtrHash&lt;WebCore::Element*&gt;, WTF::HashTraits&lt;WebCore::Element*&gt; &gt;::HashSet()
3   0x1076a8d65 WTF::HashSet&lt;WebCore::Element*, WTF::PtrHash&lt;WebCore::Element*&gt;, WTF::HashTraits&lt;WebCore::Element*&gt; &gt;::HashSet()
4   0x10789c652 WebCore::TreeScopeOrderedMap::MapEntry::MapEntry(WebCore::Element*)
5   0x10789c5fd WebCore::TreeScopeOrderedMap::MapEntry::MapEntry(WebCore::Element*)
6   0x10789c0cf WebCore::TreeScopeOrderedMap::add(WTF::AtomicStringImpl const&amp;, WebCore::Element&amp;, WebCore::TreeScope const&amp;)::$_0::operator()() const
7   0x10789afd5 void WTF::HashMapEnsureTranslator&lt;WTF::HashMap&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry, WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WebCore::TreeScopeOrderedMap::MapEntry&gt; &gt;::KeyValuePairTraits, WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt; &gt;::translate&lt;WTF::KeyValuePair&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry&gt;, WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::add(WTF::AtomicStringImpl const&amp;, WebCore::Element&amp;, WebCore::TreeScope const&amp;)::$_0&gt;(WTF::KeyValuePair&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry&gt;&amp;, WTF::AtomicStringImpl const*&amp;&amp;, WebCore::TreeScopeOrderedMap::add(WTF::AtomicStringImpl const&amp;, WebCore::Element&amp;, WebCore::TreeScope const&amp;)::$_0&amp;&amp;)
8   0x10789ac73 WTF::HashTableAddResult&lt;WTF::HashTableIterator&lt;WTF::AtomicStringImpl const*, WTF::KeyValuePair&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry&gt;, WTF::KeyValuePairKeyExtractor&lt;WTF::KeyValuePair&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry&gt; &gt;, WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashMap&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry, WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WebCore::TreeScopeOrderedMap::MapEntry&gt; &gt;::KeyValuePairTraits, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt; &gt; &gt; WTF::HashTable&lt;WTF::AtomicStringImpl const*, WTF::KeyValuePair&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry&gt;, WTF::KeyValuePairKeyExtractor&lt;WTF::KeyValuePair&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry&gt; &gt;, WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashMap&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry, WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WebCore::TreeScopeOrderedMap::MapEntry&gt; &gt;::KeyValuePairTraits, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt; &gt;::add&lt;WTF::HashMapEnsureTranslator&lt;WTF::HashMap&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry, WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WebCore::TreeScopeOrderedMap::MapEntry&gt; &gt;::KeyValuePairTraits, WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt; &gt;, WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::add(WTF::AtomicStringImpl const&amp;, WebCore::Element&amp;, WebCore::TreeScope const&amp;)::$_0&gt;(WTF::AtomicStringImpl const*&amp;&amp;, WebCore::TreeScopeOrderedMap::add(WTF::AtomicStringImpl const&amp;, WebCore::Element&amp;, WebCore::TreeScope const&amp;)::$_0&amp;&amp;)

Wasted capacity: 63448 bytes (used 42856 of 106304 bytes, utilization: 40.31%) - 22 allocations
1   0x1078997a5 WTF::HashTable&lt;WTF::AtomicStringImpl const*, WTF::KeyValuePair&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry&gt;, WTF::KeyValuePairKeyExtractor&lt;WTF::KeyValuePair&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry&gt; &gt;, WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashMap&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry, WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WebCore::TreeScopeOrderedMap::MapEntry&gt; &gt;::KeyValuePairTraits, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt; &gt;::HashTable()
2   0x107899785 WTF::HashMap&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry, WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WebCore::TreeScopeOrderedMap::MapEntry&gt; &gt;::HashMap()
3   0x107899765 WTF::HashMap&lt;WTF::AtomicStringImpl const*, WebCore::TreeScopeOrderedMap::MapEntry, WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt;, WTF::HashTraits&lt;WebCore::TreeScopeOrderedMap::MapEntry&gt; &gt;::HashMap()
4   0x107899745 WebCore::TreeScopeOrderedMap::TreeScopeOrderedMap()
5   0x107899725 WebCore::TreeScopeOrderedMap::TreeScopeOrderedMap()
6   0x107a54296 WebCore::HTMLDocument::HTMLDocument(WebCore::Frame*, WebCore::URL const&amp;, unsigned char, unsigned int)
7   0x107a54358 WebCore::HTMLDocument::HTMLDocument(WebCore::Frame*, WebCore::URL const&amp;, unsigned char, unsigned int)
8   0x10768a2a7 WebCore::HTMLDocument::create(WebCore::Frame*, WebCore::URL const&amp;)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1438986</commentid>
    <comment_count>3</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-07-03 14:30:53 -0700</bug_when>
    <thetext>(In reply to Simon Fraser (smfr) from comment #2)
&gt; Also these call sites:
&gt; 
&gt; Wasted capacity: 70928 bytes (used 11440 of 82368 bytes, utilization:
&gt; 13.89%) - 1273 allocations
&gt; 1   0x1076fd625 WTF::HashTable&lt;WebCore::Element*, WebCore::Element*,
&gt; WTF::IdentityExtractor, WTF::PtrHash&lt;WebCore::Element*&gt;,
&gt; WTF::HashTraits&lt;WebCore::Element*&gt;, WTF::HashTraits&lt;WebCore::Element*&gt;
&gt; &gt;::HashTable()
&gt; 2   0x1076fd605 WTF::HashSet&lt;WebCore::Element*,
&gt; WTF::PtrHash&lt;WebCore::Element*&gt;, WTF::HashTraits&lt;WebCore::Element*&gt;
&gt; &gt;::HashSet()
&gt; 3   0x1076a8d65 WTF::HashSet&lt;WebCore::Element*,
&gt; WTF::PtrHash&lt;WebCore::Element*&gt;, WTF::HashTraits&lt;WebCore::Element*&gt;
&gt; &gt;::HashSet()
&gt; 4   0x10789c652
&gt; WebCore::TreeScopeOrderedMap::MapEntry::MapEntry(WebCore::Element*)
&gt; 5   0x10789c5fd
&gt; WebCore::TreeScopeOrderedMap::MapEntry::MapEntry(WebCore::Element*)
&gt; 6   0x10789c0cf WebCore::TreeScopeOrderedMap::add(WTF::AtomicStringImpl
&gt; const&amp;, WebCore::Element&amp;, WebCore::TreeScope const&amp;)::$_0::operator()()
&gt; const
&gt; 7   0x10789afd5 void
&gt; WTF::HashMapEnsureTranslator&lt;WTF::HashMap&lt;WTF::AtomicStringImpl const*,
&gt; WebCore::TreeScopeOrderedMap::MapEntry, WTF::PtrHash&lt;WTF::AtomicStringImpl
&gt; const*&gt;, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt;,
&gt; WTF::HashTraits&lt;WebCore::TreeScopeOrderedMap::MapEntry&gt;
&gt; &gt;::KeyValuePairTraits, WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt;
&gt; &gt;::translate&lt;WTF::KeyValuePair&lt;WTF::AtomicStringImpl const*,
&gt; WebCore::TreeScopeOrderedMap::MapEntry&gt;, WTF::AtomicStringImpl const*,
&gt; WebCore::TreeScopeOrderedMap::add(WTF::AtomicStringImpl const&amp;,
&gt; WebCore::Element&amp;, WebCore::TreeScope
&gt; const&amp;)::$_0&gt;(WTF::KeyValuePair&lt;WTF::AtomicStringImpl const*,
&gt; WebCore::TreeScopeOrderedMap::MapEntry&gt;&amp;, WTF::AtomicStringImpl const*&amp;&amp;,
&gt; WebCore::TreeScopeOrderedMap::add(WTF::AtomicStringImpl const&amp;,
&gt; WebCore::Element&amp;, WebCore::TreeScope const&amp;)::$_0&amp;&amp;)
&gt; 8   0x10789ac73
&gt; WTF::HashTableAddResult&lt;WTF::HashTableIterator&lt;WTF::AtomicStringImpl const*,
&gt; WTF::KeyValuePair&lt;WTF::AtomicStringImpl const*,
&gt; WebCore::TreeScopeOrderedMap::MapEntry&gt;,
&gt; WTF::KeyValuePairKeyExtractor&lt;WTF::KeyValuePair&lt;WTF::AtomicStringImpl
&gt; const*, WebCore::TreeScopeOrderedMap::MapEntry&gt; &gt;,
&gt; WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt;,
&gt; WTF::HashMap&lt;WTF::AtomicStringImpl const*,
&gt; WebCore::TreeScopeOrderedMap::MapEntry, WTF::PtrHash&lt;WTF::AtomicStringImpl
&gt; const*&gt;, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt;,
&gt; WTF::HashTraits&lt;WebCore::TreeScopeOrderedMap::MapEntry&gt;
&gt; &gt;::KeyValuePairTraits, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt; &gt; &gt;
&gt; WTF::HashTable&lt;WTF::AtomicStringImpl const*,
&gt; WTF::KeyValuePair&lt;WTF::AtomicStringImpl const*,
&gt; WebCore::TreeScopeOrderedMap::MapEntry&gt;,
&gt; WTF::KeyValuePairKeyExtractor&lt;WTF::KeyValuePair&lt;WTF::AtomicStringImpl
&gt; const*, WebCore::TreeScopeOrderedMap::MapEntry&gt; &gt;,
&gt; WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt;,
&gt; WTF::HashMap&lt;WTF::AtomicStringImpl const*,
&gt; WebCore::TreeScopeOrderedMap::MapEntry, WTF::PtrHash&lt;WTF::AtomicStringImpl
&gt; const*&gt;, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt;,
&gt; WTF::HashTraits&lt;WebCore::TreeScopeOrderedMap::MapEntry&gt;
&gt; &gt;::KeyValuePairTraits, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt;
&gt; &gt;::add&lt;WTF::HashMapEnsureTranslator&lt;WTF::HashMap&lt;WTF::AtomicStringImpl
&gt; const*, WebCore::TreeScopeOrderedMap::MapEntry,
&gt; WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt;,
&gt; WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt;,
&gt; WTF::HashTraits&lt;WebCore::TreeScopeOrderedMap::MapEntry&gt;
&gt; &gt;::KeyValuePairTraits, WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt; &gt;,
&gt; WTF::AtomicStringImpl const*,
&gt; WebCore::TreeScopeOrderedMap::add(WTF::AtomicStringImpl const&amp;,
&gt; WebCore::Element&amp;, WebCore::TreeScope const&amp;)::$_0&gt;(WTF::AtomicStringImpl
&gt; const*&amp;&amp;, WebCore::TreeScopeOrderedMap::add(WTF::AtomicStringImpl const&amp;,
&gt; WebCore::Element&amp;, WebCore::TreeScope const&amp;)::$_0&amp;&amp;)
&gt; 
&gt; Wasted capacity: 63448 bytes (used 42856 of 106304 bytes, utilization:
&gt; 40.31%) - 22 allocations
&gt; 1   0x1078997a5 WTF::HashTable&lt;WTF::AtomicStringImpl const*,
&gt; WTF::KeyValuePair&lt;WTF::AtomicStringImpl const*,
&gt; WebCore::TreeScopeOrderedMap::MapEntry&gt;,
&gt; WTF::KeyValuePairKeyExtractor&lt;WTF::KeyValuePair&lt;WTF::AtomicStringImpl
&gt; const*, WebCore::TreeScopeOrderedMap::MapEntry&gt; &gt;,
&gt; WTF::PtrHash&lt;WTF::AtomicStringImpl const*&gt;,
&gt; WTF::HashMap&lt;WTF::AtomicStringImpl const*,
&gt; WebCore::TreeScopeOrderedMap::MapEntry, WTF::PtrHash&lt;WTF::AtomicStringImpl
&gt; const*&gt;, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt;,
&gt; WTF::HashTraits&lt;WebCore::TreeScopeOrderedMap::MapEntry&gt;
&gt; &gt;::KeyValuePairTraits, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt;
&gt; &gt;::HashTable()
&gt; 2   0x107899785 WTF::HashMap&lt;WTF::AtomicStringImpl const*,
&gt; WebCore::TreeScopeOrderedMap::MapEntry, WTF::PtrHash&lt;WTF::AtomicStringImpl
&gt; const*&gt;, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt;,
&gt; WTF::HashTraits&lt;WebCore::TreeScopeOrderedMap::MapEntry&gt; &gt;::HashMap()
&gt; 3   0x107899765 WTF::HashMap&lt;WTF::AtomicStringImpl const*,
&gt; WebCore::TreeScopeOrderedMap::MapEntry, WTF::PtrHash&lt;WTF::AtomicStringImpl
&gt; const*&gt;, WTF::HashTraits&lt;WTF::AtomicStringImpl const*&gt;,
&gt; WTF::HashTraits&lt;WebCore::TreeScopeOrderedMap::MapEntry&gt; &gt;::HashMap()
&gt; 4   0x107899745 WebCore::TreeScopeOrderedMap::TreeScopeOrderedMap()
&gt; 5   0x107899725 WebCore::TreeScopeOrderedMap::TreeScopeOrderedMap()
&gt; 6   0x107a54296 WebCore::HTMLDocument::HTMLDocument(WebCore::Frame*,
&gt; WebCore::URL const&amp;, unsigned char, unsigned int)
&gt; 7   0x107a54358 WebCore::HTMLDocument::HTMLDocument(WebCore::Frame*,
&gt; WebCore::URL const&amp;, unsigned char, unsigned int)
&gt; 8   0x10768a2a7 WebCore::HTMLDocument::create(WebCore::Frame*, WebCore::URL
&gt; const&amp;)

Were you using a debug build? This particular HashSet seems to be debug-only.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>