Reaching


by @matteocollina

Back in 2013..



MQTT and Node.js: Messaging in the Internet of Things


Fast?

can be faster!

Down the rabbit hole of performance optimizations

Achieving


Performance boost

Tools

What worked

node --trace_opt --trace_inlining --trace_deopt

How node works


How to get fast

fast means we can do more I/O

V8

My enemy

[marking 0x1a308644a581
  <JS Function (SharedFunctionInfo 0xf1f928b34e9)>
  for recompilation, reason: small function,
  ICs with typeinfo: 8/8 (100%), generic ICs: 0/8 (0%)]
  

My enemy

function (err, data) {
  /* whatever is done here
     is not going to be optimized */
}

Code time!

All benchmarks results

Code time!


http://npm.im/steed
var steed = require('steed')()
steed.map(new State(cb, 2), [1, 2, 3], multiply, done)

Rules for hot code path 1/2

The missing bit


The final (?) step of improvement

Rules for hot code path 2/2

Improving node

Most code does not need to go

One last thing.. flamegraphs!

How to generate them

0x

You also need a FAST logger

And a fast HTTP load testing tool


http://npm.im/steed

This presentation

http://github.com/mcollina

Thanks!


If you need help with Node.js


matteo.collina@nearform.com

@matteocollina on Twitter

www.nearform.com