Closed
Bug 933301
Opened 11 years ago
Closed 11 years ago
[].push.apply is very slow
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla28
People
(Reporter: jandem, Assigned: jandem)
References
Details
(Whiteboard: [performance] [shumway])
Attachments
(2 files, 1 obsolete file)
621 bytes,
text/plain
|
Details | |
1.17 KB,
patch
|
bhackett1024
:
review+
|
Details | Diff | Splinter Review |
jQuery does this, see bug 922053. Small shell testcase below.
d8: 35 ms
js: 289 ms
The problem is that we don't inline this push call so we spend a ton of time in the VM, doing TI stuff under setDenseElementWithType.
We can try to speed that up, try to self-host Array.prototype.push or try to inline/optimize push.apply in IonMonkey.
function test() {
var arr = [];
for (var i=0; i<100; i++)
arr[i] = {};
var t = new Date;
for (var i=0; i<70000; i++) {
var res = [];
res.push.apply(res, arr);
}
print(new Date - t);
}
test();
Comment 1•11 years ago
|
||
I'll take a stab at self-hosting this.
Blocks: 885526
Whiteboard: [performance] [shumway]
Assignee | ||
Comment 2•11 years ago
|
||
This patch changes setDenseElementWithType to check the new element's type against the previous element's type. The idea is that if they match we don't have to do the slow AddTypePropertyId dance.
This improves our time to 112 ms. Still > 2x slower than Chrome but also > 2x faster than before. I will see if this actually helps jQuery and how often this fast-path hits on other benchmarks/websites.
Comment 3•11 years ago
|
||
Ok, that proved not to be worth it. With the attached self-hosted version (and integrated benchmark), I see a win of ~10% - far less than jandem's wip patch. I didn't even test normal [].push() usage, which is probably worse with the self-hosted version.
Assignee | ||
Comment 4•11 years ago
|
||
(In reply to Till Schneidereit [:till] from comment #3)
> Ok, that proved not to be worth it. With the attached self-hosted version
> (and integrated benchmark), I see a win of ~10% - far less than jandem's wip
> patch.
Thanks for testing. I think for this to be fast Ion needs to inline apply(x, array) like it inlines apply(x, arguments)...
Assignee | ||
Comment 5•11 years ago
|
||
On Octane this avoids the AddTypePropertyId call in 81% of the cases, for Kraken this is 90% and for Sunspider it's 97%.
I only did this for setDenseElementWithType for now, we can do the same for other methods if needed.
Assignee: nobody → jdemooij
Attachment #825346 -
Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #825444 -
Flags: review?(bhackett1024)
Updated•11 years ago
|
Attachment #825444 -
Flags: review?(bhackett1024) → review+
Assignee | ||
Comment 6•11 years ago
|
||
Comment 7•11 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla28
You need to log in
before you can comment on or make changes to this bug.
Description
•