[Webkit-unassigned] [Bug 245797] New: Array.prototype.map is slower in JSC than V8 (particularly with literals)
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Sep 28 14:12:17 PDT 2022
https://bugs.webkit.org/show_bug.cgi?id=245797
Bug ID: 245797
Summary: Array.prototype.map is slower in JSC than V8
(particularly with literals)
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 462692
--> https://bugs.webkit.org/attachment.cgi?id=462692&action=review
array-map.mjs
A lot of modern JS uses .map and .forEach. Many codebases use these functions more frequently than for loops.
For small array literals with constant values, V8 is about 3x faster than what JSC is doing.
I've attached a benchmark script
Bun using a copy of JSC from September 17th, 2022:
cpu: Apple M1 Max
runtime: bun 0.1.14 (arm64-darwin)
benchmark time (avg) (min … max) p75 p99 p995
------------------------------------------------------------- -----------------------------
Array.map x 0 50.91 ns/iter (45.7 ns … 274.74 ns) 47.35 ns 113.15 ns 131.34 ns
Array.map x 1 55.15 ns/iter (51.91 ns … 453.84 ns) 52.44 ns 101.3 ns 119.57 ns
Array.map x 2 58.1 ns/iter (51.91 ns … 183.54 ns) 52.77 ns 116.05 ns 151.96 ns
Array.map x 3 52.16 ns/iter (46.56 ns … 152.19 ns) 47.15 ns 105.3 ns 125.74 ns
Array.map x 4 78.14 ns/iter (51.94 ns … 164.94 ns) 83.45 ns 129.8 ns 139.77 ns
Array.map x 5 54.94 ns/iter (51.36 ns … 226.1 ns) 53.67 ns 101.87 ns 109.88 ns
Array.map x 6 55.97 ns/iter (51.9 ns … 257.6 ns) 54.43 ns 105.08 ns 165.98 ns
Array.map x 7 55.5 ns/iter (51.84 ns … 162.09 ns) 54.43 ns 102.56 ns 112.98 ns
Array.map x 8 57.03 ns/iter (51.84 ns … 476.93 ns) 54.97 ns 121.98 ns 148.4 ns
Array.map x 9 56.4 ns/iter (51.85 ns … 370.1 ns) 54.74 ns 116.15 ns 131.97 ns
Array.map x 10 56.05 ns/iter (51.86 ns … 212.73 ns) 54.53 ns 103.42 ns 108.92 ns
Array.map x 11 55.92 ns/iter (51.86 ns … 187.18 ns) 54.53 ns 103.99 ns 133.61 ns
Array.map x 12 55.93 ns/iter (51.88 ns … 272.41 ns) 54.48 ns 107.03 ns 120.77 ns
Array.map x 13 56.08 ns/iter (51.86 ns … 174.88 ns) 54.64 ns 115.71 ns 127.24 ns
Array.map x 14 55.97 ns/iter (51.88 ns … 191.69 ns) 54.55 ns 110.09 ns 119.5 ns
Array.map x 15 55.87 ns/iter (51.86 ns … 357.33 ns) 54.51 ns 102.73 ns 111.7 ns
Array.map x 16 55.98 ns/iter (51.85 ns … 181.74 ns) 54.52 ns 106.4 ns 117.05 ns
Array.map x 17 56.25 ns/iter (51.88 ns … 380.5 ns) 54.54 ns 106.85 ns 117.7 ns
Array.map x 18 55.41 ns/iter (51.85 ns … 127.13 ns) 54.54 ns 97.5 ns 103.66 ns
Array.map x 19 55.73 ns/iter (51.87 ns … 267.85 ns) 54.61 ns 100.46 ns 106.79 ns
inline Array.map x 0 31.8 ns/iter (28.91 ns … 239.6 ns) 31.2 ns 73.13 ns 84.8 ns
inline Array.map x 1 33.6 ns/iter (30.74 ns … 106.19 ns) 33.89 ns 77.63 ns 90.15 ns
inline Array.map x 2 34.59 ns/iter (31.94 ns … 239.49 ns) 34.82 ns 75.1 ns 85.36 ns
inline Array.map x 3 36.49 ns/iter (33.39 ns … 151.94 ns) 36.17 ns 79.87 ns 93.93 ns
inline Array.map x 4 38.94 ns/iter (35.6 ns … 295.58 ns) 38.79 ns 87.57 ns 93.78 ns
inline Array.map x 5 40.37 ns/iter (36.88 ns … 268.68 ns) 39.93 ns 92.47 ns 97.58 ns
inline Array.map x 6 43.33 ns/iter (39.58 ns … 272.25 ns) 42.77 ns 93.85 ns 101.4 ns
inline Array.map x 7 44.73 ns/iter (40.56 ns … 505.39 ns) 43.34 ns 99.42 ns 138.26 ns
inline Array.map x 8 41.82 ns/iter (37.98 ns … 161.33 ns) 41.22 ns 89.9 ns 98.47 ns
inline Array.map x 9 42.2 ns/iter (38.85 ns … 104.19 ns) 41.62 ns 87.07 ns 92.6 ns
inline Array.map x 10 54.53 ns/iter (49.97 ns … 185.29 ns) 53.61 ns 105.6 ns 113.41 ns
inline Array.map x 11 55.63 ns/iter (50.92 ns … 251.47 ns) 54.47 ns 103.83 ns 173.58 ns
inline Array.map x 12 56.66 ns/iter (51.74 ns … 278.88 ns) 56.14 ns 105.58 ns 107.75 ns
inline Array.map x 13 57.31 ns/iter (52.67 ns … 212.94 ns) 56.72 ns 103.72 ns 115.22 ns
inline Array.map x 14 53.85 ns/iter (48.2 ns … 203.39 ns) 54 ns 107.08 ns 115.79 ns
inline Array.map x 15 55.64 ns/iter (48.61 ns … 265.81 ns) 55.93 ns 107.91 ns 114.97 ns
inline Array.map x 16 56.43 ns/iter (49.25 ns … 408.1 ns) 55.23 ns 111.18 ns 137.67 ns
inline Array.map x 17 57.4 ns/iter (50.05 ns … 143.59 ns) 56.14 ns 110.2 ns 116.92 ns
inline Array.map x 18 58.43 ns/iter (51.64 ns … 267.74 ns) 58.65 ns 112.74 ns 121.68 ns
inline Array.map x 19 59.89 ns/iter (51.9 ns … 476.5 ns) 59.19 ns 109.14 ns 112.25 ns
Node v18.9.1:
benchmark time (avg) (min … max) p75 p99 p995
------------------------------------------------------------- -----------------------------
Array.map x 0 34.04 ns/iter (29.44 ns … 467.84 ns) 33.85 ns 42.88 ns 43.56 ns
Array.map x 1 40.11 ns/iter (30.09 ns … 244.13 ns) 41.4 ns 109.83 ns 130.5 ns
Array.map x 2 35.94 ns/iter (25.49 ns … 533.06 ns) 39.04 ns 47.24 ns 47.97 ns
Array.map x 3 34.42 ns/iter (28.05 ns … 42.55 ns) 35.67 ns 39.95 ns 40.68 ns
Array.map x 4 32.94 ns/iter (28 ns … 45.35 ns) 33.4 ns 38.43 ns 40.02 ns
Array.map x 5 36.87 ns/iter (28.02 ns … 51.1 ns) 38.55 ns 45.81 ns 47.34 ns
Array.map x 6 34.6 ns/iter (28.05 ns … 47.17 ns) 36.35 ns 41.41 ns 42.43 ns
Array.map x 7 32.59 ns/iter (28 ns … 40.6 ns) 32.58 ns 37.35 ns 38.05 ns
Array.map x 8 32.49 ns/iter (28.05 ns … 45.3 ns) 32.5 ns 36.84 ns 37.49 ns
Array.map x 9 32.61 ns/iter (28 ns … 49.33 ns) 32.5 ns 38.6 ns 42.77 ns
Array.map x 10 32.45 ns/iter (28.01 ns … 39.56 ns) 32.42 ns 36.15 ns 36.83 ns
Array.map x 11 34.8 ns/iter (28.02 ns … 404.71 ns) 34.34 ns 66.5 ns 84.86 ns
Array.map x 12 32.45 ns/iter (28.02 ns … 46.71 ns) 32.46 ns 35.9 ns 37.15 ns
Array.map x 13 32.37 ns/iter (27.99 ns … 41.37 ns) 32.42 ns 37.14 ns 38.39 ns
Array.map x 14 32.52 ns/iter (27.99 ns … 42.66 ns) 32.52 ns 36.39 ns 38.6 ns
Array.map x 15 31.69 ns/iter (28.01 ns … 55.96 ns) 32.58 ns 34.9 ns 39.68 ns
Array.map x 16 30.77 ns/iter (28.13 ns … 40.82 ns) 33.07 ns 35.27 ns 36.27 ns
Array.map x 17 30.73 ns/iter (28.13 ns … 40.67 ns) 33 ns 35.59 ns 36.96 ns
Array.map x 18 30.77 ns/iter (28.13 ns … 39.08 ns) 33.2 ns 34.04 ns 34.35 ns
Array.map x 19 31.03 ns/iter (28.11 ns … 46.27 ns) 33.08 ns 37.92 ns 42.6 ns
inline Array.map x 0 7.59 ns/iter (6.05 ns … 415.02 ns) 10.49 ns 11.85 ns 13.33 ns
inline Array.map x 1 6.01 ns/iter (5.25 ns … 20.8 ns) 5.45 ns 10.9 ns 11.81 ns
inline Array.map x 2 7.41 ns/iter (6.56 ns … 15.85 ns) 6.75 ns 11.69 ns 11.84 ns
inline Array.map x 3 9.02 ns/iter (8.1 ns … 22.63 ns) 8.31 ns 13.24 ns 13.82 ns
inline Array.map x 4 11.25 ns/iter (10.13 ns … 25.14 ns) 10.54 ns 16.12 ns 17.26 ns
inline Array.map x 5 12.33 ns/iter (10.62 ns … 22.12 ns) 11.62 ns 16.96 ns 17.82 ns
inline Array.map x 6 13.37 ns/iter (11.57 ns … 27.57 ns) 12.72 ns 17.59 ns 18.2 ns
inline Array.map x 7 14.45 ns/iter (13.08 ns … 29.82 ns) 17.48 ns 19.14 ns 20.86 ns
inline Array.map x 8 15.47 ns/iter (14.03 ns … 25.82 ns) 18.61 ns 19.32 ns 20.18 ns
inline Array.map x 9 16.58 ns/iter (15 ns … 33.03 ns) 19.65 ns 20.6 ns 21.1 ns
inline Array.map x 10 17.6 ns/iter (15.88 ns … 28.53 ns) 20.45 ns 22.87 ns 23.76 ns
inline Array.map x 11 18.26 ns/iter (16.79 ns … 51.02 ns) 21.28 ns 24.35 ns 25.29 ns
inline Array.map x 12 18.79 ns/iter (17.72 ns … 35.87 ns) 17.79 ns 23.95 ns 24.26 ns
inline Array.map x 13 19.9 ns/iter (18.65 ns … 33.07 ns) 19.28 ns 26.57 ns 29.35 ns
inline Array.map x 14 20.79 ns/iter (19.58 ns … 31.04 ns) 19.68 ns 25.87 ns 26.63 ns
inline Array.map x 15 21.73 ns/iter (20.52 ns … 40.35 ns) 20.59 ns 26.63 ns 27.52 ns
inline Array.map x 16 22.82 ns/iter (21.45 ns … 35.67 ns) 22.2 ns 29.01 ns 30.38 ns
inline Array.map x 17 23.75 ns/iter (22.39 ns … 34.28 ns) 22.57 ns 28.8 ns 29.43 ns
inline Array.map x 18 24.75 ns/iter (23.32 ns … 35.58 ns) 23.55 ns 29.62 ns 30.4 ns
inline Array.map x 19 25.69 ns/iter (24.25 ns … 36.99 ns) 25.53 ns 30.86 ns 31.65 ns
--
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/20220928/9d701243/attachment-0001.htm>
More information about the webkit-unassigned
mailing list