Closed Bug 1521435 Opened 5 years ago Closed 2 years ago

performance of async function

Categories

(Core :: JavaScript Engine: JIT, defect, P3)

64 Branch
defect

Tracking

()

RESOLVED DUPLICATE of bug 1682623

People

(Reporter: akari.ccino, Unassigned)

References

(Depends on 2 open bugs)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.2 Safari/605.1.15

Steps to reproduce:

open this page
open Web Console devtool
select a large file (I tested files which are 10 ~ 30MB)
observe the console output.

the source is here.

Actual results:

the function used async is about slower than the function without async.( x100 slower on my machine(macOS) )

Status: UNCONFIRMED → NEW
Component: Untriaged → JavaScript Engine
Depends on: 1412202, 903457, 1317690
Ever confirmed: true
Product: Firefox → Core

This is because async functions can't be Ion-compiled. The code being timed is:

    for (let index = 0; index < uin8array.length; index++) {
      uin8array[index] ^= key;
    }

For what it's worth, hufan.akarin, you can make it fast by factoring this code out into a separate non-async function.

Component: JavaScript Engine → JavaScript Engine: JIT
Priority: -- → P3

I just tried to reproduce this bug. When I uploaded a file of 60 MB into the linked codepen, I saw the following result:

handleFilePromise: 5783.72216796875 ms
handleFileAsyncAwait: 1226.853759765625 ms

Does this mean the async/await is actually faster?

Flags: needinfo?(sdetar)

with bug 1682623, async function is now optimized.
and the testcase doesn't use await in the hot path, so the performance should be almost same as regular function.

I used 20MB file and 50MB file, and I see almost same time between them (~500ms and ~900ms).

Then, for the testcase, if you use large file and if it takes more than 1000 ms,
you'll see "This page is slowing down ..." bar at the top of the page.
This is triggered by firefox if the script runs too long without returning, to allow users to stop the script.
During showing the bar, the current execution is de-optimized, and the result time isn't reliable.

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → DUPLICATE
Flags: needinfo?(sdetar)
You need to log in before you can comment on or make changes to this bug.