Introduction to Napa.js

Daiyi Peng
Daiyi PengPrincipal Software Engineer Manager um Microsoft
Introduction to Napa.js
Daiyi Peng, Principal Engineer Manager, Microsoft
12/13/2017
Agenda
• What is Napa.js?
• Why Napa.js?
• Architecture
• Features
• Future Plans
• Q & A
What is Napa.js?
Napa.js
• Napa.js is a multi-threaded JavaScript runtime built on V8, which was
originally designed to develop highly iterative services with non-
compromised performance in Bing. As it evolves, we find it useful to
complement Node.js in CPU-bound tasks, with the capability of
executing JavaScript in multiple V8 isolates and communicating
between them. Napa.js is exposed as a Node.js module, while it can
also be embedded in a host process without Node.js dependency.
• https://github.com/Microsoft/napajs
Quick Start
Run on all workers
Run on any one worker
Example 1: Simple divide and conquer
• Estimate PI in parallel
Fan out
Aggregate
Example 2: Asynchronous recursion
• Recursive Fibonacci
Asynchronous recursion
Example 3: Shared memory via `store`
• Max sub matrix with all 1’s
Setup workers to access a shared store named ‘sub-matrix-size-store’
Setup a function defintion
Write to a shared store
across threads
Read from a shared store
Example 4: Embedding Napa.js using C++
• Example program
Why Napa.js?
MS internal project Napa
• Started on July, 2015, motivated in building a platform for AI powered
applications in Bing, with satisfying following requirements:
1. Language-level support to quickly iterate on algorithms
2. Close-to-native performance, scalable with multiple cores
3. Support shared memory across multiple cores
4. Fine-granularity parallelism with minimized communication cost between
threads
MS internal project Napa, cont.
• We chose JavaScript for
• Language maturity
• Proven performance
• Productivity and large ecosystem
• Challenges with JavaScript
• there were 2 established ways to support CPU bound tasks in
Node: Computational code in C++ exposed as async JavaScript function,
or Node cluster. The former cannot satisfy requirement of flexibility, and the
latter cannot satisfy requirement of shared memory.
Napa.js
• OSS effort branched out in Nov, 2016 to explore how a general-
purpose multi-threading model can bring possibilities to JavaScript
world.
Napa.js OSS work started
Nov, 2016
Napa.js was made public
Aug 8, 2017
Attracted another 6K stars
on Github since Oct
Oct 17, 2017
Media coverage from
Hacker’s news and
InfoWorld
Napa.js: Major decisions
• Value proposition
• Complement Node.js instead of competing, by focusing on computation heavy scenarios (See
long-term)
• Distribution
• Distribute as a Node.js module instead of being another Node
• Provide pre-built binaries to minimize installation overhead
• Built from source for embedding scenarios
• Module architecture
• Use the same module architecture with Node.js, so Napa.js can load Node.js modules and
vice versa (limitations see Node.js compatibility)
• Implementation
• Use TypeScript for all JS library files for scaling this project.
• Minimize external library dependency (e.g., uv, etc.) for easy build and easy consumption
(build time: 2 mins)
Architecture
Architecture: Node.JS
A single JS thread Multiple C++ threads
Image credit: https://www.linkedin.com/pulse/nodejs-event-loop-padmanabhan-pillai
Napa.JS
Zone 1
(A JS thread pool)
Architecture: Napa.JS
JS worker 1
JS worker 2
…
Zone 2
(A JS thread pool)
JS worker 1
JS worker 2
…
Node.JS
Event loop
(a single JS thread)
A virtual ‘node’
Zone for IO
(only 1 worker)
C++ thread pool
for IO
Call to
zone.execute
• All execution flow are organized on Zones, workers are not exposed from API
• Within a Zone, all workers are symmetric
• Zones are asymmetric among each other (either load different code, or have different policy)
• Node is exposed as a virtual Zone with only 1 worker. (Not for embedding mode yet)
Features
Core features
• Parallel execution
• Via zone namespace
• Messaging passing & Shared Memory
• Via transport and store namespace
• Synchronization
• Via sync namespace
Zone: namespace `zone`
• Container of workers
• A program can create multiple zones
• All workers within a zone are symmetrical
• Support two operations
• Broadcast – run code on all workers
• Execute – run code on any one worker
• Two type of zones
• Napa zone - zone consists of Napa.js managed JavaScript workers (V8
isolates). Support partial Node.JS APIs.
• Node zone - a 'virtual' zone which exposes Node.js event loop, has access to
full Node.js capabilities.
Transport: namespace `transport`
• Purpose
• Efficiently passing values from one worker to another worker
• Dealing with lifecycle if there is shared native resources.
• Now support:
• JavaScript primitive types: number, boolean, array, hash, etc.
• JavaScript built-in types (release soon), Uint32Array, SharedArrayBuffer, etc.
• JavaScript objects that implements Transportable
• Native object wraps that implements Transportable
• Lifecycle (Advanced)
• A object shared across multiple threads will be destroyed after last
dereference (especially useful for native object wraps)
Store: namespace `store`
• Purpose
• A key/value store of JavaScript values that can be shared across workers
• Challenges
• Each v8 isolate (thread) maintains their own heap
• If a data type can be passed via `zone.execute`, it should be able to set/get in
store.
• Our solution
• Marshall the transportable type into a JSON string
• Put into C++ heap that can be read from all workers
• Unmarshall the JSON string into per-isolate JavaScript objects
Sync: namespace `sync`
• Purpose
• Provide mechanism for synchronization to access exclusive resources among
threads
• Simple API to minimize potential deadlock from user code
• API
• napa.sync.Lock
• lock.guardSync(func, args…)
• Future: RWLock
Napa modules
• Napa.js follows Node.js' convention to support modules, which
means:
• Both JavaScript modules and C++ modules are supported.
• Module resolution follows the same algorithm, except instead of searching
file extension .node for addons, Napa.JS searches .napa.
• Supports NPM, with the same way to create and publish modules.
• API of creating C++ modules (addons) are similar. Napa.JS introduced macros
that the same source code can be compiled to produce both Napa.js addon
and Node.js addon.
• See documentation
Other features
• Logger
• Via logger API
• Metric
• Via metric namespace
• Memory allocator
• Via memory namespace
Limitation
• Within Napa zone, only partial Node API is supported. This can be
compensated by using Node zone.
• This is an area you can contribute!! 
• Transport of JS objects
• Function should not access closure
Future Plans
Features & Improvements
• Continuous improvement in stability and performance
• More efficient transport layer, supporting SharedArrayBuffer, etc.
• Thorough support for pluggable memory allocator
• Minimize GC impact on execution latency impact
• Node compatibility
• Support more Node API that is used in computation heavy tasks
• Unify native addon file format `.napa` and `.node` into single `.node`
• Tooling
• Debugging: Napa inspector
• napa-gyp: a node-gyp-like package for developing Napa native modules
Mid-long term
• Consolidate with node-worker effort (discussion ongoing)
Q & A
Thank you!
Please visit Napa.js Home for more information.
1 von 30

