<?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>43687</bug_id>
          
          <creation_ts>2010-08-08 04:53:04 -0700</creation_ts>
          <short_desc>Web Inspector: speed-up Element.prototype.removeChildren</short_desc>
          <delta_ts>2010-08-08 10:45:37 -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>Web Inspector (Deprecated)</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Nikita Vasilyev">me</reporter>
          <assigned_to name="Nikita Vasilyev">me</assigned_to>
          <cc>bweinstein</cc>
    
    <cc>eric</cc>
    
    <cc>joepeck</cc>
    
    <cc>keishi</cc>
    
    <cc>pfeldman</cc>
    
    <cc>pmuellr</cc>
    
    <cc>rik</cc>
    
    <cc>timothy</cc>
    
    <cc>yurys</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>261875</commentid>
    <comment_count>0</comment_count>
    <who name="Nikita Vasilyev">me</who>
    <bug_when>2010-08-08 04:53:04 -0700</bug_when>
    <thetext>The current Element.prototype.removeChildren is using `element.innerHTML = &quot;&quot;`. It&apos;s the slowest method in my benchmarks:

http://jsperf.com/remove-all-child-nodes/2 (20x faster in WebKit, 35x in Chrome)
http://jsperf.com/remove-all-child-nodes-5-childs/3 (1,6 faster in WebKit, 2x in Chrome)
http://jsperf.com/remove-all-child-nodes-zero-childs (1,6 faster in WebKit, 2x in Chrome)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>261876</commentid>
    <comment_count>1</comment_count>
      <attachid>63840</attachid>
    <who name="Nikita Vasilyev">me</who>
    <bug_when>2010-08-08 04:57:39 -0700</bug_when>
    <thetext>Created attachment 63840
patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>261877</commentid>
    <comment_count>2</comment_count>
      <attachid>63840</attachid>
    <who name="Pavel Feldman">pfeldman</who>
    <bug_when>2010-08-08 05:11:36 -0700</bug_when>
    <thetext>Comment on attachment 63840
patch

In fact I&apos;ve done the opposite optimization earlier:
https://bugs.webkit.org/show_bug.cgi?id=31160

Timeline was lagging visually on scrolling and clearing + shark was showing this to be the slow operation. I&apos;d suggest that you try those. Wrt benchmarks, I think they lack listeners - adding those would change the WebKit picture a lot. I know that the bindings have improved, but still, single call to native will always be ways faster.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>261880</commentid>
    <comment_count>3</comment_count>
    <who name="Nikita Vasilyev">me</who>
    <bug_when>2010-08-08 05:17:58 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; (From update of attachment 63840 [details])
&gt; In fact I&apos;ve done the opposite optimization earlier:
&gt; https://bugs.webkit.org/show_bug.cgi?id=31160
&gt; 
&gt; Timeline was lagging visually on scrolling and clearing + shark was showing this to be the slow operation. I&apos;d suggest that you try those. Wrt benchmarks, I think they lack listeners - adding those would change the WebKit picture a lot. I know that the bindings have improved, but still, single call to native will always be ways faster.

Oh, I didn&apos;t think about reflow. At this case `element.textContent = &quot;&quot;` would be faster.

By the way, what are Wrt benchmarks?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>261882</commentid>
    <comment_count>4</comment_count>
      <attachid>63842</attachid>
    <who name="Nikita Vasilyev">me</who>
    <bug_when>2010-08-08 06:59:23 -0700</bug_when>
    <thetext>Created attachment 63842
this.textContent = &quot;&quot;

http://elv1s.ru/files/js/removeChildren.html
Now innerHTML and textContent works the same. removeFirstChild is a little slower.

When inspecting the DOM, there are many calls of removeChildren while an element already doesn&apos;t have children. So I added `if (this.firstChild)` check.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>261889</commentid>
    <comment_count>5</comment_count>
      <attachid>63842</attachid>
    <who name="Pavel Feldman">pfeldman</who>
    <bug_when>2010-08-08 09:29:15 -0700</bug_when>
    <thetext>Comment on attachment 63842
this.textContent = &quot;&quot;

Thanks for doing this!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>261902</commentid>
    <comment_count>6</comment_count>
      <attachid>63842</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2010-08-08 10:45:31 -0700</bug_when>
    <thetext>Comment on attachment 63842
this.textContent = &quot;&quot;

Clearing flags on attachment: 63842

Committed r64952: &lt;http://trac.webkit.org/changeset/64952&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>261903</commentid>
    <comment_count>7</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2010-08-08 10:45:37 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>63840</attachid>
            <date>2010-08-08 04:57:39 -0700</date>
            <delta_ts>2010-08-08 06:59:23 -0700</delta_ts>
            <desc>patch</desc>
            <filename>removeChildren.patch</filename>
            <type>text/plain</type>
            <size>1045</size>
            <attacher name="Nikita Vasilyev">me</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1dlYkNvcmUvQ2hhbmdlTG9nIGIvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXgg
N2E5MjFjMS4uYmI3NWEwMSAxMDA2NDQKLS0tIGEvV2ViQ29yZS9DaGFuZ2VMb2cKKysrIGIvV2Vi
Q29yZS9DaGFuZ2VMb2cKQEAgLTEsMyAr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aGlsZCkgeworICAgICAgICB0aGlzLnJlbW92ZUNoaWxk
KGNoaWxkKTsKKyAgICB9CiB9CiAKIEVsZW1lbnQucHJvdG90eXBlLmlzSW5zZXJ0aW9uQ2FyZXRJ
bnNpZGUgPSBmdW5jdGlvbigpCg==
</data>
<flag name="review"
          id="52262"
          type_id="1"
          status="-"
          setter="pfeldman"
    />
          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>63842</attachid>
            <date>2010-08-08 06:59:23 -0700</date>
            <delta_ts>2010-08-08 10:45:31 -0700</delta_ts>
            <desc>this.textContent = &quot;&quot;</desc>
            <filename>removeChildren.patch</filename>
            <type>text/plain</type>
            <size>1006</size>
            <attacher name="Nikita Vasilyev">me</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1dlYkNvcmUvQ2hhbmdlTG9nIGIvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXgg
N2E5MjFjMS4uYmI3NWEwMSAxMDA2NDQKLS0tIGEvV2ViQ29yZS9DaGFuZ2VMb2cKKysrIGIvV2Vi
Q29yZS9DaGFuZ2VMb2cKQEAgLTEsMyArMSwxMyBAQAorMjAxMC0wOC0wOCAgTmlraXRhIFZhc2ls
eWV2ICA8bWVAZWx2MXMucnU+CisKKyAgICAgICAgUmV2aWV3ZWQgYnkgTk9CT0RZIChPT1BTISku
CisKKyAgICAgICAgV2ViIEluc3BlY3Rvcjogc3BlZWQtdXAgRWxlbWVudC5wcm90b3R5cGUucmVt
b3ZlQ2hpbGRyZW4KKyAgICAgICAgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dp
P2lkPTQzNjg3CisKKyAgICAgICAgKiBpbnNwZWN0b3IvZnJvbnQtZW5kL3V0aWxpdGllcy5qczoK
KyAgICAgICAgKEVsZW1lbnQucHJvdG90eXBlLnJlbW92ZUNoaWxkcmVuKToKKwogMjAxMC0wOC0w
OCAgQWRhbSBCYXJ0aCAgPGFiYX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