Friday, September 9, 2016

V8 Release 5.4

Every six weeks, we create a new branch of V8 as part of our release process. Each version is branched from V8’s git master immediately before a Chrome Beta milestone. Today we’re pleased to announce our newest branch, V8 version 5.4, which will be in beta until it is released in coordination with Chrome 54 Stable in several weeks. V8 5.4 is filled will all sorts of developer-facing goodies, so we’d like to give you a preview of some of the highlights in anticipation of the release.

Performance Improvements

V8 5.4 delivers a number of key improvements in memory footprint and startup speed. These primarily help accelerate initial script execution and reduce page load in Chrome.

Memory

When measuring V8’s memory consumption, two metrics are very important to monitor and understand: Peak memory consumption and average memory consumption. Typically, reducing peak consumption is just as important as reducing average consumption since an executing script that exhausts available memory even for a brief moment can cause an Out of Memory crash, even if its average memory consumption is not very high. For optimization purposes, it’s useful to divide V8's memory into two categories: On-heap memory containing actual JavaScript objects and off-heap memory containing the rest, such as internal data structures allocated by the compiler, parser and garbage collector.

In 5.4 we tuned V8’s garbage collector for low-memory devices with 512 MB RAM or less. Depending on the website displayed this reduces peak memory consumption of on-heap memory up to 40%.

Memory management inside V8’s JavaScript parser was simplified to avoid unnecessary allocations, reducing off-heap peak memory usage by up to 20%. This memory savings is especially helpful in reducing memory usage of large script files, including asm.js applications.

Startup & speed

Our work to streamline V8's parser not only helped reduce memory consumption, it also improved the parser's runtime performance. This streamlining, combined with other optimizations of JavaScript builtins and how accesses of properties on JavaScript objects use global inline caches, resulted in notable startup performance gains.

Our internal startup test suite that measures real-world JavaScript performance improved by a median of 5%. The Speedometer benchmark also benefits from these optimizations, improving by ~ 10 to 13% compared to 5.2.
~ 13% reduction on Speedometer/Mac

V8 API

Please check out our summary of API changes. This document is regularly updated a few weeks after each major release.


Developers with an active V8 checkout can use 'git checkout -b 5.4 -t branch-heads/5.4' to experiment with the new features in V8 5.4. Alternatively you can subscribe to Chrome's Beta channel and try the new features out yourself soon.

Posted by the V8 team

7 comments:

  1. I'm so excited for async/await, these release notes are killing me

    ReplyDelete
  2. Ho do I get to know from devtools the difference between peak memory and average memory usage of my script(s)?

    ReplyDelete
    Replies
    1. You can extract those numbers with Devtool's Timeline feature.

      Delete
    2. Thanks. The nodejs specification talks about "heapTotal and heapUsed refer to V8's memory usage." ( https://nodejs.org/dist/latest-v6.x/docs/api/all.html#process_process_memoryusage )

      What is their meaning in relation to "peak memory" and "average memory"?

      Delete
    3. Total is the memory reserved which is higher than the actual memory used. This is typically measured for one point in time.

      Peak and average are calculated over several points in time. One could calculate the peak UsedMemory or the avarge UsedMemory.

      Probably it also makes sense to ask the Node.js people directly.

      Delete
    4. The values returned by node here come directly from v8's GetHeapStatistics method. This value is collected at the point that you call the method, and it doesn't represent a peak memory value. You'd need to aggregate that yourself if you want to track it.

      Delete