<?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>97270</bug_id>
          
          <creation_ts>2012-09-20 16:09:28 -0700</creation_ts>
          <short_desc>DOM-in-JavaScript performance experiments</short_desc>
          <delta_ts>2017-07-18 08:30:03 -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>WebCore JavaScript</component>
          <version>528+ (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></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Adam Barth">abarth</reporter>
          <assigned_to name="Adam Barth">abarth</assigned_to>
          <cc>alex</cc>
    
    <cc>ap</cc>
    
    <cc>arv</cc>
    
    <cc>barraclough</cc>
    
    <cc>dmikurube</cc>
    
    <cc>dominicc</cc>
    
    <cc>eric</cc>
    
    <cc>ggaren</cc>
    
    <cc>haraken</cc>
    
    <cc>mjs</cc>
    
    <cc>sam</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>724951</commentid>
    <comment_count>0</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-20 16:09:28 -0700</bug_when>
    <thetext>This bug is just a holder for DOM-in-JavaScript performance experiment patches.  If you don&apos;t care about DOM-in-JavaScript performance, you can safely ignore it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>724953</commentid>
    <comment_count>1</comment_count>
      <attachid>165006</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-20 16:10:49 -0700</bug_when>
    <thetext>Created attachment 165006
Patch to measure the cost of pimpl for Node (-3% on Dromaeo/dom-traverse; -5% on Dromaeo/dom-modify)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>724963</commentid>
    <comment_count>2</comment_count>
      <attachid>165007</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-20 16:27:34 -0700</bug_when>
    <thetext>Created attachment 165007
Patch to Dromaeo/dom-traverse to compare CPP DOM and JS DOM (29.32% better with JS DOM)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>724965</commentid>
    <comment_count>3</comment_count>
    <who name="Kentaro Hara">haraken</who>
    <bug_when>2012-09-20 16:30:18 -0700</bug_when>
    <thetext>ccing arv@, who has been also prototyping DOM-in-JavaScript.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>724990</commentid>
    <comment_count>4</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-20 17:04:03 -0700</bug_when>
    <thetext>Looks like arv has been running some experiments too:

https://github.com/arv/JS-DOM-Test</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>725490</commentid>
    <comment_count>5</comment_count>
    <who name="Erik Arvidsson">arv</who>
    <bug_when>2012-09-21 06:52:53 -0700</bug_when>
    <thetext>Let me see if I understand this correctly. The pure cpp impact is -5% but we get almost 30% faster from JS?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>725530</commentid>
    <comment_count>6</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-21 08:28:22 -0700</bug_when>
    <thetext>We don&apos;t have enough data to draw those conclusions, but so far that&apos;s about the scale of the performance changes.  These patches are just rough approximations.  Haraken has also suggested some more experiments, which I&apos;d like to run.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>726236</commentid>
    <comment_count>7</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2012-09-22 23:49:59 -0700</bug_when>
    <thetext>Can you explain a bit more about what this experiment is looking at?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>726283</commentid>
    <comment_count>8</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-23 12:10:05 -0700</bug_when>
    <thetext>&gt; Can you explain a bit more about what this experiment is looking at?

Currently all of the DOM structure is stored outside the JavaScript VM.  We&apos;re experimenting with the idea of uploading some amount of this state into the JavaScript VM.  At least from these simple experiments, there does appear to a significant amount of performance on the table.

I certainly don&apos;t have a complete design in mind.  At the moment, I&apos;m leaning towards some sort of state representation that can be shared by the JavaScript VM and the CPP implementation.  In particular, to get the full advantage of the JavaScript VM&apos;s memory management, we&apos;d likely want this state to be understandable (and compactable) by the garbage collector.

We&apos;re just exploring the design space.  The performance characteristics of JavaScript VMs have changed radically since the design of the current bindings.  It seems likely that there are different performance considerations now.  If you&apos;re interested in this topic, I&apos;m happy to involve you in more of the discussions.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>726311</commentid>
    <comment_count>9</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2012-09-23 16:14:10 -0700</bug_when>
    <thetext>(In reply to comment #8)
&gt; &gt; Can you explain a bit more about what this experiment is looking at?
&gt; 
&gt; Currently all of the DOM structure is stored outside the JavaScript VM.  We&apos;re experimenting with the idea of uploading some amount of this state into the JavaScript VM.  At least from these simple experiments, there does appear to a significant amount of performance on the table.
&gt; 
&gt; I certainly don&apos;t have a complete design in mind.  At the moment, I&apos;m leaning towards some sort of state representation that can be shared by the JavaScript VM and the CPP implementation.  In particular, to get the full advantage of the JavaScript VM&apos;s memory management, we&apos;d likely want this state to be understandable (and compactable) by the garbage collector.
&gt; 
&gt; We&apos;re just exploring the design space.  The performance characteristics of JavaScript VMs have changed radically since the design of the current bindings.  It seems likely that there are different performance considerations now.  If you&apos;re interested in this topic, I&apos;m happy to involve you in more of the discussions.

Please do.  And also please involve the folks working on JavaScriptCore.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>726337</commentid>
    <comment_count>10</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-23 19:19:24 -0700</bug_when>
    <thetext>Anyone in particular?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>726348</commentid>
    <comment_count>11</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2012-09-23 20:06:04 -0700</bug_when>
    <thetext>(In reply to comment #10)
&gt; Anyone in particular?

At the very least Geoff Garen.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>728966</commentid>
    <comment_count>12</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2012-09-26 14:13:16 -0700</bug_when>
    <thetext>Adam, I am intrigued by the possibility of 30% speedups. How do I interpret the results of the patched Dromaeo/dom-traverse? I get output like this, how do I interpret it? Which are the C++ DOM numbers and which are the JS DOM numbers?

--------
233.2742048370791
228.85231409663135
1419
1451.8
250.69890229530947

Time:
avg 3583.6254212290196 runs/s
median 0 runs/s
stdev 106.78560737165455 runs/s
min 3374.3917685085466 runs/s
max 3653.791186857055 runs/s</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>728974</commentid>
    <comment_count>13</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-26 14:21:37 -0700</bug_when>
    <thetext>&gt; Adam, I am intrigued by the possibility of 30% speedups.

Me too!  I should warn you that these are just experiments.  There isn&apos;t a real design here.  Just some evidence that we might want to look into moving move of the DOM into JavaScript.

&gt; How do I interpret the results of the patched Dromaeo/dom-traverse? I get output like this, how do I interpret it? Which are the C++ DOM numbers and which are the JS DOM numbers?

If you look in the dom-traverse patch, you&apos;ll see the following two lines:

+ document.body.cppFirstChild = document.body.firstChild;
+ document.body.jsFirstChild = mirror(document.body.firstChild);

What this means is that document.body.cppFirstChild points to the normal implementation of the DOM: namely backed by CPP code in WebCore.  On the other hand, document.body.jsFirstChild is a JavaScript-only mirror of the DOM structure, created just by wiring up firstChild/lastChild/nextSibling/previousSibling properties up on empty JavaScript objects.  (I haven&apos;t tested the mirror function, so it might have bugs.)

If you look in the nextSibling test, you&apos;ll see the following line of code:

+ var cur = document.body.jsFirstChild; // Change to document.body.cppFirstChild

That means the test is running with the JavaScript version of the DOM tree.  If you change jsFirstChild to cppFirstChild, you&apos;ll be running with the CPP version of the DOM tree.  You can run test once with jsFirstChild and once with cppFirstChild to compare the performance differences between the two implementations of the tree.

The way I&apos;ve been doing that with with the run-perf-tests script, which creates nice graphs for comparing the output:

$ ./Tools/Scripts/run-perf-tests PerformanceTests/Dromaeo/dom-traverse.html

You can also just compare the avg runs/s numerically.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>728975</commentid>
    <comment_count>14</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-26 14:23:10 -0700</bug_when>
    <thetext>(I should note that I changed both the nextSibling and the previousSibling tests at the same time.  You can also delete one or the other since they&apos;re very similar tests.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>728989</commentid>
    <comment_count>15</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2012-09-26 14:38:26 -0700</bug_when>
    <thetext>Thanks for the tips! Here are some results I got:

JS - Safari TOT
    avg 253710.8 runs/s

CPP - Safari TOT
    avg 499435.80000000005 runs/s

That looks like the JS-based version is about 50% slower, not 30% faster. Am I misunderstanding the test or what the claim was?

I wanted to try the test in Chrome Canary but it doesn&apos;t seem to run there.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729009</commentid>
    <comment_count>16</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-26 15:03:19 -0700</bug_when>
    <thetext>&gt; Here are some results I got:

Fascinating.

&gt; That looks like the JS-based version is about 50% slower, not 30% faster. Am I misunderstanding the test or what the claim was?

Here are the numbers I got (five minutes ago) with DumpRenderTree in the chromium port:

$ ./out/Release/DumpRenderTree file:///src/abarth-webkit/PerformanceTests/Dromaeo/dom-traverse.html

== js ==

avg 326188 runs/s
median 0 runs/s
stdev 1218.1536848854498 runs/s
min 325071 runs/s
max 328243 runs/s

== cpp ==

avg 266485.3966033966 runs/s
median 0 runs/s
stdev 671.5778183390692 runs/s
min 265506 runs/s
max 267288.48851148854 runs/s

That shows the JS implementation running faster than the CPP implementation.  I need re-run these tests on a Mac to compare the absolute numbers between JSC and V8.

We might be getting different outcomes here because there are two moving pieces:

1) The performance of the JSC and the V8 bindings code.
2) The performance of the underlying JavaScript engine.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729039</commentid>
    <comment_count>17</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2012-09-26 16:02:26 -0700</bug_when>
    <thetext>(In reply to comment #16)
&gt; &gt; Here are some results I got:
&gt; 
&gt; Fascinating.
&gt; 
&gt; &gt; That looks like the JS-based version is about 50% slower, not 30% faster. Am I misunderstanding the test or what the claim was?
&gt; 
&gt; Here are the numbers I got (five minutes ago) with DumpRenderTree in the chromium port:
&gt; 
&gt; $ ./out/Release/DumpRenderTree file:///src/abarth-webkit/PerformanceTests/Dromaeo/dom-traverse.html
&gt; 
&gt; == js ==
&gt; 
&gt; avg 326188 runs/s
&gt; median 0 runs/s
&gt; stdev 1218.1536848854498 runs/s
&gt; min 325071 runs/s
&gt; max 328243 runs/s
&gt; 
&gt; == cpp ==
&gt; 
&gt; avg 266485.3966033966 runs/s
&gt; median 0 runs/s
&gt; stdev 671.5778183390692 runs/s
&gt; min 265506 runs/s
&gt; max 267288.48851148854 runs/s
&gt; 
&gt; That shows the JS implementation running faster than the CPP implementation.  I need re-run these tests on a Mac to compare the absolute numbers between JSC and V8.
&gt; 
&gt; We might be getting different outcomes here because there are two moving pieces:
&gt; 
&gt; 1) The performance of the JSC and the V8 bindings code.
&gt; 2) The performance of the underlying JavaScript engine.

I will try to rearrange the test to be a single file and print both results, so it can easily be loaded in different browsers. Because I&apos;m also curious what the results are in different versions. And that is probably easier for me than building chromium webkit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729047</commentid>
    <comment_count>18</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-26 16:12:15 -0700</bug_when>
    <thetext>Ok, I just ran WebKit@129710 in a Mac Pro in both chromium-mac and apple-mac:

== js ==
chromium-mac: avg 190979.59999999998 runs/s
apple-mac: avg 178240.40000000002 runs/s

== cpp ==
chromium-mac: avg 148605.44592533214 runs/s
apple-mac: avg 388969 runs/s

The performance ordering appears to be:

apple-mac-cpp &gt; chromium-mac-js &gt; apple-mac-js &gt; chromium-mac-cpp</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729051</commentid>
    <comment_count>19</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-26 16:18:53 -0700</bug_when>
    <thetext>With a small tweak to how we build the JS objets, I can make the JS version outperform the CPP version in JSC as well:

chromium-mac-js2: 191981.8 runs/s
apple-mac-js2: 472447.4 runs/s

The difference is that js2 uses createMirrorDOMNode() to add the properties in the same order for every JavaScript &quot;DOM node.&quot;  (Attaching updated perf test shortly.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729057</commentid>
    <comment_count>20</comment_count>
      <attachid>165894</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-26 16:22:18 -0700</bug_when>
    <thetext>Created attachment 165894
Version in which JS outperforms CPP in JavaScriptCore as well</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729061</commentid>
    <comment_count>21</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-26 16:31:53 -0700</bug_when>
    <thetext>Recoding my command lines for copy-pasta later:

$ DYLD_FRAMEWORK_PATH=/Users/abarth/svn/webkit/WebKitBuild/Release ./WebKitBuild/Release/DumpRenderTree file:///Users/abarth/svn/webkit/PerformanceTests/Dromaeo/dom-traverse.html
$ ./out/Release/DumpRenderTree.app/Contents/MacOS/DumpRenderTree file:///Users/abarth/svn/webkit/PerformanceTests/Dromaeo/dom-traverse.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729114</commentid>
    <comment_count>22</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2012-09-26 18:14:59 -0700</bug_when>
    <thetext>(In reply to comment #18)
&gt; Ok, I just ran WebKit@129710 in a Mac Pro in both chromium-mac and apple-mac:
&gt; 
&gt; == js ==
&gt; chromium-mac: avg 190979.59999999998 runs/s
&gt; apple-mac: avg 178240.40000000002 runs/s
&gt; 
&gt; == cpp ==
&gt; chromium-mac: avg 148605.44592533214 runs/s
&gt; apple-mac: avg 388969 runs/s
&gt; 
&gt; The performance ordering appears to be:
&gt; 
&gt; apple-mac-cpp &gt; chromium-mac-js &gt; apple-mac-js &gt; chromium-mac-cpp

Seems the main issue identified here is that V8 DOM bindings are very slow compared to JSC DOM bindings.

(I will look into the version that seems to show a benefit in JSC as well.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729119</commentid>
    <comment_count>23</comment_count>
    <who name="Kentaro Hara">haraken</who>
    <bug_when>2012-09-26 18:24:35 -0700</bug_when>
    <thetext>&gt; &gt; apple-mac-cpp &gt; chromium-mac-js &gt; apple-mac-js &gt; chromium-mac-cpp
&gt;
&gt; Seems the main issue identified here is that V8 DOM bindings are very slow compared to JSC DOM bindings.

V8 DOM bindings are still very slower than JSC DOM bindings, that&apos;s true to some extent. (I&apos;ve been optimizing the performance for months.)

That being said, conceptually, I think that apple-mac-js should be faster than apple-mac-cpp. In apple-mac-cpp, .nextSibling needs to call back JSC binding, do some value conversion from JS to C++, do something in WebCore, do some value conversion from C++ to JS, and return back to JSC. On the other hand, in apple-mac-js, .nextSibling doesn&apos;t need to call back JSC binding. Everything completes without leaving the JIT code. In that sense, in the world where we optimize things appropriately, apple-mac-js will become faster than apple-mac-cpp.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729156</commentid>
    <comment_count>24</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-26 19:49:35 -0700</bug_when>
    <thetext>&gt; Seems the main issue identified here is that V8 DOM bindings are very slow compared to JSC DOM bindings.

That may well be true (and is something we can work on in another bug), but Comment #19 seems to indiciate that the first JS implementation was not being fully optimized by JSC.  In the second JS implementation, the JS version appears to be significantly faster than the CPP version, even in JSC.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729170</commentid>
    <comment_count>25</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2012-09-26 20:26:52 -0700</bug_when>
    <thetext>(In reply to comment #24)
&gt; &gt; Seems the main issue identified here is that V8 DOM bindings are very slow compared to JSC DOM bindings.
&gt; 
&gt; That may well be true (and is something we can work on in another bug), but Comment #19 seems to indiciate that the first JS implementation was not being fully optimized by JSC.  In the second JS implementation, the JS version appears to be significantly faster than the CPP version, even in JSC.

As mentioned, I&apos;m definitely interested in that and will look into it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729243</commentid>
    <comment_count>26</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2012-09-26 23:38:20 -0700</bug_when>
    <thetext>From &lt;http://trac.webkit.org/wiki/DOMInJavaScript?version=3&gt;, and the dom-traverse test case, it looks like the main goal here is to optimize DOM traversal. Are there other goals?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729255</commentid>
    <comment_count>27</comment_count>
    <who name="Kentaro Hara">haraken</who>
    <bug_when>2012-09-26 23:50:57 -0700</bug_when>
    <thetext>(In reply to comment #26)
&gt; From &lt;http://trac.webkit.org/wiki/DOMInJavaScript?version=3&gt;, and the dom-traverse test case, it looks like the main goal here is to optimize DOM traversal. Are there other goals?

FYI, this slide explains other motivations:  https://docs.google.com/a/chromium.org/presentation/d/1X3hExrBtjXIUVqmDArAdEh9JYQudhCPvgSguilK54iE/edit?pli=1#slide=id.p</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729258</commentid>
    <comment_count>28</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-26 23:57:35 -0700</bug_when>
    <thetext>Thanks for noticing the wiki page I&apos;m writing up.  I think I&apos;ve got it into a more sane shape now.  Here&apos;s a strawman design for we might actually be able to realize these speedups:

https://trac.webkit.org/wiki/DOMInJavaScript

&gt; it looks like the main goal here is to optimize DOM traversal. Are there other goals?

Speeding up DOM traversal is certainly near the top of my list because it&apos;s so widely used.  If we do a good job with DOM traversal, we might be able to re-use the mechanism in other places where it shows a speedup.  For example, haraken has some data showing that nodeType and className are the hotest DOM properties.  There might also be opportunities for optimizing these properties by uploading them into the JavaScript engine.

Another benefit of this approach is that it somewhat simplifies garbage collection (e.g., it might help fix Bug 88834).  The idea here is that by uploading the DOM tree into the JavaScript engine, the JavaScript engine&apos;s garbage collector has a better understanding of which objects are keeping which other objects alive.  The usefulness of this information depends on how the garbage collector works.  For example, a generational garbage collector might need only examine DOM edges in the new space rather than needing to crawl the entire DOM tree (i.e., the portion in the old space).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729264</commentid>
    <comment_count>29</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-27 00:01:22 -0700</bug_when>
    <thetext>&gt; FYI, this slide explains other motivations:  https://docs.google.com/a/chromium.org/presentation/d/1X3hExrBtjXIUVqmDArAdEh9JYQudhCPvgSguilK54iE/edit?pli=1#slide=id.p

I don&apos;t agree with some of the conclusions in this slide deck.  In particular, I&apos;m hopeful that DOM-in-JavaScript will actually be faster, especially for JS-heavy workloads.  That&apos;s why I created this bug initially: to experiment with performance.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729516</commentid>
    <comment_count>30</comment_count>
    <who name="Kentaro Hara">haraken</who>
    <bug_when>2012-09-27 07:41:25 -0700</bug_when>
    <thetext>&gt; https://trac.webkit.org/wiki/DOMInJavaScript

Thank you very much for the write up! The approach looks good.

One question: Are you intending to create wrapper objects for all DOM nodes? Or are you intending to create wrapper objects only for DOM nodes that are touched by JavaScript (as is done in the current JSC/V8+WebKit)?

The latter idea would be feasible in a following way (and might be better/worse in terms of performance). As a fast path, in a case where a wrapper object exists, .nextSibling is realized by normal JavaScript property access. As a slow path, in a case where a wrapper object does not exist, .nextSibling is realized by Node::nextSibling() as is done in the current WebKit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729522</commentid>
    <comment_count>31</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-27 07:51:17 -0700</bug_when>
    <thetext>&gt; One question: Are you intending to create wrapper objects for all DOM nodes? Or are you intending to create wrapper objects only for DOM nodes that are touched by JavaScript (as is done in the current JSC/V8+WebKit)?

The proposal in the wiki page is to create wrappers for all DOM nodes.  Before doing that, of course, we&apos;ll need to look at the impact on memory and performance.

&gt; The latter idea would be feasible in a following way (and might be better/worse in terms of performance). As a fast path, in a case where a wrapper object exists, .nextSibling is realized by normal JavaScript property access. As a slow path, in a case where a wrapper object does not exist, .nextSibling is realized by Node::nextSibling() as is done in the current WebKit.

The trade-off is in that approach need to reserve space both in Node and in its wrapper for nextSibling.  Depending on the wrapper rate, this can either be a win or a loss.

We&apos;ll probably need to try a few designs before we find the best one.  Would you mind adding a section comparing the optional-wrapper and mandatory-wrapper approaches to the wiki page?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729526</commentid>
    <comment_count>32</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-27 07:55:37 -0700</bug_when>
    <thetext>I should also say that if you have storage for nextSibling in Node, another approach is to keep both copies up to date.  In that case, JS would read the data from the JS object and CPP would read the data from the CPP object.  The write operation (e.g., setNextSibling) would write to both locations.  For purposes of discussion, we might want to call this the &quot;write through&quot; approach (and we should probably add it to the wiki as well).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729528</commentid>
    <comment_count>33</comment_count>
    <who name="Kentaro Hara">haraken</who>
    <bug_when>2012-09-27 07:57:45 -0700</bug_when>
    <thetext>(In reply to comment #31)
&gt; We&apos;ll probably need to try a few designs before we find the best one.  Would you mind adding a section comparing the optional-wrapper and mandatory-wrapper approaches to the wiki page?

Sure! Another disadvantage of the optional-wrapper approach is that it won&apos;t contribute to simplifying the GC. Either way I&apos;ll write them up tomorrow.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729989</commentid>
    <comment_count>34</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2012-09-27 16:35:51 -0700</bug_when>
    <thetext>Adding Gavin Barraclough to Cc, I had a good conversation with him recently about plans to speed up DOM property access for JavaScriptCore.

He said that JSC folks have discussed letting the JIT have sufficient understanding of some DOM accessors to make them efficient without having to modify the layout of DOM nodes or implement anything in JS.


From what I can gather of the approach outlined in this bug, it seems that it would likely have a memory cost, and a speed cost for DOM traversal and mutation from C++. I am concerned about these potential costs, because it seems they would affect speed of core operations like HTML parsing and style resolution. Since JSC+WebKit, as far as I know, already has the fastest DOM traversal of any browser engine even with no changes, it would be a tough call whether a further ~1.2x speedup to DOM traversal would outweigh such costs. Maybe there is a plan to mitigate these downsides. If so, I am interested in learning more about that.


Anyway - though the approach Gavin described to me sounds like it may more technically challenging (you&apos;d have to understand and modify JIT code), it seems much less likely to hurt memory use or access speed from C++ code. So I found it to be a very intriguing idea.

Since the JavaScriptCore team has a track record of success in making really wicked fast DOM bindings, I think it is worth considering their input in this area.

It might also be useful to have some conversations about this by email or in person, and not just in bug comments.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>729997</commentid>
    <comment_count>35</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2012-09-27 16:39:10 -0700</bug_when>
    <thetext>(In reply to comment #29)
&gt; &gt; FYI, this slide explains other motivations:  https://docs.google.com/a/chromium.org/presentation/d/1X3hExrBtjXIUVqmDArAdEh9JYQudhCPvgSguilK54iE/edit?pli=1#slide=id.p
&gt; 
&gt; I don&apos;t agree with some of the conclusions in this slide deck.  In particular, I&apos;m hopeful that DOM-in-JavaScript will actually be faster, especially for JS-heavy workloads.  That&apos;s why I created this bug initially: to experiment with performance.

One experiment that would help us learn about likely perf characteristics of a DOM implemented completely in JavaScript would be to try reimplementing some more complex DOM methods in JS. Seems like a trivial accessor like firstChild is the best possible case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>730035</commentid>
    <comment_count>36</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-27 17:09:06 -0700</bug_when>
    <thetext>Interesting. I hadn&apos;t considered the approach of teaching the JIT more about the structure of DOM objects.

As haraken writes in Comment #23, you&apos;re still going to run up against the limitation of needing to follow a pointer from the JSObject to the Node and then back to the other JSObject. As long as there are two objects and only one representation of the tree, one of the two kinds of objects is going to need to transit the graph by way of the other.

I guess the logical conclusion of that thought process is that we should try to merge the wrapper object and the wrapped object so that neither needs to consult the other in order to transit the graph.

&gt; One experiment that would help us learn about likely perf characteristics of a DOM implemented completely in JavaScript would be to try reimplementing some more complex DOM methods in JS. Seems like a trivial accessor like firstChild is the best possible case.

I wasn&apos;t suggesting implementing the entire DOM in JavaScript. The proposal in &lt;http://trac.webkit.org/wiki/DOMInJavaScript&gt; just suggests moving the tree representation.

In any case, all of this is very much open for discussion and I welcome everyone&apos;s input, especially JSC hackers.  :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>730634</commentid>
    <comment_count>37</comment_count>
    <who name="Kentaro Hara">haraken</who>
    <bug_when>2012-09-28 07:18:57 -0700</bug_when>
    <thetext>(In reply to comment #31)
&gt; We&apos;ll probably need to try a few designs before we find the best one.  Would you mind adding a section comparing the optional-wrapper and mandatory-wrapper approaches to the wiki page?

Done. Please edit it freely.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>730873</commentid>
    <comment_count>38</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2012-09-28 12:15:48 -0700</bug_when>
    <thetext>Can you state the goal of these experiments?  What benchmarks/scenarios are you trying to improve on? It seems a bit odd to me to start with a solution.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>730901</commentid>
    <comment_count>39</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-09-28 12:41:05 -0700</bug_when>
    <thetext>&gt; Can you state the goal of these experiments?  What benchmarks/scenarios are you trying to improve on?

See Comment #28.

&gt; It seems a bit odd to me to start with a solution.

This bug is about experimenting with an alternative approach for implement some DOM bindings. The goal is to learn about the performance characteristics of the approach by comparing its scores on various benchmarks. The approach might turn out to be a better or worse performance trade-off than the current approach. That&apos;s what I&apos;m hoping to learn from these experiments.

I could have chosen to perform these experiments in a secret branch of WebKit, but I decided to perform them here on this bug so that other folks in the community can participate in the discussion if they so choose.  As I wrote in Comment #0, if you&apos;re not interested in the performance characteristics of this approach, you can safely ignore this bug thread.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>165006</attachid>
            <date>2012-09-20 16:10:49 -0700</date>
            <delta_ts>2012-09-20 16:10:49 -0700</delta_ts>
            <desc>Patch to measure the cost of pimpl for Node (-3% on Dromaeo/dom-traverse; -5% on Dromaeo/dom-modify)</desc>
            <filename>pimpl.patch</filename>
            <type>text/plain</type>
            <size>3225</size>
            <attacher name="Adam Barth">abarth</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJDb3JlL2RvbS9Eb2N1bWVudC5oIGIvU291cmNlL1dlYkNv
cmUvZG9tL0RvY3VtZW50LmgKaW5kZXggZDgxMTljMy4uNDNmMjYzMCAxMDA2NDQKLS0tIGEvU291
cmNlL1dlYkNvcmUvZG9tL0RvY3VtZW50LmgKKysrIGIvU291cmNlL1dlYkNvcmUvZG9tL0RvY3Vt
ZW50LmgKQEAgLTE2MDcsMTAgKzE2MDcsMTIgQEAgaW5saW5lIGJvb2wgTm9kZTo6aXNEb2N1bWVu
dE5vZGUoKSBjb25zdAogaW5saW5lIE5vZGU6Ok5vZGUoRG9jdW1lbnQqIGRvY3VtZW50LCBDb25z
dHJ1Y3Rpb25UeXBlIHR5cGUpCiAgICAgOiBtX25vZGVGbGFncyh0eXBlKQogICAgICwgbV9kb2N1
bWVudChkb2N1bWVudCkKLSAgICAsIG1fcH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HByZXZp
b3VzOyB9CisgICAgdm9pZCBzZXROZXh0U2libGluZyhOb2RlKiBuZXh0KSB7IG1faW1wbC0+bV9u
ZXh0ID0gbmV4dDsgfQogCiAgICAgdmlydHVhbCBib29sIGNhbkNvbnRhaW5SYW5nZUVuZFBvaW50
KCkgY29uc3QgeyByZXR1cm4gZmFsc2U7IH0KIApAQCAtODAyLDggKzgwMiwxMSBAQCBwcml2YXRl
OgogCiAgICAgbXV0YWJsZSB1aW50MzJfdCBtX25vZGVGbGFnczsKICAgICBEb2N1bWVudCogbV9k
b2N1bWVudDsKLSAgICBOb2RlKiBtX3ByZXZpb3VzOwotICAgIE5vZGUqIG1fbmV4dDsKKyAgICBz
dHJ1Y3QgTm9kZUltcGwgeworICAgICAgICBOb2RlKiBtX3ByZXZpb3VzOworICAgICAgICBOb2Rl
KiBtX25leHQ7CisgICAgfTsKKyAgICBPd25QdHI8Tm9kZUltcGw+IG1faW1wbDsKICAgICBSZW5k
ZXJPYmplY3QqIG1fcmVuZGVyZXI7CiAKIHB1YmxpYzoK
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>165007</attachid>
            <date>2012-09-20 16:27:34 -0700</date>
            <delta_ts>2012-09-20 16:27:34 -0700</delta_ts>
            <desc>Patch to Dromaeo/dom-traverse to compare CPP DOM and JS DOM (29.32% better with JS DOM)</desc>
            <filename>dom-traverse.patch</filename>
            <type>text/plain</type>
            <size>2881</size>
            <attacher name="Adam Barth">abarth</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1BlcmZvcm1hbmNlVGVzdHMvRHJvbWFlby9yZXNvdXJjZXMvZHJvbWFlby93
ZWIvdGVzdHMvZG9tLXRyYXZlcnNlLmh0bWwgYi9QZXJmb3JtYW5jZVRlc3RzL0Ryb21hZW8vcmVz
b3VyY2VzL2Ryb21hZW8vd2ViL3Rlc3RzL2RvbS10cmF2ZXJzZS5odG1sCmluZGV4IDk5ZmE4ZDgu
L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lsZSAoIGN1ciApCiAJCQkJY3VyID0gY3VyLnByZXZp
b3VzU2libGluZzsKIAkJCXJldCA9IGN1cjsKIAkJfQogCX0pOwogCi0JdGVzdCggImNoaWxkTm9k
ZXMiLCBmdW5jdGlvbigpewotCQlmb3IgKCB2YXIgaSA9IDA7IGkgPCBudW07IGkrKyApIHsKLQkJ
CXZhciBub2RlcyA9IGRvY3VtZW50LmJvZHkuY2hpbGROb2RlczsKLQkJCWZvciAoIHZhciBqID0g
MDsgaiA8IG5vZGVzLmxlbmd0aDsgaisrICkKLQkJCQlyZXQgPSBub2Rlc1tqXTsKLQkJfQotCX0p
OwotCiBlbmRUZXN0KCk7CiB9OwogPC9zY3JpcHQ+Cg==
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>165894</attachid>
            <date>2012-09-26 16:22:18 -0700</date>
            <delta_ts>2012-09-26 16:22:18 -0700</delta_ts>
            <desc>Version in which JS outperforms CPP in JavaScriptCore as well</desc>
            <filename>bug-97270-20120926162137.patch</filename>
            <type>text/plain</type>
            <size>3129</size>
            <attacher name="Adam Barth">abarth</attacher>
            
              <data encoding="base64">SW5kZXg6IFBlcmZvcm1hbmNlVGVzdHMvRHJvbWFlby9yZXNvdXJjZXMvZHJvbWFlby93ZWIvdGVz
dHMvZG9tLXRyYXZlcnNlLmh0bWwKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gUGVyZm9ybWFuY2VUZXN0cy9Ecm9t
YWVvL3Jlc291cmNlcy9kcm9tYWVvL3dlYi90ZXN0cy9kb20tdHJhdmVyc2UuaHRtbAkocmV2aXNp
b24gMTI5NzEwKQorKysgUGVyZm9ybWFuY2VUZXN0cy9Ecm9tYWVvL3Jlc291cmNlcy9kcm9tYWVv
L3dlYi90ZXN0cy9kb20tdHJhdmVyc2UuaHRtbAkod29ya2luZyBjb3B5KQpAQCAtMiw2ICs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