Closed Bug 875815 Opened 11 years ago Closed 5 months ago

Terrible performance on mootools $$("*") call

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: bzbarsky, Unassigned)

References

(Depends on 1 open bug)

Details

Looking at http://dromaeo.com/?id=195568,195582 and in particular at the "DOM Query (Mootools)" section the first item is "Mootools - *".  On this item we're 10x slower than Chrome, though on the other items we're pretty similar, mostly.

A profile shows that it's all a mess.  Specifically:

1)  14% of the time is spent taking the slow fallback path through ion::GetPropertyIC::update.  I'm not quite sure why, though at least part of this seems to be calling HTMLFormElement resolve hooks or something?  And more is nativeLoookup.

2)  17% of the time is self time in js::Interpret(!).  The interpreter is also calling a bunch of ion::CanEnter, TypeMonitorResult, proxy_GetElement (which lands in HTMLCollectionBinding, doing an own-prop get), etc, etc.  The total fraction of time under js::Interpret but not under JITs is about 31% (!!).

3)  About 18% of the time is self time in baseline jitcode.

4)  6% js::ion::ProxyGet calling into HTMLCollectionBinding.

5)  6% js::ion:DoGetNameFallback calling into js::GetScopeName (which is 3% of
    total time).

6)  Various DoTypeUpdateFallback and DoTypeMonitorFallback being called from
    baseline jitcode, afaict, is another 6-7%.

I guess the most important question to start with is why we're spending so much of our time in baseline, and worse yet in interp....
Some more data.  $$ looks like this:

  if (arguments.length == 1 && typeof selector == 'string')
    return this.document.getElements(selector);

(that's the path we should end up taking every time through it) and then the only other weird part in the function is:

  var args = Array.flatten(arguments);

Not sure whether this prevents ion-compilation of $$ itself.

getElements looks like this:

  	getElements: function(tags, nocash){
		tags = tags.split(',');
		var elements = [];
		var ddup = (tags.length > 1);
		tags.each(function(tag){
			var partial = this.getElementsByTagName(tag.trim());
			(ddup) ? elements.extend(partial) : elements = partial;
		}, this);
		return new Elements(elements, {ddup: ddup, cash: !nocash});
	}

In this case this should end up doing a single call to getElementsByTagName and then call the |new Elements| thing.  Then there's a bunch of stuff that happend in the initialize() function in Elements, including walking the list with [i], etc...  Not sure which parts of this are ending up in interp, exactly and why.
Depends on: 649887
All of that code should compile with both Ion and Baseline.
Assignee: general → kvijayan
Testing Firefox 34 x Chrome 39:
http://dromaeo.com/?id=232094,232093
Mootools - *	314.03runs/s ±73.30%	1188.82runs/s ±3.18%	
Firefox still almost 4x slower.
We should probably retest now that bug 1323190 is fixed.
Depends on: 1323190
Flags: needinfo?(evilpies)
Bug 965992 also blocks a mootools bug, so we might want to wait for that to land as well.
Depends on: 965992
Mootools - * is still pretty slow:  432.44runs/s with just the IC from bug 1323190 and 491.11runs/s when using my local Proxy::get inlining patch.
Flags: needinfo?(evilpies)
Depends on: 1328858
Assignee: kvijayan → nobody
Severity: normal → S3

We're still slower; 4500 vs 6500. But we're not nearly at 10x, and mootools is fading away AIUI.

Status: NEW → RESOLVED
Closed: 5 months ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.