Recomendados

Javantura 2014 - Java 8 JavaScript Nashorn von
Javantura 2014 - Java 8 JavaScript NashornJavantura 2014 - Java 8 JavaScript Nashorn
Javantura 2014 - Java 8 JavaScript NashornMiroslav Resetar
2K views22 Folien
Introduction to node.js by jiban von
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jibanJibanananda Sana
2.5K views34 Folien
Node.js for beginner von
Node.js for beginnerNode.js for beginner
Node.js for beginnerSarunyhot Suwannachoti
563 views32 Folien
Gcd and concurrency programming von
Gcd and concurrency programmingGcd and concurrency programming
Gcd and concurrency programmingLi Lin
1.4K views29 Folien
Build Your Kubernetes Operator with the Right Tool! von
Build Your Kubernetes Operator with the Right Tool!Build Your Kubernetes Operator with the Right Tool!
Build Your Kubernetes Operator with the Right Tool!Rafał Leszko
193 views92 Folien
Grand Central Dispatch and multi-threading [iCONdev 2014] von
Grand Central Dispatch and multi-threading [iCONdev 2014]Grand Central Dispatch and multi-threading [iCONdev 2014]
Grand Central Dispatch and multi-threading [iCONdev 2014]Kuba Břečka
5.3K views24 Folien

Más contenido relacionado

Was ist angesagt?

