[Webkit-unassigned] [Bug 240984] New: [JSC] Promise/async is about 6x slower than v8
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Thu May 26 15:33:16 PDT 2022
https://bugs.webkit.org/show_bug.cgi?id=240984
Bug ID: 240984
Summary: [JSC] Promise/async is about 6x slower than 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 459797
--> https://bugs.webkit.org/attachment.cgi?id=459797&action=review
safari
Running https://github.com/v8/promise-performance-tests in jsc vs v8 reports the following on macOS arm64
with JSC:
❯ fd . --exec bun '{}'
Time(doxbee-async-es2017-native): 55.3 ms.
Time(doxbee-promises-es2015-native): 60.5 ms.
Time(doxbee-async-es2017-babel): 73.4 ms.
Time(parallel-promises-es2015-native): 255.8 ms.
Time(parallel-async-es2017-babel): 383.9 ms.
Time(parallel-async-es2017-native): 414.5 ms.
Time(fibonacci-async-es2017-babel): 785.8 ms.
Time(fibonacci-async-es2017-native): 1923.3 ms.
with V8:
❯ fd . --exec node '{}'
Time(doxbee-async-es2017-native): 20.9 ms.
Time(doxbee-promises-es2015-native): 26.6 ms.
Time(doxbee-async-es2017-babel): 42 ms.
Time(parallel-promises-es2015-native): 55.6 ms.
Time(parallel-async-es2017-native): 63.1 ms.
Time(parallel-async-es2017-babel): 82.7 ms.
Time(fibonacci-async-es2017-native): 110.9 ms.
Time(fibonacci-async-es2017-babel): 222.6 ms.
the bluebird ones were skipped because bun doesn't support node's async_hooks
In another microbench, we can run the following in jsc's shell with Mitata (https://github.com/evanwashere/mitata)
import {run, bench} from './mitata/src/cli.mjs';
bench("sync", () => {});
bench("async", async () => {});
await run();
That reports:
❯ node a.mjs
cpu: Apple M1 Max
runtime: node v18.2.0 (arm64-darwin)
benchmark time (avg) (min … max) p75 p99 p995
------------------------------------------------- -----------------------------
sync 320.19 ps/iter (304.1 ps … 258.77 ns) 316.7 ps 358.3 ps 370.8 ps
async 57.01 ns/iter (52.72 ns … 122.63 ns) 59.06 ns 107.38 ns 115.63 ns
❯ jsc a.mjs -m
cpu: unknown
runtime: unknown (unknown)
benchmark time (avg) (min … max) p75 p99 p995
------------------------------------------------- -----------------------------
sync 322.29 ps/iter (300 ps … 15.65 ns) 316.7 ps 387.5 ps 416.6 ps
async 369.04 ns/iter (357.71 ns … 519.04 ns) 365.94 ns 476.6 ns 519.04 ns
Running this in Safari (attached screenshot) shows async to be about 565 ns/iter, something like 10x slower compared to V8/node
Running the https://github.com/v8/promise-performance-tests/blob/master/src/parallel-async-es2017-native.js with Instruments, shows this:
https://user-images.githubusercontent.com/709451/170589528-852d693f-94c3-40ab-a460-f697225e150b.png
We can see that a lot of time is spent in bookkeeping – preparing to call microtasks, creating JSC::JSMicrotask, destroying JSC::JSMicrotask, writing to handleset, etc
--
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/20220526/1e274669/attachment.htm>
More information about the webkit-unassigned
mailing list