Open
Bug 1158767
Opened 10 years ago
Updated 2 years ago
V8 and JSC much faster when using shift/unshift on huge, mostly empty arrays
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
NEW
Tracking | Status | |
---|---|---|
firefox40 | --- | affected |
People
(Reporter: till, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
(deleted),
application/x-javascript
|
Details |
Consider the attached benchmark. V8 completes it immediately, whereas we and, in this form, JSC never do or at least take hours (I didn't check).
If you active line 2, all browsers take long, but changing that to a non-index property doesn't cause a slowdown.
JSC becomes fast if the `unshift` is removed, so it only optimizes the `shift`, apparently. JSC also has a bug in all this: the other entries aren't moved by the shift, so "foo" always stays at index 999.
I only discovered this through working on Shumway compatibility with the Tamarin test suite, and it's not immediately important, but might be a symptom of a missing optimization that might we useful to have.
Comment 1•10 years ago
|
||
> JSC also has a bug in all this
Did you happen to file that?
Flags: needinfo?(till)
Reporter | ||
Comment 2•10 years ago
|
||
(In reply to Not doing reviews right now from comment #1)
> Did you happen to file that?
Good call, I did now: https://bugs.webkit.org/show_bug.cgi?id=144261
Flags: needinfo?(till)
Updated•10 years ago
|
Component: JavaScript Engine: JIT → JavaScript Engine
Flags: needinfo?(jdemooij)
Comment 3•10 years ago
|
||
This is a sparse array issue, similar to the slice problem I fixed in bug 1087963. The meta bug for this is bug 1088189.
array_shift loops from 0 to newlen, then does a slow GetElement for each of them. I think it'd be nice to have an IndexIterator thing that either loops from 0 to len, or does something smarter for sparse arrays (like what I did for slice). Then we can templatize these loops and hopefully fix this without duplicating/complicating too much code.
Maybe I can make this a q3 project, if I don't have time to get to it before that.
Blocks: 1088189
Flags: needinfo?(jdemooij)
Comment 4•10 years ago
|
||
I'm going to need to templatize these loops soon anyways so that these VM functions will be fast on unboxed arrays. I can try to abstract the index iteration as well when I do that.
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•