Tracing Microservices with Zipkin von
Tracing Microservices with ZipkinTracing Microservices with Zipkin
Tracing Microservices with Zipkintakezoe
13.8K views18 Folien
Node js for beginners von
Node js for beginnersNode js for beginners
Node js for beginnersArjun Sreekumar
925 views22 Folien
Node.js tutoria for beginner von
Node.js tutoria for beginnerNode.js tutoria for beginner
Node.js tutoria for beginnerManinder Singh
620 views12 Folien
GraalVM von
GraalVMGraalVM
GraalVMManfredi Giordano
22 views16 Folien
Node.js 101 with Rami Sayar von
Node.js 101 with Rami SayarNode.js 101 with Rami Sayar
Node.js 101 with Rami SayarFITC
6.1K views45 Folien
Mongo and node mongo dc 2011 von
Mongo and node mongo dc 2011Mongo and node mongo dc 2011
Mongo and node mongo dc 2011async_io
5.3K views29 Folien

Was ist angesagt?(20)

Tracing Microservices with Zipkin von takezoe
Tracing Microservices with ZipkinTracing Microservices with Zipkin
Tracing Microservices with Zipkin
takezoe13.8K views
Node.js 101 with Rami Sayar von FITC
Node.js 101 with Rami SayarNode.js 101 with Rami Sayar
Node.js 101 with Rami Sayar
FITC6.1K views
Mongo and node mongo dc 2011 von async_io
Mongo and node mongo dc 2011Mongo and node mongo dc 2011
Mongo and node mongo dc 2011
async_io5.3K views
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka von Nurul Ferdous
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
Nurul Ferdous2.5K views
Creating Highly Available MongoDB Microservices with Docker Containers and Ku... von MongoDB
Creating Highly Available MongoDB Microservices with Docker Containers and Ku...Creating Highly Available MongoDB Microservices with Docker Containers and Ku...
Creating Highly Available MongoDB Microservices with Docker Containers and Ku...
MongoDB3.9K views
Cloud Architect Alliance #15: Openstack von Microsoft
Cloud Architect Alliance #15: OpenstackCloud Architect Alliance #15: Openstack
Cloud Architect Alliance #15: Openstack
Microsoft1.4K views
Tugrik: A new persistence option for Pharo von ESUG
Tugrik: A new persistence option for PharoTugrik: A new persistence option for Pharo
Tugrik: A new persistence option for Pharo
ESUG705 views
Node.js Enterprise Middleware von Behrad Zari
Node.js Enterprise MiddlewareNode.js Enterprise Middleware
Node.js Enterprise Middleware
Behrad Zari4.6K views
T4T Training day - NodeJS von Tim Sommer
T4T Training day - NodeJST4T Training day - NodeJS
T4T Training day - NodeJS
Tim Sommer764 views
Node.js, for architects - OpenSlava 2013 von Oscar Renalias
Node.js, for architects - OpenSlava 2013Node.js, for architects - OpenSlava 2013
Node.js, for architects - OpenSlava 2013
Oscar Renalias13.7K views
Introduction to Node.js von Rob O'Doherty
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Rob O'Doherty2.9K views
Openstack platform -Red Hat Pizza and technology event - Israel von Arthur Berezin
Openstack platform -Red Hat Pizza and technology event - IsraelOpenstack platform -Red Hat Pizza and technology event - Israel
Openstack platform -Red Hat Pizza and technology event - Israel
Arthur Berezin1.2K views

Similar a Introduction to Napa.js

An introduction to Node.js von
An introduction to Node.jsAn introduction to Node.js
An introduction to Node.jsKasey McCurdy
788 views36 Folien
Irfan maulana nodejs web development von
Irfan maulana   nodejs web developmentIrfan maulana   nodejs web development
Irfan maulana nodejs web developmentPHP Indonesia
438 views46 Folien
PHP Indonesia - Nodejs Web Development von
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentIrfan Maulana
1.8K views46 Folien
NodeJS - Server Side JS von
NodeJS - Server Side JS NodeJS - Server Side JS
NodeJS - Server Side JS Ganesh Kondal
5K views28 Folien
Overview of PaaS: Java experience von
Overview of PaaS: Java experienceOverview of PaaS: Java experience
Overview of PaaS: Java experienceIgor Anishchenko
1.4K views53 Folien

