Introduction to native extensions
summary
Explains how to build Node native addons using binding.gyp and node-gyp, and how to use N-API or nan plus worker threads to move CPU-heavy work off the main event loop. Presents an experiment processing 30k items showing performance differences: ~16 req/s with naive workers, ~67 req/s using object instances, and ~274 req/s using buffer/shared memory, while noting the need for explicit binary builds, manual memory management, and careful integration to avoid blocking and unsafe access to JavaScript.
AI-written summary · about
chapters (10)
- 0:00Native extensions overview
- 2:07What are native extensions
- 5:03Tools for native extensions
- 7:16NAPI advantages
- 9:43Node-API evolution
- 10:24Basic extension example
- 13:43CPU-intensive processing
- 18:44Buffers vs objects
- 21:16Performance results
- 23:44Summary
related talks
31mBuilding Modern Native Add-ons for Node.js in 2021
39mNext Generation N-API: A Hands-on Workshop
28mWriting node modules with v8
29mNode.js Addons for High Performance Numeric Computing
34mWorker Threads vs C ++ Addons (part 2)
50mBuilding native Node.js addons in Reason
29mRust Native Module with Node-API
23mDig Deep V8 profiling
