Blog of Raivo Laanemets

Stories about web development, consulting and personal computers.

Pkg and Node.js 8 performance

Pkg is a Node.js application compiler. It makes application distribution easier without requiring a complex infrastructure setup like Docker. It packages and creates a single executable that can also contain non-executable asset files.

However, compiled scripts suffer from a performance penalty under the V8 Crankshaft compiler pipeline. The performance hit is much smaller under Ignition+TurboFan. Ignition is the new JavaScript interpreter and TurboFan is the new JIT compiler in V8.

I made some benchmarks using Node 8 (will become LTS soon). The benchmark is a minimal Express.js application that outputs a page generated from random data using an EJS template. With this application the results were:

  • Under the Crankshaft compilation pipeline there is a performance penalty about 31%.
  • For Ignition+TurboFan pipeline the performance penalty is much smaller at about 1.4%
  • Without packaging, the Ignition+TurboFan pipeline is 6.7% slower than the Crankshaft.

The benchmark code is on GitHub.

Update 2017-06-14

The Crankshaft compilation pileline performance penalty can be avoided when the application source is included. There are certain conditions required for this. See discussion here for more information.


No comments have been added so far.

Email is not displayed anywhere.
URLs (max 3) starting with http:// or https:// can be used. Use @Name to mention someone.