Similar a Introduction to Napa.js(20)

An introduction to Node.js von Kasey McCurdy
An introduction to Node.jsAn introduction to Node.js
An introduction to Node.js
Kasey McCurdy788 views
Irfan maulana nodejs web development von PHP Indonesia
Irfan maulana   nodejs web developmentIrfan maulana   nodejs web development
Irfan maulana nodejs web development
PHP Indonesia438 views
PHP Indonesia - Nodejs Web Development von Irfan Maulana
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web Development
Irfan Maulana1.8K views
Overview of PaaS: Java experience von Alex Tumanoff
Overview of PaaS: Java experienceOverview of PaaS: Java experience
Overview of PaaS: Java experience
Alex Tumanoff771 views
What is Mean Stack Development ? von Balajihope
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?
Balajihope158 views
Java script nirvana in netbeans [con5679] von Ryan Cuprak
Java script nirvana in netbeans [con5679]Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]
Ryan Cuprak1.1K views

Último

GDSC Mikroskil Members Onboarding 2023.pdf von
GDSC Mikroskil Members Onboarding 2023.pdfGDSC Mikroskil Members Onboarding 2023.pdf
GDSC Mikroskil Members Onboarding 2023.pdfgdscmikroskil
72 views62 Folien
Unlocking Research Visibility.pdf von
Unlocking Research Visibility.pdfUnlocking Research Visibility.pdf
Unlocking Research Visibility.pdfKhatirNaima
11 views19 Folien
CCNA_questions_2021.pdf von
CCNA_questions_2021.pdfCCNA_questions_2021.pdf
CCNA_questions_2021.pdfVUPHUONGTHAO9
7 views196 Folien
Design_Discover_Develop_Campaign.pptx von
Design_Discover_Develop_Campaign.pptxDesign_Discover_Develop_Campaign.pptx
Design_Discover_Develop_Campaign.pptxShivanshSeth6
56 views20 Folien
MongoDB.pdf von
MongoDB.pdfMongoDB.pdf
MongoDB.pdfArthyR3
51 views6 Folien
Créativité dans le design mécanique à l’aide de l’optimisation topologique von
Créativité dans le design mécanique à l’aide de l’optimisation topologiqueCréativité dans le design mécanique à l’aide de l’optimisation topologique
Créativité dans le design mécanique à l’aide de l’optimisation topologiqueLIEGE CREATIVE
9 views84 Folien

Último(20)

GDSC Mikroskil Members Onboarding 2023.pdf von gdscmikroskil
GDSC Mikroskil Members Onboarding 2023.pdfGDSC Mikroskil Members Onboarding 2023.pdf
GDSC Mikroskil Members Onboarding 2023.pdf
gdscmikroskil72 views
Unlocking Research Visibility.pdf von KhatirNaima
Unlocking Research Visibility.pdfUnlocking Research Visibility.pdf
Unlocking Research Visibility.pdf
KhatirNaima11 views
Design_Discover_Develop_Campaign.pptx von ShivanshSeth6
Design_Discover_Develop_Campaign.pptxDesign_Discover_Develop_Campaign.pptx
Design_Discover_Develop_Campaign.pptx
ShivanshSeth656 views
MongoDB.pdf von ArthyR3
MongoDB.pdfMongoDB.pdf
MongoDB.pdf
ArthyR351 views
Créativité dans le design mécanique à l’aide de l’optimisation topologique von LIEGE CREATIVE
Créativité dans le design mécanique à l’aide de l’optimisation topologiqueCréativité dans le design mécanique à l’aide de l’optimisation topologique
Créativité dans le design mécanique à l’aide de l’optimisation topologique
LIEGE CREATIVE9 views
Programmable Logic Devices : SPLD and CPLD von Usha Mehta
Programmable Logic Devices : SPLD and CPLDProgrammable Logic Devices : SPLD and CPLD
Programmable Logic Devices : SPLD and CPLD
Usha Mehta27 views
REACTJS.pdf von ArthyR3
REACTJS.pdfREACTJS.pdf
REACTJS.pdf
ArthyR339 views
Basic Design Flow for Field Programmable Gate Arrays von Usha Mehta
Basic Design Flow for Field Programmable Gate ArraysBasic Design Flow for Field Programmable Gate Arrays
Basic Design Flow for Field Programmable Gate Arrays
Usha Mehta10 views
Trust Metric-Based Anomaly Detection via Deep Deterministic Policy Gradient R... von IJCNCJournal
Trust Metric-Based Anomaly Detection via Deep Deterministic Policy Gradient R...Trust Metric-Based Anomaly Detection via Deep Deterministic Policy Gradient R...
Trust Metric-Based Anomaly Detection via Deep Deterministic Policy Gradient R...
IJCNCJournal5 views
2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx von lwang78
2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx
2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx
lwang78314 views
Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc... von csegroupvn
Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc...Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc...
Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc...
csegroupvn16 views
IRJET-Productivity Enhancement Using Method Study.pdf von SahilBavdhankar
IRJET-Productivity Enhancement Using Method Study.pdfIRJET-Productivity Enhancement Using Method Study.pdf
IRJET-Productivity Enhancement Using Method Study.pdf
SahilBavdhankar10 views
BCIC - Manufacturing Conclave - Technology-Driven Manufacturing for Growth von Innomantra
BCIC - Manufacturing Conclave -  Technology-Driven Manufacturing for GrowthBCIC - Manufacturing Conclave -  Technology-Driven Manufacturing for Growth
BCIC - Manufacturing Conclave - Technology-Driven Manufacturing for Growth
Innomantra 22 views
Ansari: Practical experiences with an LLM-based Islamic Assistant von M Waleed Kadous
Ansari: Practical experiences with an LLM-based Islamic AssistantAnsari: Practical experiences with an LLM-based Islamic Assistant
Ansari: Practical experiences with an LLM-based Islamic Assistant
M Waleed Kadous12 views

