<?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>107371</bug_id>
          
          <creation_ts>2013-01-19 03:39:50 -0800</creation_ts>
          <short_desc>Pre-allocate our CompatHTMLToken Vector since we know how big it will be the the common case</short_desc>
          <delta_ts>2023-12-25 10:05:28 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>111645</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Eric Seidel (no email)">eric</reporter>
          <assigned_to name="Eric Seidel (no email)">eric</assigned_to>
          <cc>annevk</cc>
    
    <cc>ojan.autocc</cc>
    
    <cc>tonyg</cc>
    
    <cc>webkit.review.bot</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>811373</commentid>
    <comment_count>0</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2013-01-19 03:39:50 -0800</bug_when>
    <thetext>Pre-allocate our CompatHTMLToken Vector since we know how big it will be the the common case</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>811374</commentid>
    <comment_count>1</comment_count>
      <attachid>183617</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2013-01-19 03:41:16 -0800</bug_when>
    <thetext>Created attachment 183617
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>811375</commentid>
    <comment_count>2</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2013-01-19 03:41:48 -0800</bug_when>
    <thetext>The real wins will come from making HTMLCompactToken smaller.  Then we&apos;ll be allocating much less memory each time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>811434</commentid>
    <comment_count>3</comment_count>
      <attachid>183617</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2013-01-19 11:12:47 -0800</bug_when>
    <thetext>Comment on attachment 183617
Patch

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

&gt; Source/WebCore/ChangeLog:10
&gt; +        We know the maximum size of this buffer, so pre-allocate it to that size
&gt; +        for a small savings.  This shows us spending slightly less time in malloc,
&gt; +        but doesn&apos;t seem noticable on the final runtime (at least not outside the error bars).

I looked at this patch and didn&apos;t see much if any change in the benchmark.  On other workloads (say those with many scripts), it&apos;s not clear to me whether reserving this much space is actually a good thing.  If we&apos;re only sending off a hundred tokens in a chunk, then reserving space for 4k seems wasteful in terms of memory.

Before making this change, I&apos;d like to either see some data showing its a win or be convinced that it&apos;s never a loss.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>847550</commentid>
    <comment_count>4</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2013-03-05 04:22:36 -0800</bug_when>
    <thetext>I guess we could re-explore this change now that we have fancy telemetry to help us.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>850612</commentid>
    <comment_count>5</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2013-03-07 16:32:58 -0800</bug_when>
    <thetext>Allocs from our current lazy-strategy currently account for about 1% of total time:

Running Time	Self		Symbol Name
51.2ms    5.7%	51.2	 	WTF::fastMalloc(unsigned long)
8.7ms    0.9%	0.0	 	 WTF::Vector&lt;WebCore::CompactHTMLToken::Attribute, 0ul&gt;::Vector(WTF::Vector&lt;WebCore::CompactHTMLToken::Attribute, 0ul&gt; const&amp;)
5.8ms    0.6%	0.0	 	  WTF::VectorMover&lt;false, WebCore::CompactHTMLToken&gt;::move(WebCore::CompactHTMLToken const*, WebCore::CompactHTMLToken const*, WebCore::CompactHTMLToken*)
5.8ms    0.6%	0.0	 	   WTF::Vector&lt;WebCore::CompactHTMLToken, 0ul&gt;::reserveCapacity(unsigned long)
5.8ms    0.6%	0.0	 	    void WTF::Vector&lt;WebCore::CompactHTMLToken, 0ul&gt;::appendSlowCase&lt;WebCore::CompactHTMLToken&gt;(WebCore::CompactHTMLToken const&amp;)
5.8ms    0.6%	0.0	 	     WebCore::BackgroundHTMLParser::pumpTokenizer()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>850614</commentid>
    <comment_count>6</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2013-03-07 16:34:46 -0800</bug_when>
    <thetext>Related: abarth suggests that we at least set:
static const size_t pendingTokenLimit = 1000;
to align with one of the Vector pre-allocation sizes.

This is the vector algorithm:
        reserveCapacity(std::max(newMinCapacity, std::max(static_cast&lt;size_t&gt;(16), capacity() + capacity() / 4 + 1)));</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>850619</commentid>
    <comment_count>7</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2013-03-07 16:40:52 -0800</bug_when>
    <thetext>Actually this is worse than I thought.  We have an extra 2.5% of total time spent copying CompactHTMLTokens around these growing vectors:
