Bug 70687

Summary: Typed arrays are 10X slower than normal classic arrays
Product: WebKit Reporter: Joseph Huckaby <jhuckaby>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Minor CC: ap, cmarcelo, fpizlo, ggaren, m.goleb+bugzilla, oliver, shezbaig.wk
Priority: P3 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Mac (Intel)   
OS: OS X 10.7   
URL: http://jsperf.com/read-write-typed-arrays/2

Description Joseph Huckaby 2011-10-22 18:57:08 PDT
Using a simple for loop reading and writing single values from typed arrays vs. normal arrays, the performance difference is staggering.  Typed arrays are all about 10X slower than normal arrays.  This strange behavior only occurs in Safari (running the very same test in Chrome and Firefox the typed arrays win outright, as they should).

See the test page for details and source code: http://jsperf.com/read-write-typed-arrays/2

Reproduced in Safari 5.1, 5.11 and WebKit Nightly Build (Oct 18 2011) on OS X 10.7.2.
Comment 1 Geoffrey Garen 2011-10-24 12:11:51 PDT
<rdar://problem/10335308>
Comment 2 Oliver Hunt 2011-10-24 12:19:22 PDT
Yeah, we know about this.  The problem is essentially that WebKit still uses DOM-based typed arrays, which leads to most of the perf issues we see here (essentially they get the worst performance it is possible to achieve in JSC currently).

Fix is non-trivial, but it also won't be the hardest thing in the world to achieve.
Comment 3 Joseph Huckaby 2011-10-24 12:23:35 PDT
Cool, thanks guys.  I figured you had to know about it, just didn't see it in Bugzilla :)
Comment 4 Michał Gołębiowski-Owczarek 2013-12-13 04:49:37 PST
I don't see any slowdown in Safari 7.0, has this issue been fixed?
Comment 5 Alexey Proskuryakov 2013-12-13 09:24:05 PST
This particular bug is believed to have been fixed in Safari 6. There were many additional optimizations afterwards, including a rewrite that happened recently, after Safari 7.
Comment 6 Joseph Huckaby 2013-12-13 10:03:51 PST
I can confirm the speed has greatly improved in Safari 6.1 (I don't have 7 yet).
Comment 7 Alexey Proskuryakov 2013-12-13 10:32:26 PST
Could you please test with Safari 6.1 and nightly build, as well? 

http://nightly.webkit.org
Comment 8 Michał Gołębiowski-Owczarek 2013-12-13 10:41:10 PST
In the test under http://jsperf.com/read-write-typed-arrays/2 WebKit Nightly is faster than Safari 7, especially in Uint32Array tests.