Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
WebAssembly in NodeJS
Search
Willian Martins
October 17, 2017
Technology
4
640
WebAssembly in NodeJS
My presentation about WASM in NodeJS @ NodeJS Meetup Berlin
Willian Martins
October 17, 2017
Tweet
Share
More Decks by Willian Martins
See All by Willian Martins
Empirical Observations on the The Future of Scalable UI Architecture
wmsbill
0
160
Além do else! Categorizando Pokemóns com Pattern Matching no JavaScript
wmsbill
0
880
De volta ao Futuro do JS: As próximas features e propostas incríveis
wmsbill
0
110
Back to the future of JS II: Beyond what we can foresee
wmsbill
0
130
A, B, C. 1, 2, 3. Iterables you and me.
wmsbill
0
100
Back to the future of JS II: Beyond what we can foresee
wmsbill
0
130
Back to the future of JS.
wmsbill
0
11
Node conf ar 2018.
wmsbill
0
630
Back to the future of JS
wmsbill
1
83
Other Decks in Technology
See All in Technology
AWS DevOps Agent vs SRE俺 / AWS DevOps Agent vs me, the SRE
sms_tech
3
410
白金鉱業Meetup_Vol.22_Orbital Senseを支える衛星画像のマルチモーダルエンベディングと地理空間のあいまい検索技術
brainpadpr
2
260
バクラクのSREにおけるAgentic AIへの挑戦/Our Journey with Agentic AI
taddy_919
2
1.1k
[JAWSDAYS2026]Who is responsible for IAM
mizukibbb
0
140
Shifting from MCP to Skills / ベストプラクティスの変遷を辿る
yamanoku
4
700
Oracle Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
5
1.1k
自動テストが巻き起こした開発プロセス・チームの変化 / Impact of Automated Testing on Development Cycles and Team Dynamics
codmoninc
3
1.2k
Security Diaries of an Open Source IAM
ahus1
0
210
開発組織の課題解決を加速するための権限委譲 -する側、される側としての向き合い方-
daitasu
5
320
EMからICへ、二周目人材としてAI全振りのプロダクト開発で見つけた武器
yug1224
5
480
Agentic Software Modernization - Back to the Roots (Zürich Agentic Coding and Architectures, März 2026)
feststelltaste
1
220
Kiro のクレジットを使い切る!
otanikohei2023
0
120
Featured
See All Featured
Embracing the Ebb and Flow
colly
88
5k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
150
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
370
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
980
Into the Great Unknown - MozCon
thekraken
40
2.3k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
220
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
67
37k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
120
Un-Boring Meetings
codingconduct
0
220
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
100
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.2k
The Cult of Friendly URLs
andyhume
79
6.8k
Transcript
The Need for Speed and WebAssembly Willian Martins Autumn 2017
None
Timeline…
How did we achieve it Moore law Pushed Tech industries
to evolve until today Allowed huge computation power even on small devices
All this power for what? Faster applications More immersive games
Virtual reality Augmented reality Live video/image processing Big Data/Machine learning
The languages over time
But what about JS?
JS - Early days Created in 1995 by Brendan Eich
Was written in 11 days Designed to be easy and simple Designed to be a glue code for dynamic Web
None
JS - 2008 until now 2008 - JIT Compiler by
google w/ Chrome Jump of performance Allowed more complex applications What is the next step?
Willian Elia @wmsbill
None
WE’RE HIRING!!
What is WebAssembly?
What’s WebAssembly? New binary format Run compiled programs (C, C++,
Rust) on a browser Works alongside Javascript Performance and flexibility API
Why WebAssembly is faster?
V8 - JiT in action
V8 - JiT in action
V8 - JiT in action
V8 - JiT in action
V8 - JiT in action
V8 - JiT in action
V8 - JiT in action
JiT: Code life cycle in summary 1. Parse 2. Compile
3. Optimize (de-optimize) 4. Execute 5. Garbage Collector
WebAssembly
WebAssembly is fast Parse Compile Optimize Execute GC Decode Compile
+ Optimize Execute JS WASM
WebAssembly is fast WASM is more compact -> Faster FETCH
of the source WASM is closer to machine code -> Faster DECODING, COMPILING and OPTIMISING No need to RE-OPTIMISE No garbage collection
So WebAssembly looks fast, let’s see how to use it
How to run WASM modules Current situation: not possible to
run WASM modules on their own Need for some Javascript glue
WebAssembly JS API 1. Fetch/Load the module binary 2. Instantiate
it 3. Access exported functionalities
fs.readFile(‘./module.wasm’, async function(err, file) => { const { instance }
= await WebAssembly.instantiate(file); // Do something with the compiled results! });
How to generate a WASM file
Compile C to WASM + JS WASM emcc my-module.c -o
my-module.js -s WASM=1
Then we can simply import the generated JS code as
a module
Export functions to JS Keyword EMSCRIPTEN_KEEPALIVE EMSCRIPTEN_KEEPALIVE int sum(int x,
int y) { return x + y; } Expose only the interface of the WASM module to JS
What about WebAssembly memory? How can we access it?
Memory management Emscripten provide three useful functions to manage WebAssembly
memory _malloc(memoryNeeded) getValue(ptr, type) setValue(ptr, value, type)
Elia @eliamain
DEMO TIME
The WASM implementation was still slower
Why??
JIT handover
“Currently, calling a WebAssembly function in JS code is slower
than it needs to be. The JIT doesn’t know how to deal directly with WebAssembly, so it has to route the WebAssembly to something that does. … This can be up to 100x slower than it would be if the JIT knew how to handle it directly. ” Lin Clark
The future of WebAssembly
Future features Formal Specification Threads supports SIMD acronym to Single
Instruction Multiple Data (back to Stage 3 on TC39) Exception handling Garbage collection Direct DOM access ES6 Module integration
Danke! Thank you!
What about Native modules?