Closed
Bug 1381469
Opened 7 years ago
Closed 7 years ago
Improve TypedArray iteration by avoid the detached buffer check when the current length is non-zero
Categories
(Core :: JavaScript: Standard Library, enhancement)
Core
JavaScript: Standard Library
Tracking
()
RESOLVED
FIXED
mozilla56
Tracking | Status | |
---|---|---|
firefox56 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
Details
Attachments
(1 file)
1.39 KB,
patch
|
till
:
review+
|
Details | Diff | Splinter Review |
It's faster to call PossiblyWrappedTypedArrayLength (because it can be inlined), than to call PossiblyWrappedTypedArrayHasDetachedBuffer (which isn't inlined). So to speed up typed array iteration, we can avoid calling PossiblyWrappedTypedArrayHasDetachedBuffer when the current typed array length is non-zero (we currently reset the length to zero when the underlying array buffer was detached, so any typed array with a non-zero length can't have a detached array buffer). Improves this µ-benchmark from 240ms to 50ms for me: var a = new Int32Array(100).map((v, k) => k + 1); var q = 0; var t = Date.now(); for (var i = 0; i < 100000; ++i) { for (var x of a) q += x; } print(Date.now() - t, q);
Assignee | ||
Comment 1•7 years ago
|
||
This avoids the slow PossiblyWrappedTypedArrayHasDetachedBuffer check when the typed array is definitely not detached.
Attachment #8887030 -
Flags: review?(till)
Comment 2•7 years ago
|
||
Comment on attachment 8887030 [details] [diff] [review] bug1381469.patch Review of attachment 8887030 [details] [diff] [review]: ----------------------------------------------------------------- nice, r=me
Attachment #8887030 -
Flags: review?(till) → review+
Assignee | ||
Comment 3•7 years ago
|
||
Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=d929d586209513f21fe082c7d03f2e4e97c43e68
Keywords: checkin-needed
Pushed by ryanvm@gmail.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/75e1e435c2b6 Only check for detached buffers when iterating over typed arrays when the current length is zero. r=till
Keywords: checkin-needed
Comment 5•7 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/75e1e435c2b6
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
status-firefox56:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
You need to log in
before you can comment on or make changes to this bug.
Description
•