<?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>186709</bug_id>
          
          <creation_ts>2018-06-15 15:11:00 -0700</creation_ts>
          <short_desc>SimpleLineLayout::FlowContents wastes 54KB of Vector capacity on nytimes.com</short_desc>
          <delta_ts>2018-07-11 06:30:23 -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>RESOLVED</bug_status>
          <resolution>FIXED</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="alan">zalan</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>commit-queue</cc>
    
    <cc>darin</cc>
    
    <cc>saam</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1433595</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2018-06-15 15:11:00 -0700</bug_when>
    <thetext>Tooling from bug 186698:

Wasted capacity: 54096 bytes (used 7728 of 61824 bytes, utilization: 12.50%) - 161 allocations
1   0x108927092 WTF::VectorBuffer&lt;WebCore::SimpleLineLayout::FlowContents::Segment, 8ul&gt;::VectorBuffer(unsigned long, unsigned long)
2   0x108926fa8 WTF::Vector&lt;WebCore::SimpleLineLayout::FlowContents::Segment, 8ul, WTF::CrashOnOverflow, 16ul&gt;::Vector&lt;0ul, WTF::CrashOnOverflow, 16ul&gt;(WTF::Vector&lt;WebCore::SimpleLineLayout::FlowContents::Segment, 0ul, WTF::CrashOnOverflow, 16ul&gt; const&amp;)
3   0x1088faaed WTF::Vector&lt;WebCore::SimpleLineLayout::FlowContents::Segment, 8ul, WTF::CrashOnOverflow, 16ul&gt;::Vector&lt;0ul, WTF::CrashOnOverflow, 16ul&gt;(WTF::Vector&lt;WebCore::SimpleLineLayout::FlowContents::Segment, 0ul, WTF::CrashOnOverflow, 16ul&gt; const&amp;)
4   0x1088fa790 WebCore::SimpleLineLayout::FlowContents::FlowContents(WebCore::RenderBlockFlow const&amp;)
5   0x1088fab3d WebCore::SimpleLineLayout::FlowContents::FlowContents(WebCore::RenderBlockFlow const&amp;)
6   0x10892f8a6 WebCore::SimpleLineLayout::RunResolver::RunResolver(WebCore::RenderBlockFlow const&amp;, WebCore::SimpleLineLayout::Layout const&amp;)
7   0x10892f9c5 WebCore::SimpleLineLayout::RunResolver::RunResolver(WebCore::RenderBlockFlow const&amp;, WebCore::SimpleLineLayout::Layout const&amp;)
8   0x1088f8309 WebCore::SimpleLineLayout::Layout::runResolver() const</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1433597</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2018-06-15 15:11:19 -0700</bug_when>
    <thetext>&lt;rdar://problem/41173793&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1433663</commentid>
    <comment_count>2</comment_count>
    <who name="alan">zalan</who>
    <bug_when>2018-06-15 19:31:11 -0700</bug_when>
    <thetext>(In reply to Simon Fraser (smfr) from comment #0)
&gt; Tooling from bug 186698:
&gt; 
&gt; Wasted capacity: 54096 bytes (used 7728 of 61824 bytes, utilization: 12.50%)
&gt; - 161 allocations
&gt; 1   0x108927092
&gt; WTF::VectorBuffer&lt;WebCore::SimpleLineLayout::FlowContents::Segment,
&gt; 8ul&gt;::VectorBuffer(unsigned long, unsigned long)
&gt; 2   0x108926fa8
&gt; WTF::Vector&lt;WebCore::SimpleLineLayout::FlowContents::Segment, 8ul,
&gt; WTF::CrashOnOverflow, 16ul&gt;::Vector&lt;0ul, WTF::CrashOnOverflow,
&gt; 16ul&gt;(WTF::Vector&lt;WebCore::SimpleLineLayout::FlowContents::Segment, 0ul,
&gt; WTF::CrashOnOverflow, 16ul&gt; const&amp;)
&gt; 3   0x1088faaed
&gt; WTF::Vector&lt;WebCore::SimpleLineLayout::FlowContents::Segment, 8ul,
&gt; WTF::CrashOnOverflow, 16ul&gt;::Vector&lt;0ul, WTF::CrashOnOverflow,
&gt; 16ul&gt;(WTF::Vector&lt;WebCore::SimpleLineLayout::FlowContents::Segment, 0ul,
&gt; WTF::CrashOnOverflow, 16ul&gt; const&amp;)
&gt; 4   0x1088fa790
&gt; WebCore::SimpleLineLayout::FlowContents::FlowContents(WebCore::
&gt; RenderBlockFlow const&amp;)
&gt; 5   0x1088fab3d
&gt; WebCore::SimpleLineLayout::FlowContents::FlowContents(WebCore::
&gt; RenderBlockFlow const&amp;)
&gt; 6   0x10892f8a6
&gt; WebCore::SimpleLineLayout::RunResolver::RunResolver(WebCore::RenderBlockFlow
&gt; const&amp;, WebCore::SimpleLineLayout::Layout const&amp;)
&gt; 7   0x10892f9c5
&gt; WebCore::SimpleLineLayout::RunResolver::RunResolver(WebCore::RenderBlockFlow
&gt; const&amp;, WebCore::SimpleLineLayout::Layout const&amp;)
&gt; 8   0x1088f8309 WebCore::SimpleLineLayout::Layout::runResolver() const

In initializeSegments(), we call segments.reserveCapacity(numberOfChildren); on the vector -and we recreate it every time the content changes. Is there stacktraces for the wasted allocations?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1433680</commentid>
    <comment_count>3</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2018-06-15 21:53:21 -0700</bug_when>
    <thetext>No, but you could easily add this to the code added in bug 186698.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1439419</commentid>
    <comment_count>4</comment_count>
      <attachid>344335</attachid>
    <who name="alan">zalan</who>
    <bug_when>2018-07-05 09:49:04 -0700</bug_when>
    <thetext>Created attachment 344335
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1439459</commentid>
    <comment_count>5</comment_count>
      <attachid>344335</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2018-07-05 11:18:29 -0700</bug_when>
    <thetext>Comment on attachment 344335
Patch

Clearing flags on attachment: 344335

Committed r233530: &lt;https://trac.webkit.org/changeset/233530&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1439460</commentid>
    <comment_count>6</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2018-07-05 11:18:30 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1439573</commentid>
    <comment_count>7</comment_count>
      <attachid>344335</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2018-07-05 15:00:02 -0700</bug_when>
    <thetext>Comment on attachment 344335
Patch

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

&gt; Source/WebCore/ChangeLog:9
&gt; +        The size of the m_segments vector in SimpleLineLayoutFlowContents is alway pre-computed and don&apos;t change after the initial append.  

Given that’s true then we could make an even-more-memory efficient implementation by storing a size alongside a std::unique_ptr&lt;Segment[]&gt;. Could even make a class called something like WTF::FixedVector to make that available. Not sure how often we’d use such a thing or how well it would interoperate with things that know how to work with WTF::vector.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1439720</commentid>
    <comment_count>8</comment_count>
      <attachid>344335</attachid>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2018-07-06 00:45:56 -0700</bug_when>
    <thetext>Comment on attachment 344335
Patch

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

&gt;&gt; Source/WebCore/ChangeLog:9
&gt;&gt; +        The size of the m_segments vector in SimpleLineLayoutFlowContents is alway pre-computed and don&apos;t change after the initial append.  
&gt; 
&gt; Given that’s true then we could make an even-more-memory efficient implementation by storing a size alongside a std::unique_ptr&lt;Segment[]&gt;. Could even make a class called something like WTF::FixedVector to make that available. Not sure how often we’d use such a thing or how well it would interoperate with things that know how to work with WTF::vector.

std::unique_ptr&lt;T[]&gt; typically allocates bytes for size since `delete [] rawPointer` requires this. So, if we want to have such FixedVector, we should allocate a memory with fastMalloc() internally (instead of having std::unique_ptr&lt;T[]&gt;).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1439802</commentid>
    <comment_count>9</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2018-07-06 10:11:56 -0700</bug_when>
    <thetext>Seems like this may be a Speedometer2 regression on iOS</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1439803</commentid>
    <comment_count>10</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2018-07-06 10:12:18 -0700</bug_when>
    <thetext>(In reply to Saam Barati from comment #9)
&gt; Seems like this may be a Speedometer2 regression on iOS

About ~3% on certain iOS devices, but not all.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1439805</commentid>
    <comment_count>11</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2018-07-06 10:18:41 -0700</bug_when>
    <thetext>(In reply to Saam Barati from comment #10)
&gt; (In reply to Saam Barati from comment #9)
&gt; &gt; Seems like this may be a Speedometer2 regression on iOS
&gt; 
&gt; About ~3% on certain iOS devices, but not all.

Interestingly, JS tests also regressed in this range. So perhaps it&apos;s a different change that caused this regression</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1441151</commentid>
    <comment_count>12</comment_count>
    <who name="alan">zalan</who>
    <bug_when>2018-07-11 06:30:23 -0700</bug_when>
    <thetext>Committed r233728: &lt;https://trac.webkit.org/changeset/233728&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>344335</attachid>
            <date>2018-07-05 09:49:04 -0700</date>
            <delta_ts>2018-07-05 11:18:29 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-186709-20180705094904.patch</filename>
            <type>text/plain</type>
            <size>1500</size>
            <attacher name="alan">zalan</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjMzNTIxCmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggZWEzZDM5NDMwN2FiMThj
YjFjZjQwNWIyNWE5YmU4YzI5YjFjNDkzYS4uNTNhOGFkMDVmOTkwYjE3MTY0MTcxM2YzNWIzNjdl
ZDYyMmViOWMzMCAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE3IEBACisyMDE4LTA3LTA1ICBaYWxh
biBCdWp0YXMgIDx6YWxhbkBhcHBsZS5jb20+CisKKyAgICAgICAgU2ltcGxlTGluZUxheW91dDo6
Rmxvd0NvbnRlbnRzIHdhc3RlcyA1NEtCIG9mIFZlY3RvciBjYXBhY2l0eSBvbiBueXRpbWVzLmNv
bQorICAgICAgICBodHRwczovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/aWQ9MTg2NzA5
CisgICAgICAgIDxyZGFyOi8vcHJvYmxlbS80MTE3Mzc5Mz4KKworICAgICAgICBSZXZpZXdlZCBi
eSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAgICBUaGUgc2l6ZSBvZiB0aGUgbV9zZWdtZW50cyB2
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