Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Performance first: Node.js and Rust

Performance first: Node.js and Rust

Workshop about Performance techniques to use Rust with Node.js when Performance is necessary for a specific process or task.


Giovanny Gongora

June 11, 2018

More Decks by Giovanny Gongora

Other Decks in Programming


  1. Performance first

  2. History behind Node.js

  3. What's Node.js for • Node is designed to build scalable

    network applications • Node is similar in design to, and influenced by, systems like Ruby's Event Machine or Python's Twisted • Just because Node is designed without threads, doesn't mean you cannot take advantage of multiple cores in your environment.
  4. History behind Rust

  5. Why Rust exists? • There is too little attention paid

    to safety • They have poor concurrency support • There is a lack of practical affordances • They offer limited control over resources
  6. How fast is Rust • Fast! Rust is already competitive

    with idiomatic C and C++ in a number of benchmarks • Rust takes zero-cost abstractions as one of its core principles: none of Rust’s abstractions impose a global performance penalty, nor is there overhead from any runtime system in the traditional sense.
  7. Goals for Rust • Design and Implement a safe, concurrent,

    practical systems language • Provides both efficient code and a comfortable level of abstraction
  8. Non Goals for Rust • We do not demand that

    Rust run on “every possible platform”. It must eventually work without unnecessary compromises on widely-used hardware and software platforms. • We do not intend to cover the complete feature-set of C++, or any other language. Rust should provide majority-case features. • We do not intend to be 100% static, 100% safe, 100% reflective, or too dogmatic in any other sense. Trade-offs exist.
  9. Workshop time

  10. Hello world en Node.js Step 1

  11. Hello world en Rust Step 2

  12. FFI ( Node.js + Rust ) Step 3 & 4

  13. Neon ( Node.js + Rust ) Step 5 & 6

  14. Neon ( Node.js + Rust ) Complex example - Step

  15. So, what just happened?

  16. Advantages - Rust & Node.js • The performance increase is

    not the only advantage, the consolidation of processes simplifies the deployment strategy, troubleshooting and maintenance.
  17. Disadvantages - Rust & Node.js • Get a negligible gain

    in exchange for an implementation that doesn't scale • Sometimes writing a native module in Rust might not be easier, but would be the best answer for performance problems
  18. Thanks Giovanny Gongora - @Gioyik