Introduction to Napa.js

  • 1. Introduction to Napa.js Daiyi Peng, Principal Engineer Manager, Microsoft 12/13/2017
  • 2. Agenda • What is Napa.js? • Why Napa.js? • Architecture • Features • Future Plans • Q & A
  • 4. Napa.js • Napa.js is a multi-threaded JavaScript runtime built on V8, which was originally designed to develop highly iterative services with non- compromised performance in Bing. As it evolves, we find it useful to complement Node.js in CPU-bound tasks, with the capability of executing JavaScript in multiple V8 isolates and communicating between them. Napa.js is exposed as a Node.js module, while it can also be embedded in a host process without Node.js dependency. • https://github.com/Microsoft/napajs
  • 5. Quick Start Run on all workers Run on any one worker
  • 6. Example 1: Simple divide and conquer • Estimate PI in parallel Fan out Aggregate
  • 7. Example 2: Asynchronous recursion • Recursive Fibonacci Asynchronous recursion
  • 8. Example 3: Shared memory via `store` • Max sub matrix with all 1’s Setup workers to access a shared store named ‘sub-matrix-size-store’ Setup a function defintion Write to a shared store across threads Read from a shared store
  • 9. Example 4: Embedding Napa.js using C++ • Example program
  • 11. MS internal project Napa • Started on July, 2015, motivated in building a platform for AI powered applications in Bing, with satisfying following requirements: 1. Language-level support to quickly iterate on algorithms 2. Close-to-native performance, scalable with multiple cores 3. Support shared memory across multiple cores 4. Fine-granularity parallelism with minimized communication cost between threads
  • 12. MS internal project Napa, cont. • We chose JavaScript for • Language maturity • Proven performance • Productivity and large ecosystem • Challenges with JavaScript • there were 2 established ways to support CPU bound tasks in Node: Computational code in C++ exposed as async JavaScript function, or Node cluster. The former cannot satisfy requirement of flexibility, and the latter cannot satisfy requirement of shared memory.
  • 13. Napa.js • OSS effort branched out in Nov, 2016 to explore how a general- purpose multi-threading model can bring possibilities to JavaScript world. Napa.js OSS work started Nov, 2016 Napa.js was made public Aug 8, 2017 Attracted another 6K stars on Github since Oct Oct 17, 2017 Media coverage from Hacker’s news and InfoWorld
  • 14. Napa.js: Major decisions • Value proposition • Complement Node.js instead of competing, by focusing on computation heavy scenarios (See long-term) • Distribution • Distribute as a Node.js module instead of being another Node • Provide pre-built binaries to minimize installation overhead • Built from source for embedding scenarios • Module architecture • Use the same module architecture with Node.js, so Napa.js can load Node.js modules and vice versa (limitations see Node.js compatibility) • Implementation • Use TypeScript for all JS library files for scaling this project. • Minimize external library dependency (e.g., uv, etc.) for easy build and easy consumption (build time: 2 mins)
  • 16. Architecture: Node.JS A single JS thread Multiple C++ threads Image credit: https://www.linkedin.com/pulse/nodejs-event-loop-padmanabhan-pillai
  • 17. Napa.JS Zone 1 (A JS thread pool) Architecture: Napa.JS JS worker 1 JS worker 2 … Zone 2 (A JS thread pool) JS worker 1 JS worker 2 … Node.JS Event loop (a single JS thread) A virtual ‘node’ Zone for IO (only 1 worker) C++ thread pool for IO Call to zone.execute • All execution flow are organized on Zones, workers are not exposed from API • Within a Zone, all workers are symmetric • Zones are asymmetric among each other (either load different code, or have different policy) • Node is exposed as a virtual Zone with only 1 worker. (Not for embedding mode yet)
  • 19. Core features • Parallel execution • Via zone namespace • Messaging passing & Shared Memory • Via transport and store namespace • Synchronization • Via sync namespace
  • 20. Zone: namespace `zone` • Container of workers • A program can create multiple zones • All workers within a zone are symmetrical • Support two operations • Broadcast – run code on all workers • Execute – run code on any one worker • Two type of zones • Napa zone - zone consists of Napa.js managed JavaScript workers (V8 isolates). Support partial Node.JS APIs. • Node zone - a 'virtual' zone which exposes Node.js event loop, has access to full Node.js capabilities.
  • 21. Transport: namespace `transport` • Purpose • Efficiently passing values from one worker to another worker • Dealing with lifecycle if there is shared native resources. • Now support: • JavaScript primitive types: number, boolean, array, hash, etc. • JavaScript built-in types (release soon), Uint32Array, SharedArrayBuffer, etc. • JavaScript objects that implements Transportable • Native object wraps that implements Transportable • Lifecycle (Advanced) • A object shared across multiple threads will be destroyed after last dereference (especially useful for native object wraps)
  • 22. Store: namespace `store` • Purpose • A key/value store of JavaScript values that can be shared across workers • Challenges • Each v8 isolate (thread) maintains their own heap • If a data type can be passed via `zone.execute`, it should be able to set/get in store. • Our solution • Marshall the transportable type into a JSON string • Put into C++ heap that can be read from all workers • Unmarshall the JSON string into per-isolate JavaScript objects
  • 23. Sync: namespace `sync` • Purpose • Provide mechanism for synchronization to access exclusive resources among threads • Simple API to minimize potential deadlock from user code • API • napa.sync.Lock • lock.guardSync(func, args…) • Future: RWLock
  • 24. Napa modules • Napa.js follows Node.js' convention to support modules, which means: • Both JavaScript modules and C++ modules are supported. • Module resolution follows the same algorithm, except instead of searching file extension .node for addons, Napa.JS searches .napa. • Supports NPM, with the same way to create and publish modules. • API of creating C++ modules (addons) are similar. Napa.JS introduced macros that the same source code can be compiled to produce both Napa.js addon and Node.js addon. • See documentation
  • 25. Other features • Logger • Via logger API • Metric • Via metric namespace • Memory allocator • Via memory namespace
  • 26. Limitation • Within Napa zone, only partial Node API is supported. This can be compensated by using Node zone. • This is an area you can contribute!!  • Transport of JS objects • Function should not access closure
  • 28. Features & Improvements • Continuous improvement in stability and performance • More efficient transport layer, supporting SharedArrayBuffer, etc. • Thorough support for pluggable memory allocator • Minimize GC impact on execution latency impact • Node compatibility • Support more Node API that is used in computation heavy tasks • Unify native addon file format `.napa` and `.node` into single `.node` • Tooling • Debugging: Napa inspector • napa-gyp: a node-gyp-like package for developing Napa native modules
  • 29. Mid-long term • Consolidate with node-worker effort (discussion ongoing)
  • 30. Q & A Thank you! Please visit Napa.js Home for more information.