Running Time	Self		Symbol Name
22.6ms    2.5%	0.0	 	 WTF::Vector&lt;WebCore::CompactHTMLToken, 0ul&gt;::reserveCapacity(unsigned long)
22.6ms    2.5%	0.0	 	  void WTF::Vector&lt;WebCore::CompactHTMLToken, 0ul&gt;::appendSlowCase&lt;WebCore::CompactHTMLToken&gt;(WebCore::CompactHTMLToken const&amp;)
22.6ms    2.5%	0.0	 	   WebCore::BackgroundHTMLParser::pumpTokenizer()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>851825</commentid>
    <comment_count>8</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2013-03-09 14:02:35 -0800</bug_when>
    <thetext>Assuming I&apos;m understanding the vector growth curve correctly, I&apos;m not sure it&apos;s the one we want:
https://docs.google.com/spreadsheet/ccc?key=0AlC4tS7Ao1fIdE1xa1pRc3Y3R2FRMGJoeGw2ZWk0dVE#gid=0</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2001930</commentid>
    <comment_count>9</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-12-25 10:05:28 -0800</bug_when>
    <thetext>Threaded HTML parser was removed.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>183617</attachid>
            <date>2013-01-19 03:41:16 -0800</date>
            <delta_ts>2013-01-19 11:12:47 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-107371-20130119033814.patch</filename>
            <type>text/plain</type>
            <size>1716</size>
            <attacher name="Eric Seidel (no email)">eric</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTQwMjM5CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggNjZhZDNhMzVmNjg2MmJi
NjU1MjY0NjhmZTY3NjRhZGVjZWQ3MDE4OS4uZTU1NDVmODRkNTU5YzBlZWYwYzM3ZjM3OWYxMjU1
NmY5M2ZlZTRkYiAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSw1ICsxLDE5IEBACiAyMDEzLTAxLTE5ICBFcmlj
IFNlaWRlbCAgPGVyaWNAd2Via2l0Lm9yZz4KIAorICAgICAgICBQcmUtYWxsb2NhdGUgb3VyIENv
bXBhdEhUTUx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vV2ViQ29yZS9odG1sL3BhcnNlci9CYWNrZ3JvdW5kSFRNTFBhcnNlci5jcHAK
aW5kZXggYWYwZDc4ZjMwNzE5MjkzNjdiMDc4MjVhNmZjNTM0NWEwMjE5NzhlNi4uNDdlNDI5NTY2
M2MxODc3M2Q2YTljMWJkYjFjYjlkNDhhMDRkOTQ4NyAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNv
cmUvaHRtbC9wYXJzZXIvQmFja2dyb3VuZEhUTUxQYXJzZXIuY3BwCisrKyBiL1NvdXJjZS9XZWJD
b3JlL2h0bWwvcGFyc2VyL0JhY2tncm91bmRIVE1MUGFyc2VyLmNwcApAQCAtMTIzLDYgKzEyMyw4
IEBAIHZvaWQgQmFja2dyb3VuZEhUTUxQYXJzZXI6OnB1bXBUb2tlbml6ZXIoKQogICAgIGlmICht
X2lzUGF1c2VkV2FpdGluZ0ZvclNjcmlwdHMpCiAgICAgICAgIHJldHVybjsKIAorICAgIG1fcGVu
ZGluZ1Rva2Vucy5yZXNlcnZlQ2FwYWNpdHkocGVuZGluZ1Rva2VuTGltaXQpOworCiAgICAgd2hp
bGUgKG1fdG9rZW5pemVyLT5uZXh0VG9rZW4obV9pbnB1dC5jdXJyZW50KCksIG1fdG9rZW4pKSB7
CiAgICAgICAgIG1fcGVuZGluZ1Rva2Vucy5hcHBlbmQoQ29tcGFjdEhUTUxUb2tlbihtX3Rva2Vu
KSk7CiAK
</data>
<flag name="review"
          id="202052"
          type_id="1"
          status="-"
          setter="abarth"
    />
          </attachment>
      

    </bug>

</bugzilla>