Upgrading from Node 6 to Node 8: performance comparison

We get several major upgrades with Node.js versions every year. Node 6 upgraded to Node 8. As it is an upgraded version, it posses some changes that enhance performance factor. This results in more efficiency and reducing the cost of a development. It was not difficult to upgrade to Node 8- It will take only 10 minutes. Also it will not break a single library. You can easily install it on macOS with .pkg file from a website. It was smooth running. It also works like a charm on Windows machine. Also, it doesn’t require manual steps, no broken packages. Also it doesn’t require much time to upgrade. 

These performance comparisons are for  medium to large React site with a single page. With the server it takes a JSON object with a thousand of properties and returns with 2113 nodes.

Upgrading from Node 6 to Node 8: performance-

1. Server rendering time-

Start with the important metric- Time taken to do the server rendering of the page. 

At a first look, there are no drastic difference. But, at the eighth version, the render time reduces. Node 6 was getting the job done in about 104ms while Node 8 was taking about 80ms.

Server rendering time

That’s really 23% reduction in render time. Or, more concretely, a 23% reduction in the hardware required to serve the site. 

Here’s the same test, but using React in dev mode:

React renderToString (dev mode)

After the first few, there was an average reduction of about 31%. This chart shows that it is important to set NODE_ENVto ‘production’ and ship the production version of libraries.

2. Running a test suite-

This suite of  500 Jest tests involves most of the  mounting and unmounting React components, and obviously just general JavaScriptery.

Suite of Jest tests

A 10% reduction, perhaps the improvement is less pronounced here because the JavaScript engine isn’t doing any optimizations (each run was a fresh start of Node). This is just a guess. Corrections/explanations are most welcome.

3. Webpack Build-

The Webpack build is a little bit of disk I/O. It is a bunch of Babel transpiling, JS uglifying/minifying, all for about 500 KB of JavaScript.

Webpack build

Node 8.0 causes the 7% reduction in run time. 

4. NPM installs-

Node 6 LTS shipped with npm@3. This brought some good improvements to the next versions. With Node 8 LTS, we’ll be getting npm@5. This has brought some insanely impressive features and performance. Some new features include such as,lockfiles, local caching with fallbacks, SHA512 checksums and a suite of other small features. In case of performance, one can expect up to 5x performance increases in the best cases. On average, you can expect 20-100% faster npm installs. Check the npm@5 from the npm team to analyze more about the new version, and see the improvements you will get in with Node 8  LTS.

Specific performance Updates-

  1. Creating object- Creating objects in Node8 is five times faster than in Node 6.
  2. Function size- The V8 engine decides whether a function should be optimized based on several factors such as function size. Small functions are optimized whereas large functions are not.
  3. TurboFan and Ignition- V8 includes turboFan and Ignition. These are major updates to the internals of V8 which gives impressive performance hike across a variety of JavaScript operations.
  4. One of the most exciting things to be added recently to the core JavaScript language is coming to Node.js 8 LTS – async/await. Many see async/await as the next evolution of asynchronous programming in Node.js, beating out both callbacks and promises. There’s a lot of excitement around async/await, so I highly suggest checking out this article on reasons why async/await is awesome for a more brief introduction.

Are you looking for a web development to boost your business? Then you are at the right place. Solace expert’s are well trained to use Node 8 for effective development. To get a free quote for any web development, contact us. We are happy to help you get started through our expert’s.