Node.js is faster on Windows than on Linux – what can we learn?

In an interesting interview on DevBeat (http://venturebeat.com/2011/12/09/node-js-rackspace/), Rackspace systems architect and Node.js contributor Paul Querna talks about the Node.js implementation on Windows. (Original video here: http://vimeo.com/33248104)

Paul’s points in the interview about making use of I/O completion ports on Windows highlights a key issue in cross-platform software development: Windows has some incredibly powerful and advanced APIs, which – if used directly – can provide huge performance benefits for software that uses them.

The common model of “develop for Linux first, then port to Windows” can mean that the ported software performs poorly on Windows installations, at least partly because you’re imposing a Linux-y execution model on a Windows system. You only need to look at the number of application handles opened by 32-bit MySQL running on Windows (at least 32k handles at startup – for *what* reason, exactly?) to see an example of a such a non-idiomatic Linux-to-Windows port.

The spoken language analogy would be using Google Translate for all your i18n needs: a big fail. Paul also points out that there is a large installed base of Windows servers out there which are not going away any time soon, so ignoring Windows when developing software is somewhat negligent.

In fact, Node in effect re-implemented I/O completion ports (http://msdn.microsoft.com/en-us/library/windows/desktop/aa365198(v=vs.85).aspx, “an efficient threading model for processing multiple asynchronous I/O requests on a multiprocessor system“) inside the Node code, effectively making them available on Linux too.

Under the cover of all the Windows marketing/sales hype, there is a [largely-] POSIX-compliant, well-architected OS with some features (such as I/O completion ports) which Linux lacks. Linux obviously has features (User-mode Linux, for instance) which Windows could really use; my point here is to highlight that the “Linux first, then transliterate for Windows” is missing a trick or two.

Join the discussion...

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s