BT

InfoQ Homepage News JavaScript V8 Engine Improves Async Performance

JavaScript V8 Engine Improves Async Performance

Bookmarks

The V8 JavaScript team announces improvements to optimize async functions and promises. The team also improved the debugging experience for async code, a common pain point for JavaScript developers.

The introduction of promises in ES2015 and the later introduction of asynchronous functions and ES2018's async iteration makes the authoring of asynchronous code much more efficient than using callbacks. However, until recently the use of these new features was not efficient. Google V8 engineers Maya Lekova and Benedikt Meurer explain:

We’ve managed to improve the performance of asynchronous code significantly between V8 v5.5 (Chrome 55 & Node.js 7) and V8 v6.8 (Chrome 68 & Node.js 10). We reached a level of performance where developers can safely use these new programming paradigms without having to worry about speed. We’ve managed to improve Promise.all performance by a factor of 8×.

The V8 team has also explored the performance of real-world source code, looking at usage with Middleware frameworks such as hapi, koa, and trek, which use promises and async functions. With the recent changes in V8, the performance when using these frameworks improved significantly.

V8 has introduced several changes to lead to async performance improvements, including TurboFan, a new optimizing compiler, and Orinoco, a new garbage collector, moving GC off the main thread to improve request processing. Additionally, there was a bug within Node.js 8 that led to await skipping microticks in some cases.

The performance work has led to a few proposed patches to improve the specification for async functions, which should improve performance not just in V8, but all JavaScript engines. These changes include the removal of two extra microticks and the removal of a throwaway promise for async functions.

With the recent updates to both the V8 source code and proposed refinements to the async functions specification, async/await now outperforms promise code for the first time by reducing the overhead of async functions.

To make debugging easier, Chrome DevTools improves stack traces also to include the async portion of the stack trace.

V8 is an open source JavaScript engine from Google that powers Chrome and Chromium-based browsers, as well as Node.js. V8 is available under a BSD-style license. Contributions are welcome via the V8 GitHub project under the Chromium code of conduct.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.