[Webkit-unassigned] [Bug 239936] New: TypedArray.from is ~60x slower than in V8
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Sat Apr 30 21:30:21 PDT 2022
https://bugs.webkit.org/show_bug.cgi?id=239936
Bug ID: 239936
Summary: TypedArray.from is ~60x slower than in V8
Product: WebKit
Version: WebKit Nightly Build
Hardware: Unspecified
OS: Unspecified
Status: NEW
Severity: Normal
Priority: P2
Component: JavaScriptCore
Assignee: webkit-unassigned at lists.webkit.org
Reporter: jarred at jarredsumner.com
Created attachment 458644
--> https://bugs.webkit.org/attachment.cgi?id=458644&action=review
microbenchmark
TypedArray.from(otherTypedArrayView) uses Symbol.iterator when it could use memmove() or possibly memcpy.
A microbenchmark is attached that runs in both JSC shell and node.
On macOS 12.3 aarch64 M1X
For 1 MB:
- JSC: 22ms
- Node : 0.13ms
For 32 MB:
- JSC: 274ms
- Node: 4ms
If TypedArray.prototype.set[0] is used in TypedArrayConstructor.js when !mapFn && @isTypedArrayView(arrayLike), that becomes:
For 1 MB:
- JSC: 22ms
- JSC (modified): 0.4ms
- v8 9.6 (Node 17.7.1): 0.13ms
For 32 MB:
- JSC: 274ms
- JSC (modified): 5ms
- v8 9.6 (Node 17.7.1): 4ms
It isn't precisely correct to use TypedArray.prototype.set, but it shows roughly what the numbers would look like after this is fixed. It does seem that V8 is consistently slightly faster after this change though, which means there is still something more to do here. Maybe it could allocate uninitialized memory because it will copy directly from the other typed array view?
V8's optimization for TypedArray.from: https://github.com/v8/v8/blob/f32335fea75b7bde495e0800d7f7349253f81a7c/src/builtins/typed-array-from.tq#L167
[0]: https://gist.github.com/Jarred-Sumner/543b94142de9f17a9ec86e9dac5cf171#file-typedarrayconstructor-js
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20220501/9a09f039/attachment.htm>
More information about the webkit-unassigned
mailing list