Closed
Bug 129496
Opened 23 years ago
Closed 17 years ago
JS object initializer dynamic overhead (affects a DHTML test case)
Categories
(Core :: JavaScript Engine, defect, P2)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla1.9beta4
People
(Reporter: markushuebner, Assigned: brendan)
References
()
Details
(Keywords: js1.5, perf, testcase)
Attachments
(6 files, 5 obsolete files)
See attached e-mail conversation ...
Reporter | ||
Comment 1•23 years ago
|
||
Reporter | ||
Updated•23 years ago
|
Blocks: 21762
Keywords: mozilla1.0,
perf
Comment 2•23 years ago
|
||
The URL is hanging the browser with 2002030603 or 2002030703 NT4.
Assignee | ||
Comment 3•23 years ago
|
||
It would help if we knew why this test URL allocates strings and objects like
mad. I am pretty sure that even with generational GC, the testcase is going to
pay a high (but smoothed-out into little disruptions to the schedule) overhead
in GC. If we find that it is just doing crasy O(n^2) or worse explosive growth
in JS object/string allocation, it should be fixed to do something smarter. If
this has to do with DOM nodelists being document listeners, there's a bug on
that already, I believe.
Let's get to the bottom of this testcase, not just point fingers at the JS GC.
/be
Comment 4•23 years ago
|
||
The base problem appears (at a glance) to be in this:
coord = function (x,y) { if(!x) var x=0; if(!y) var y=0; return {x: x, y: y}; }
function getBezier(percent,C1,C2,C3,C4)
{ var pos = new coord();
pos.x = ...
pos.y = ...
return pos;
}
Then lots of calls to getBezier().
OS: Windows 2000 → All
Hardware: PC → All
Assignee | ||
Comment 5•23 years ago
|
||
>coord = function (x,y) { if(!x) var x=0; if(!y) var y=0; return {x: x, y: y}; }
>
>function getBezier(percent,C1,C2,C3,C4)
> { var pos = new coord();
> pos.x = ...
> pos.y = ...
> return pos;
>}
The new operator causes a new object to be made and passed as the this parameter
to the constructor, but in the case of coord, that object is wasted, because
coord returns an object created with an object initializer. The JS engine could
do better here:
- it migth be able to analyze the constructor (this one is easy, there are
obvious hard cases) to see that it "overrides this" by returning a different object;
- it certainly could literalize a prototype object corresponding to the object
initializer (aka object literal) and avoid creating a new object with its own
scope for each coord call -- instead, it would clone the prototype and set its
slots.
Can someone try eliminating the operator new usage and see how much that helps?
Also, any commentary on how 0.9.9-candidates (anything since bug 62164's patch
landed) does compared to 0.9.8? It should help, but maybe not enough to matter
at the limit.
/be
Reporter | ||
Comment 6•23 years ago
|
||
Tried the testcase with 0.9.8 and 0.9.9 and both have the same problems as
already described.
Comment 7•23 years ago
|
||
I'm not sure if this is what Brendan asked for in comment #5.
I elliminated the "new" operator in the getBezier function.
I couldn't measure any performance improvements..
Assignee | ||
Comment 8•23 years ago
|
||
Removing the new helps, but not enough -- there are simply too many new objects
created by the {x: x, y: y} literal. I have a plan to fix that bloat issue in
bug 123668.
/be
Reporter | ||
Updated•22 years ago
|
Keywords: mozilla1.0 → mozilla1.1
Assignee | ||
Comment 10•22 years ago
|
||
I should put a work-in-progress patch in here, just for backup purposes. It
won't help on footprint yet.
/be
Assignee | ||
Updated•22 years ago
|
Summary: JS GC issue relating to DHTML → JS object initializer dynamic overhead (affects a DHTML test case)
Assignee | ||
Comment 11•22 years ago
|
||
Moving out, some of these may move to 1.3alpha shortly.
/be
Target Milestone: mozilla1.2alpha → mozilla1.2beta
Reporter | ||
Updated•22 years ago
|
Keywords: mozilla1.2 → mozilla1.3
Reporter | ||
Comment 12•22 years ago
|
||
Bug 184352 seems to be affected by this too - dupe of this one?
Assignee | ||
Comment 13•22 years ago
|
||
bug 184352 is Mac-only, it can't have anything to do with this bug.
/be
Assignee | ||
Comment 15•22 years ago
|
||
Noting true dependency.
/be
Assignee | ||
Updated•22 years ago
|
Keywords: mozilla1.3 → js1.5
Target Milestone: mozilla1.3beta → mozilla1.4alpha
Reporter | ||
Comment 16•22 years ago
|
||
Can we get this into 1.4beta ?
Assignee | ||
Updated•22 years ago
|
Target Milestone: mozilla1.4alpha → mozilla1.4beta
Assignee | ||
Updated•22 years ago
|
Target Milestone: mozilla1.4beta → mozilla1.5alpha
Assignee | ||
Updated•21 years ago
|
Target Milestone: mozilla1.5alpha → mozilla1.6alpha
Assignee | ||
Comment 18•21 years ago
|
||
Rather work on Narcissus.
/be
Target Milestone: mozilla1.7alpha → Future
Reporter | ||
Comment 19•20 years ago
|
||
Testing the mentioned example at
http://3dhtml.netzministerium.de/examples/beziercube3d.html
as well as all other examples at http://3dhtml.netzministerium.de/
like http://3dhtml.netzministerium.de/examples/solarsystem3d.html
with trunk build 2004112405 on winxp pro still is very choppy!
Maybe a profile shows were we are currently lacking.
Assignee | ||
Comment 20•20 years ago
|
||
This is low priority for a SpiderMonkey fix, but should be addressed in any new
runtime designed for JS2.
/be
Priority: -- → P5
Reporter | ||
Comment 21•19 years ago
|
||
Running with Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1)
Gecko/20050907 Firefox/1.6a1 this is as it was.
Also CPU usage is 70-80%
Reporter | ||
Comment 22•19 years ago
|
||
Updating testcase URL
Comment 23•17 years ago
|
||
I have around 15% CPU usage but the animation is choppy.
Assignee | ||
Updated•17 years ago
|
Assignee: brendan → general
Status: ASSIGNED → NEW
Component: DOM: Core → JavaScript Engine
Flags: wanted1.9+
Flags: blocking1.9?
Priority: P5 → P2
QA Contact: stummala → general
Target Milestone: Future → mozilla1.9beta4
Assignee | ||
Updated•17 years ago
|
Assignee: general → brendan
Assignee | ||
Comment 24•17 years ago
|
||
The URL loads but nothing works, tons of ns and ie not defined errors. Anyone have a diagnosis or (better) fixed test?
/be
Comment 25•17 years ago
|
||
De-ns4-ified and all external files inlined version of SolarSystem3d.html.
Assignee | ||
Comment 26•17 years ago
|
||
Just wondering why the URL worked for crowder but not me -- anyone else have testimony?
/be
Status: NEW → ASSIGNED
Assignee | ||
Comment 27•17 years ago
|
||
# baseline unpatched js shell:
$ ../src.bench/Darwin_OPT.OBJ/js /tmp/initests.js
1e6 small object initialisers: 1341
before 33316864, after 16384, break 07c05000
1e6 larger-than-fslots initialiser: 2375
before 33316864, after 16384, break 07c05000
1e6 small object constructions: 835
before 33316864, after 16384, break 07c05000
1e6 larger-than-fslots constructions: 1586
# with forthcoming patch:
$ ./Darwin_OPT.OBJ/js /tmp/initests.js
1e6 small object initialisers: 772
before 33316864, after 16384, break 07c05000
1e6 larger-than-fslots initialiser: 982
before 33316864, after 16384, break 07c05000
1e6 small object constructions: 882
before 33316864, after 16384, break 07c05000
1e6 larger-than-fslots constructions: 1307
Lopped 42% off the small fits-in-fslots case, 59% off the bigger case.
Note also the last number improving due to fslots-exceeded hazard elimination under JSOP_SETNAME/JSOP_SETPROP.
/be
Assignee | ||
Comment 28•17 years ago
|
||
Would appreciate anyone with time and interest applying this patch and testing it, solarsystem3d.html and general dogfooding. I will do that tomorrow but not today, trying to get a hard patch finished. Thanks,
/be
Attachment #304594 -
Flags: review?(shaver)
Assignee | ||
Comment 29•17 years ago
|
||
Should the URL link to the attachment now? I defer to bugzilla protocol experts.
/be
Flags: blocking1.9? → blocking1.9+
Assignee | ||
Updated•17 years ago
|
Flags: blocking1.9+ → blocking1.9?
Comment 30•17 years ago
|
||
Comment on attachment 304594 [details] [diff] [review]
fix
This crashed me.
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000
Crashed Thread: 0
Thread 0 Crashed:
0 libmozjs.dylib 0x0013b2f2 ChangeScope + 139 (jsscope.c:361)
1 libmozjs.dylib 0x0013c1b1 js_AddScopeProperty + 201 (jsscope.c:1024)
2 libmozjs.dylib 0x00114340 js_SetPropertyHelper + 1087 (jsobj.c:3858)
3 libmozjs.dylib 0x00101760 js_Interpret + 26860 (jsinterp.c:4374)
4 libmozjs.dylib 0x0010770d js_Invoke + 2150 (jsinterp.c:1432)
5 libmozjs.dylib 0x00107a8e js_InternalInvoke + 124 (jsinterp.c:1489)
6 libmozjs.dylib 0x00107bc6 js_InternalGetOrSet + 200 (jsinterp.c:1546)
7 libmozjs.dylib 0x0010ec29 js_NativeGet + 215 (jsobj.c:3523)
8 libmozjs.dylib 0x00113e0a js_GetPropertyHelper + 674 (jsobj.c:3672)
9 libmozjs.dylib 0x001008e0 js_Interpret + 23148 (jsinterp.c:4082)
10 libmozjs.dylib 0x0010770d js_Invoke + 2150 (jsinterp.c:1432)
11 XUL 0x01a4c176 nsXPCWrappedJSClass::CallMethod
Assignee | ||
Comment 31•17 years ago
|
||
Comment on attachment 304594 [details] [diff] [review]
fix
More a WIP, and backup. I'll debug.
/be
Attachment #304594 -
Flags: review?(shaver)
Assignee | ||
Comment 32•17 years ago
|
||
This tests better, and I need to get it out of my tree and brain. Sayrer, can you give it a whirl? Thanks,
/be
Attachment #304594 -
Attachment is obsolete: true
Attachment #305044 -
Flags: review?(shaver)
Assignee | ||
Comment 33•17 years ago
|
||
Removed another hazard in the {add,set,ini}pchit case, fixed last version's bogus hit test condition.
/be
Attachment #305044 -
Attachment is obsolete: true
Attachment #305044 -
Flags: review?(shaver)
Comment 34•17 years ago
|
||
This patch does not malfunction, but doesn't seem to help the tests in this bug.
Assignee | ||
Comment 35•17 years ago
|
||
Attachment #305055 -
Attachment is obsolete: true
Attachment #305305 -
Flags: review?(shaver)
Comment 36•17 years ago
|
||
Comment on attachment 305305 [details] [diff] [review]
free slot on error
r=shaver, thanks for the call to go through this.
Attachment #305305 -
Flags: review?(shaver) → review+
Assignee | ||
Comment 37•17 years ago
|
||
The clasp->reserveSlots hazard that the JSOP_SETNAME/JSOP_SETPROP logic faces was not addressed by previous patches. This patch resolves it by detecting when the cached sprop's slot does not match the next one allocated for obj, in which case it updates the cache entry. Tests well (mochi and suite plus random dogfooding), soliciting re-review.
/be
Attachment #305305 -
Attachment is obsolete: true
Attachment #305879 -
Flags: review?(shaver)
Assignee | ||
Comment 38•17 years ago
|
||
Assignee | ||
Comment 39•17 years ago
|
||
Attachment #305882 -
Attachment is obsolete: true
Comment 40•17 years ago
|
||
Comment on attachment 305879 [details] [diff] [review]
fix bug found with further firefox testing
Looks good, well-caught. r=shaver
Attachment #305879 -
Flags: review?(shaver) → review+
Assignee | ||
Comment 41•17 years ago
|
||
Fixed on trunk:
js/src/jsapi.c 3.424
js/src/jsgc.c 3.283
js/src/jsgc.h 3.107
js/src/jsinterp.c 3.444
js/src/jsinterp.h 3.77
js/src/jsobj.c 3.443
js/src/jsopcode.tbl 3.109
js/src/jsscope.c 3.85
js/src/jsscope.h 3.57
Anything else to report about object initialisers (more could be done, probably under bug 412868), file a new bug after looking for existing to avoid dup'ing.
/be
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•