Summary: | [JSC] Promise/async is about 6x slower than v8 | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Jarred Sumner <jarred> | ||||
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> | ||||
Status: | NEW --- | ||||||
Severity: | Normal | CC: | cyb.ai.815, webkit-bug-importer, ysuzuki | ||||
Priority: | P2 | Keywords: | InRadar | ||||
Version: | WebKit Nightly Build | ||||||
Hardware: | Unspecified | ||||||
OS: | Unspecified | ||||||
See Also: | https://github.com/tc39/ecma262/pull/2772 | ||||||
Attachments: |
|
Description
Jarred Sumner
2022-05-26 15:33:16 PDT
If we look at V8's implementation We can see that they don't use a generic JSC::JSMicrotask-like type with a JS implementation. Instead, they have specific types for each job. https://github.com/v8/v8/blob/f32335fea75b7bde495e0800d7f7349253f81a7c/src/builtins/builtins-microtask-queue-gen.cc#L118 They also implement an optimization for resolving promises that skips allocating a temporary promise. https://github.com/v8/v8/blob/f32335fea75b7bde495e0800d7f7349253f81a7c/src/builtins/promise-jobs.tq#L15 These patches had some impact: - https://github.com/Jarred-Sumner/WebKit/commit/2640da9d0023f6e70ef0a1f7331f2eeb8b93717b - https://github.com/Jarred-Sumner/WebKit/commit/e049be38d79ec80be0a4e6687f9d99f6e97ac208 - https://github.com/Jarred-Sumner/WebKit/commit/d8fdbb963f79baa30848fdb77914486055a6bc57 - https://github.com/Jarred-Sumner/WebKit/commit/e63c5d1faf1ba7c00f45f90acef0a0f30141ed7d There was also a JSC::Strong in Bun's code that was not good. async function calls are about 59% faster in bun than default jsc shell now (In reply to Jarred Sumner from comment #1) > > They also implement an optimization for resolving promises that skips > allocating a temporary promise. > > https://github.com/v8/v8/blob/f32335fea75b7bde495e0800d7f7349253f81a7c/src/ > builtins/promise-jobs.tq#L15 Note that JSC is doing the same thing internally :) *** Bug 243472 has been marked as a duplicate of this bug. *** |