Closed
Bug 1366372
Opened 8 years ago
Closed 8 years ago
Array.from is way too slow
Categories
(Core :: JavaScript: Standard Library, defect)
Core
JavaScript: Standard Library
Tracking
()
RESOLVED
FIXED
mozilla55
| Tracking | Status | |
|---|---|---|
| firefox55 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
|
4.35 KB,
patch
|
evilpies
:
review+
|
Details | Diff | Splinter Review |
test case:
---
function zeroElements() {
var a = [];
var t = Date.now();
for (var i = 0; i < 1000000; ++i) Array.from(a);
print(Date.now() - t);
}
function tenElements() {
var a = [1,2,3,4,5,6,7,8,9,10];
var t = Date.now();
for (var i = 0; i < 1000000; ++i) Array.from(a);
print(Date.now() - t);
}
zeroElements();
tenElements();
---
Expected:
- zeroElements() completes in 200ms in my dev-environment
- tenElements() completes in 380ms in my dev-environment
Actual:
- zeroElements() needs 4000ms
- tenElements() needs 4800ms
Patch forthcoming... :-)
| Assignee | ||
Comment 1•8 years ago
|
||
Function default parameters combined with nested functions are a real show-stopper. Inferred functions names are also slow when they need to be computed at runtime.
I've also removed the inlined version of IterableToList in TypedArrayStaticFrom, because it's no longer needed and the new IterableToList function is actually faster (Arrays + DefineDataProperty perform now better than the self-hosted List version).
And for another few 100ms, I've removed the arguments check from GetIterator. We're now always calling GetIterator with two arguments, so we don't need to have this check any longer.
Attachment #8869567 -
Flags: review?(evilpies)
Comment 2•8 years ago
|
||
Comment on attachment 8869567 [details] [diff] [review]
bug1366372.patch
Review of attachment 8869567 [details] [diff] [review]:
-----------------------------------------------------------------
Ah so before we got an abort in Array.from with "has extra var environment" and in GetIterator with "NYI: arguments & setarg.". Pretty bad, seems like it would be trivial to run into that again. Thanks for fixing this!
Attachment #8869567 -
Flags: review?(evilpies) → review+
| Assignee | ||
Comment 3•8 years ago
|
||
Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=282539cec6a017421b033a2093f0fbe026f455dc
Keywords: checkin-needed
| Assignee | ||
Comment 4•8 years ago
|
||
(In reply to Tom Schuster [:evilpie] from comment #2)
> Ah so before we got an abort in Array.from with "has extra var environment"
> and in GetIterator with "NYI: arguments & setarg.". Pretty bad, seems like
> it would be trivial to run into that again. Thanks for fixing this!
Thanks for investigating and filing bug 1366470!
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/9dd114fb1542
Remove performance pitfalls in Array.from method. r=evilpie
Keywords: checkin-needed
Comment 6•8 years ago
|
||
| bugherder | ||
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
status-firefox55:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
Comment 7•8 years ago
|
||
https://hg.mozilla.org/projects/cedar/rev/9dd114fb1542532f4ceac384c8c230e2cc091257
Bug 1366372 - Remove performance pitfalls in Array.from method. r=evilpie
You need to log in
before you can comment on or make changes to this bug.
Description
•