Last Comment Bug 503470 - 3D JavaScript demo (also known as Chrome Experiment "monster") doesn't perform
: 3D JavaScript demo (also known as Chrome Experiment "monster") doesn't perform
Status: RESOLVED FIXED
[chromeexperiments]
: perf
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: unspecified
: x86 All
: -- normal with 3 votes (vote)
: ---
Assigned To: general
:
: Jason Orendorff [:jorendorff]
Mentors:
http://deanm.github.com/pre3d/monster...
: 503837 599239 (view as bug list)
Depends on: 495329 503408
Blocks: 467263 chromex
  Show dependency treegraph
 
Reported: 2009-07-09 22:35 PDT by Jeff Balogh (:jbalogh)
Modified: 2011-11-23 16:20 PST (History)
16 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
The script (44.44 KB, text/plain)
2009-07-10 20:21 PDT, Boris Zbarsky [:bz] (still a bit busy)
no flags Details
testcase HTML (1.43 KB, text/html)
2009-07-10 20:22 PDT, Boris Zbarsky [:bz] (still a bit busy)
no flags Details

Description Jeff Balogh (:jbalogh) 2009-07-09 22:35:46 PDT
Not really a specific bug, just a script where FF can't keep up with Safari.  I couldn't find any references in bugzilla, wanted to make sure you guys are aware.

About 15 seconds into the demo at http://deanm.github.com/pre3d/monster.html js performance dies and the demo goes into slow motion (not a feature).  The code is at http://deanm.github.com/pre3d/monster.js but is currently obfuscated.
Comment 1 Ryan VanderMeulen [:RyanVM] 2009-07-10 18:26:45 PDT
bz with profiling FTW?
Comment 2 Boris Zbarsky [:bz] (still a bit busy) 2009-07-10 20:21:19 PDT
Maybe... 

So 28% of our time is spent in (not just under; that's 89%) js_Interpret.  That's an obvious issue right there.  Typical trace aborts:

abort: 6489: fp->scopeChain is not global or active call object
Abort recording of tree file:///Users/bzbarsky/test.js:567@30 at file:///Users/bzbarsky/test.js:574@97: callname.

and

abort: 9092: can't trace inherited property set
Abort recording of tree file:///Users/bzbarsky/test.js:1247@844 at file:///Users/bzbarsky/test.js:949@81: SetPropHit.

and

Abort recording of tree file:///Users/bzbarsky/test.js:498@237 at file:///Users/bzbarsky/test.js:505@284: No compatible inner tree.

and

abort: 10728: JSOP_BINDNAME must return global object on trace
Abort recording of tree file:///Users/bzbarsky/test.js:428@141 at file:///Users/bzbarsky/test.js:263@0: bindname.

Stats look like this after a short-ish run (just to the part where things get real slow):

recorder: started(123), aborted(47), completed(302), different header(0), trees trashed(0), slot promoted(0), unstable loop variable(86), breaks(0), returns(0), unstableInnerCalls(5), blacklisted(13)
monitor: triggered(349277), exits(349274), type mismatch(0), global mismatch(1)

ccing some folks who might know of specific bugs on the aborts above. Will attach a js-beautified testcase that I used to get the above output (yay not having all the code on one line).

Other than the 28% above, 11% of the time is js_NewObject (probably from all the object literals; about 1/3 of this is GC), 10% is fill() calls on the canvas, 8% is jitted code plus entering and leaving trace, 4.4% getting mutable scopes, 4% sorting arrays, 4% joining arrays, 4% js_NativeSet, 3% creating new jsdoubles, 25 js_NativeGet, 2% creating array objects, 1% array_extra and so forth; lots of things taking just a bit of time (canvas ops at the 0.5-1% level each, and there are 4-5 of them, that sort of thing).

Summary: we need to stay on trace, then reprofile.
Comment 3 Boris Zbarsky [:bz] (still a bit busy) 2009-07-10 20:21:58 PDT
Created attachment 388022 [details]
The script
Comment 4 Boris Zbarsky [:bz] (still a bit busy) 2009-07-10 20:22:38 PDT
Created attachment 388023 [details]
testcase HTML
Comment 5 David Mandelin [:dmandelin] 2009-07-13 13:18:19 PDT
abort: 6489: fp->scopeChain is not global or active call object
Abort recording of tree file:///Users/bzbarsky/test.js:567@30 at
file:///Users/bzbarsky/test.js:574@97: callname.

It would be helpful to know what the code looks like that causes this problem. I'm working on related stuff in JSOP_NAME, but I can't be sure my current patch will fix this particular problem without more info.
Comment 6 Boris Zbarsky [:bz] (still a bit busy) 2009-07-13 13:51:55 PDT
> It would be helpful to know what the code looks like that causes this problem.

It's attached to this bug...  Line 574:

            var aK = b(aU, aV);

Here aU and aV are vars declared in the same loop.  b is a function.  The setup in general is sorta like this:

Soft3d = (function() {
  function b(x,y) {
    /* do stuff */
  }
  // ...
  B.prototype.rebuildMeta = function ap() {
    // ...
    for (var aN = 0; aN < aW; ++aN) {
      // ....
      var aK = b(aU, aV);
    }
  }

  return {};
})();
Comment 7 José Jeria 2009-07-16 08:12:30 PDT
*** Bug 503837 has been marked as a duplicate of this bug. ***
Comment 8 deanm 2009-07-20 02:01:56 PDT
Pre3d is open source:

http://github.com/deanm/pre3d/tree/master

I would probably start by trying to profile spin_ring:

http://deanm.github.com/pre3d/demos/loader.html#spin_ring.js
Comment 9 Boris Zbarsky [:bz] (still a bit busy) 2010-09-27 12:01:25 PDT
Current JM profile of this thing is something like (all percentages are "under" unless they
explicitly say "in"):

  20% in mjit-generated code
  20% Fill on the canvas
  10% NewInitObject + GC   9% painting
   5% SetName<0> (half is allocating slots and half is setting canvas styles)
   5% InitPropOrMethod
   4% stubs::CallName (mostly under NameOp getting call vars, looks like)
   3% array_join
   3% stubs::NewArray
   3% array_sort
   3% array_extra (mostly creating array objects)
   2% FillRect on canvas
   2% NewObject
   3% finalizer thread
Comment 10 Boris Zbarsky [:bz] (still a bit busy) 2010-09-27 12:01:38 PDT
*** Bug 599239 has been marked as a duplicate of this bug. ***
Comment 11 Ryan VanderMeulen [:RyanVM] 2011-11-22 19:22:20 PST
Very smooth with JM+TI on my Win7 D2D system. Not sure if there's more to do here or not.

Note You need to log in before you can comment on or make changes to this bug.