Closed
Bug 1090583
Opened 11 years ago
Closed 10 years ago
8x slower on dart2js output of Tracer benchmark vs v8
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
mozilla39
People
(Reporter: azakai, Assigned: jandem)
References
Details
(Keywords: perf)
Attachments
(4 files)
|
86.12 KB,
application/javascript
|
Details | |
|
795 bytes,
patch
|
bhackett1024
:
review+
|
Details | Diff | Splinter Review |
|
2.66 KB,
patch
|
bhackett1024
:
review+
|
Details | Diff | Splinter Review |
|
1.65 KB,
patch
|
bhackett1024
:
review+
|
Details | Diff | Splinter Review |
Running the dart benchmarks, I noticed that the dart2js version of Tracer (i.e., compiled to JS from dart) runs fairly slowly, around 10x slower than the handwritten Tracer, and in a more apples-to-apples comparison, 8x slower than v8 on the same dart2js output.
| Assignee | ||
Comment 1•11 years ago
|
||
Ouch, I'm seeing 70% of the time under CreateThisForFunctionWithProtoWrapper, a stub called from Ion JIT code. I'll try to create a smallish testcase.
Flags: needinfo?(jdemooij)
| Assignee | ||
Comment 2•11 years ago
|
||
OK, see the micro-benchmark below:
SM: 1334 ms
d8: 72 ms
No wonder we're slower.
The problem is that our constructor calls are awesome and fast if the target function has a singleton type, but if that's not the case we have a slow VM call to construct the `this` object. Bad perf fault that we should fix.
function cons() {
function Vector(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
}
return Vector;
}
var V = cons();
function f() {
for (var i=0; i<10000000; i++)
var v = new V(1, 2, 3);
return v;
}
var t = new Date;
f();
print(new Date - t);
Flags: needinfo?(jdemooij)
| Assignee | ||
Updated•11 years ago
|
Flags: needinfo?(jdemooij)
| Assignee | ||
Comment 3•11 years ago
|
||
Removes 2 lines of code so that getSingletonPrototype works if the target function has non-singleton type.
This fixes the micro-benchmark in comment 2 (from 1300 ms to 70 ms), but the original benchmark needs more work.
Assignee: nobody → jdemooij
Status: NEW → ASSIGNED
Attachment #8514209 -
Flags: review?(bhackett1024)
Updated•11 years ago
|
Attachment #8514209 -
Flags: review?(bhackett1024) → review+
| Assignee | ||
Updated•11 years ago
|
Flags: needinfo?(jdemooij)
Keywords: leave-open
| Assignee | ||
Updated•11 years ago
|
Flags: needinfo?(jdemooij)
| Assignee | ||
Comment 4•11 years ago
|
||
Forgot the link, sorry for the bugspam. Part 1:
https://hg.mozilla.org/integration/mozilla-inbound/rev/0eeb6a55facb
Comment 5•11 years ago
|
||
| Assignee | ||
Comment 6•10 years ago
|
||
With bug 1129387 fixed we have:
V8: 632 ms
SM: 1161 ms
So we're down from 8x slower to < 2x slower. We spend almost all time in JIT code, so we probably have bad type information somewhere.
| Assignee | ||
Comment 7•10 years ago
|
||
(In reply to Jan de Mooij [:jandem] from comment #6)
> V8: 632 ms
> SM: 1161 ms
The remaining problem is that the definite properties analysis fails for a number of important constructors, because AddClearDefiniteGetterSetterForPrototypeChain returns false because an object on the prototype has unknown properties.
The unknown properties there comes from the MarkObjectGroupUnknownProperties in TypeScript::MonitorAssign: we have a loop copying properties and the heuristic in TypeScript::MonitorAssign kicks in :(
With the MarkObjectGroupUnknownProperties call there commented out I get:
V8: 632 ms
SM: 628-640 ms
SM --unboxed-objects: 563 ms
So, getting rid of that call in TypeScript::MonitorAssign should be a nice win here, especially with --unboxed-objects.
Depends on: 1106828
| Assignee | ||
Comment 8•10 years ago
|
||
This fixes the problem in comment 7, performance improvement is still about the same.
TypeScript::MonitorAssign does:
if (group->getPropertyCount() < 128)
return;
MarkObjectGroupUnknownProperties(cx, group);
The problem is that getPropertyCount overapproximates (returns the capacity) if the properties are stored in a HashSet, so we may hit this when there are only 32 properties. I also think we shouldn't rely on the HashSet implementation for this.
The patch changes it to use basePropertyCount. I kept the 128, it's quite a lot but MarkObjectGroupUnknownProperties is pretty bad for performance so I think it makes sense to do this only if there really are a ton of properties.
Flags: needinfo?(jdemooij)
Attachment #8571892 -
Flags: review?(bhackett1024)
Updated•10 years ago
|
Attachment #8571892 -
Flags: review?(bhackett1024) → review+
| Assignee | ||
Comment 9•10 years ago
|
||
Part 2 (tweaking the MonitorAssign heuristic) exposed an existing bug when running jit-test/tests/ion/bug904315.js
We were eliminating a LoadElementHole even though it needed a negative int check. This patch sets the guard flag to prevent that.
Attachment #8572818 -
Flags: review?(bhackett1024)
Comment 10•10 years ago
|
||
Comment on attachment 8572818 [details] [diff] [review]
Fix pre-existing bug
Review of attachment 8572818 [details] [diff] [review]:
-----------------------------------------------------------------
::: js/src/jit/MIR.h
@@ +8201,5 @@
> setMovable();
> + // Set the guard flag to make sure we bail when we see a negative
> + // index. We can clear this flag (and needsNegativeIntCheck_) in
> + // collectRangeInfoPreTrunc.
> + setGuard();
newlines before/after this comment/call.
Attachment #8572818 -
Flags: review?(bhackett1024) → review+
| Assignee | ||
Comment 11•10 years ago
|
||
| Assignee | ||
Comment 13•10 years ago
|
||
And part 2:
https://hg.mozilla.org/integration/mozilla-inbound/rev/594fc93e0ae2
Keeping the leave-open for now because I want to add this test to AWFY.
Comment 14•10 years ago
|
||
Comment 15•10 years ago
|
||
| Assignee | ||
Updated•10 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Keywords: leave-open
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
You need to log in
before you can comment on or make changes to this bug.
Description
•