SlideShare uma empresa Scribd logo
1 de 24
Baixar para ler offline
JavaScript on Microcontrollers 
Samsung Open Source Group 1 
Tilmann Scheller 
LLVM Compiler Engineer 
t.scheller@samsung.com 
Samsung Open Source Group 
Samsung Research UK 
2nd Samsung Web Tech Talk 
San Jose, USA, October 30, 2014
Overview 
● Introduction 
● JavaScript engine code size 
● JavaScript engine correctness/performance 
● Summary 
Samsung Open Source Group 2
Introduction 
Samsung Open Source Group 3
Introduction 
● Wearable devices becoming more and more widespread 
● Weight and energy efficiency a big concern 
● JavaScript very popular, easy to learn 
● Scales from embedded to servers 
● Execute JavaScript on a microcontroller! 
Samsung Open Source Group 4
Target hardware 
● Cortex-M3 microcontroller (32-bit ARM Thumb-2) 
● 96KB of RAM 
● 512KB of flash memory 
● Clocked at 84MHz 
Samsung Open Source Group 5
JS Engines 
● Goal: JS engine which fits in the microcontroller 
constraints 
● Option one: Pick an established JS engine and strip it 
down to fit on a microcontroller 
● Option two: Pick a lightweight engine and make sure that 
it meets all the requirements 
Samsung Open Source Group 6
JS Engines 
● Two approaches pursued in parallel: 
– Try to minimize JavaScriptCore so that it fits on a 
microcontroller 
– Get the lightweight Duktape engine running on a 
microcontroller 
Samsung Open Source Group 7
JavaScriptCore 
● Well-established JS engine running on millions of devices 
● High-performance (four distinct levels of optimization) 
● Never intended to run in resource-constrained 
environments, primary focus is maximum performance 
● Written in C++ 
Samsung Open Source Group 8
Duktape 
● Lightweight JS engine 
● Focus on portability and a low footprint 
● Written in C and about 40k lines of code (excluding 
comments) 
● ECMAScript E5/E5.1 compliant 
● Liberal license 
● Active community, has been around for several years 
Samsung Open Source Group 9
Code size 
Samsung Open Source Group 10
JavaScriptCore minimization 
● Challenge: JavaScriptCore was never intended for 
environments like this 
● First attempt: 
– Took r170522 (June 26, 2014) of WebKit and built the EFL 
configuration for Thumb-2 
● Original (3.63 MB) 
● Reduced (2.39 MB) 
● Static (21.21 MB) 
– Several MB of heap memory consumed during runtime 
Samsung Open Source Group 11
JavaScriptCore minimization 
● Current snapshot: way too big! 
● Second try: Use a snapshot from 2008 just before SquirrelFish was merged 
● Performed minimizations: 
– Qt dependency was removed 
– Reduced the size of ICU data by disabling extra features 
– Rebuilt ICU with the –Os compiler option 
– Pthread was removed 
– Built older ICU libs 
– Stripped static JSC binary is now 1,647 KB (was: 19,578 KB) 
– The engine part of is 311 KB 
– The Unicode libraries are 562 Kbyte and the remaining size comes from libc, libm 
and libstdc++ libraries. 
Samsung Open Source Group 12
JavaScriptCore minimization 
● Engine size close to target size 
● However, libraries rely on too many system calls to make 
it feasible to run on a baremetal system 
● Too much effort to get JSC working on a baremetal 
system 
● Aborting JSC investigation and directing all efforts 
towards Duktape 
Samsung Open Source Group 13
Duktape 
● Compiled for Thumb-2 
● Using the newlib C standard library 
● No OS running on the microcontroller 
● Statically linked binary 
● C library has a big impact on the size of the executable 
● Disabling certain optimizations (through preprocessor 
macros), helps to reduce code size even further 
Samsung Open Source Group 14
Code size 
Static binary 
Engine 
Libraries 
108 
161 
100 
83 
70 
59 
212 
187 
127 
318 
655 
790 
1207 
311 
0 200 400 600 800 1000 1200 1400 1600 1800 
Samsung Open Source Group 15 
1647 
Duktape Thumb-2 baremetal noopt 
Duktape Thumb-2 baremetal 
Duktape ARM baremetal 
Duktape ARM Linux glibc 
JSC Thumb-2 Linux glibc 
KB 
Compiled at -Os ..., noopt = Duktape optimizations not compiled in, 
baremetal builds link against Newlib
Correctness/Performance 
Samsung Open Source Group 16
Correctness - test262 
● Duktape 0.12 and Arduino library 1.5.8, without DUK_OPT defines 
● test262 (ECMAScript conformance test suite) results: 
– Ran 11824 tests 
● Passed 11411 tests (96.5%) 
● Failed 413 tests (3.5%) 
● Failure details: 
– 144 tests ran out of memory 
– 10 tests timed out (300 secs) 
– 90 tests failed because of an undefined gettimeofday() function 
– 169 tests fail because of other reasons (have to be investigated) 
– Summary: 167 failures specific to the Arduino Due and 246 tests which fail on 
x86-64 as well 
Samsung Open Source Group 17
test262 
85 713 
288957 
Min Avg Max 
350000 
300000 
250000 
200000 
150000 
100000 
50000 
0 
Execution time (ms) 
Samsung Open Source Group 18 
Min Avg Max 
80 
70 
60 
50 
40 
30 
20 
10 
0 
54 
57 
75 
Memory usage (KB)
SunSpider 
● Duktape 0.12 and Arduino library 1.5.8, without DUK_OPT defines 
● Ran 26 tests 
– Passed 9 tests (34.6%) 
– Failed 17 tests (65.4%) 
● Failure details: 
– 3 tests were too big (string-unpack-code.js (164K), string-tagcloud.js 
(172K), regexp-dna.js (400K)) 
– 13 tests run out of memory (3d-cube.js, 3d-morph.js, 3d-raytrace.js, 
access-binary-trees.js, access-nsieve.js, bitops-nsieve-bits.js, crypto-aes.js, 
crypto-md5.js, crypto-sha1.js, date-format-tofte.js, date-format-xparb.js, 
string-base64.js, string-validate-input.js) 
– 1 test failed because of undefined gettimeofday() function (math-cordic.js) 
Samsung Open Source Group 19
SunSpider 
access-nbody 
160 
140 
120 
100 
80 
60 
40 
20 
access-fannkuch 
bitops-bits-in-byte 
bitops-3bit-bits-in-byte 
controlflow-recursive 
bitops-bitwise-and 
math-partial-sums 
Samsung Open Source Group 20 
math-spectral-norm 
string-fasta 
0 
149 
41.5 
64.3 
74.8 
140.2 
25.9 
62.3 
21.8 
119.9 
54 
64 
50 49 50 
70 
51 53 57 
Execution time (s) 
Memory usage (KB)
Summary 
Samsung Open Source Group 21
Summary 
● JavaScriptCore proved to be unsuitable for 
microcontrollers 
● Duktape fits well into flash and main memory 
● Duktape has promising correctness results 
● Ongoing effort to evaluate Duktape performance 
Samsung Open Source Group 22
Thank you. 
Samsung Open Source Group 23
We are hiring! 
Contact Information: 
Tilmann Scheller 
t.scheller@samsung.com 
Samsung Open Source Group 
Samsung Research UK 
Samsung Open Source Group 24

Mais conteúdo relacionado

Mais procurados

Using Flame Graphs
Using Flame GraphsUsing Flame Graphs
Using Flame GraphsIsuru Perera
 
OSCON2012TroubleShootJava
OSCON2012TroubleShootJavaOSCON2012TroubleShootJava
OSCON2012TroubleShootJavaWilliam Au
 
Software Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaSoftware Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaIsuru Perera
 
On the benchmark of Chainer
On the benchmark of ChainerOn the benchmark of Chainer
On the benchmark of ChainerKenta Oono
 
Jvm problem diagnostics
Jvm problem diagnosticsJvm problem diagnostics
Jvm problem diagnosticsDanijel Mitar
 
Get Lower Latency and Higher Throughput for Java Applications
Get Lower Latency and Higher Throughput for Java ApplicationsGet Lower Latency and Higher Throughput for Java Applications
Get Lower Latency and Higher Throughput for Java ApplicationsScyllaDB
 
LXC on Ganeti
LXC on GanetiLXC on Ganeti
LXC on Ganetikawamuray
 
Elephant Roads: a tour of Postgres forks
Elephant Roads: a tour of Postgres forksElephant Roads: a tour of Postgres forks
Elephant Roads: a tour of Postgres forksCommand Prompt., Inc
 
OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...
OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...
OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...ScyllaDB
 
GitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons LearnedGitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons LearnedAlexey Lesovsky
 
OpenNebulaconf2017US: Rapid scaling of research computing to over 70,000 cor...
OpenNebulaconf2017US:  Rapid scaling of research computing to over 70,000 cor...OpenNebulaconf2017US:  Rapid scaling of research computing to over 70,000 cor...
OpenNebulaconf2017US: Rapid scaling of research computing to over 70,000 cor...OpenNebula Project
 
Bpf performance tools chapter 4 bcc
Bpf performance tools chapter 4   bccBpf performance tools chapter 4   bcc
Bpf performance tools chapter 4 bccViller Hsiao
 
cache2k, Java Caching, Turbo Charged, FOSDEM 2015
cache2k, Java Caching, Turbo Charged, FOSDEM 2015cache2k, Java Caching, Turbo Charged, FOSDEM 2015
cache2k, Java Caching, Turbo Charged, FOSDEM 2015cruftex
 
Brief introduction to kselftest
Brief introduction to kselftestBrief introduction to kselftest
Brief introduction to kselftestSeongJae Park
 
Analyzing Java Applications Using Thermostat (Omair Majid)
Analyzing Java Applications Using Thermostat (Omair Majid)Analyzing Java Applications Using Thermostat (Omair Majid)
Analyzing Java Applications Using Thermostat (Omair Majid)Red Hat Developers
 

Mais procurados (20)

Le guide de dépannage de la jvm
Le guide de dépannage de la jvmLe guide de dépannage de la jvm
Le guide de dépannage de la jvm
 
Tools for Metaspace
Tools for MetaspaceTools for Metaspace
Tools for Metaspace
 
Using Flame Graphs
Using Flame GraphsUsing Flame Graphs
Using Flame Graphs
 
OSCON2012TroubleShootJava
OSCON2012TroubleShootJavaOSCON2012TroubleShootJava
OSCON2012TroubleShootJava
 
Software Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaSoftware Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in Java
 
Multimaster
MultimasterMultimaster
Multimaster
 
Tuning Linux for MongoDB
Tuning Linux for MongoDBTuning Linux for MongoDB
Tuning Linux for MongoDB
 
On the benchmark of Chainer
On the benchmark of ChainerOn the benchmark of Chainer
On the benchmark of Chainer
 
Jvm problem diagnostics
Jvm problem diagnosticsJvm problem diagnostics
Jvm problem diagnostics
 
Get Lower Latency and Higher Throughput for Java Applications
Get Lower Latency and Higher Throughput for Java ApplicationsGet Lower Latency and Higher Throughput for Java Applications
Get Lower Latency and Higher Throughput for Java Applications
 
Java GC, Off-heap workshop
Java GC, Off-heap workshopJava GC, Off-heap workshop
Java GC, Off-heap workshop
 
LXC on Ganeti
LXC on GanetiLXC on Ganeti
LXC on Ganeti
 
Elephant Roads: a tour of Postgres forks
Elephant Roads: a tour of Postgres forksElephant Roads: a tour of Postgres forks
Elephant Roads: a tour of Postgres forks
 
OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...
OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...
OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...
 
GitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons LearnedGitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons Learned
 
OpenNebulaconf2017US: Rapid scaling of research computing to over 70,000 cor...
OpenNebulaconf2017US:  Rapid scaling of research computing to over 70,000 cor...OpenNebulaconf2017US:  Rapid scaling of research computing to over 70,000 cor...
OpenNebulaconf2017US: Rapid scaling of research computing to over 70,000 cor...
 
Bpf performance tools chapter 4 bcc
Bpf performance tools chapter 4   bccBpf performance tools chapter 4   bcc
Bpf performance tools chapter 4 bcc
 
cache2k, Java Caching, Turbo Charged, FOSDEM 2015
cache2k, Java Caching, Turbo Charged, FOSDEM 2015cache2k, Java Caching, Turbo Charged, FOSDEM 2015
cache2k, Java Caching, Turbo Charged, FOSDEM 2015
 
Brief introduction to kselftest
Brief introduction to kselftestBrief introduction to kselftest
Brief introduction to kselftest
 
Analyzing Java Applications Using Thermostat (Omair Majid)
Analyzing Java Applications Using Thermostat (Omair Majid)Analyzing Java Applications Using Thermostat (Omair Majid)
Analyzing Java Applications Using Thermostat (Omair Majid)
 

Destaque

Tech giants of the last decade
Tech giants of the last decadeTech giants of the last decade
Tech giants of the last decadeInVenture Partners
 
標準人壽My Smart Planner Android 應用程式 - 轉換投資選擇
標準人壽My Smart Planner Android 應用程式 - 轉換投資選擇標準人壽My Smart Planner Android 應用程式 - 轉換投資選擇
標準人壽My Smart Planner Android 應用程式 - 轉換投資選擇StandardlifeAEM
 
標準人壽 iOS應用程式 - 轉換投資選擇
標準人壽 iOS應用程式 - 轉換投資選擇標準人壽 iOS應用程式 - 轉換投資選擇
標準人壽 iOS應用程式 - 轉換投資選擇StandardlifeAEM
 
what kind of media institution might distribute your media product and why?
what kind of media institution might distribute your media product and why?what kind of media institution might distribute your media product and why?
what kind of media institution might distribute your media product and why?furbymojo
 
Frank Jermusek: 5 Useful Commerical Real Estate Tips
Frank Jermusek: 5 Useful Commerical Real Estate TipsFrank Jermusek: 5 Useful Commerical Real Estate Tips
Frank Jermusek: 5 Useful Commerical Real Estate TipsFrank Jermusek
 
Polish Stocks 6. January 2017
Polish Stocks 6. January 2017 Polish Stocks 6. January 2017
Polish Stocks 6. January 2017 Gieldowy Wizjer
 
Slideshare ps2
Slideshare ps2 Slideshare ps2
Slideshare ps2 imcneal71
 
Vocabulary movie stars
Vocabulary movie starsVocabulary movie stars
Vocabulary movie starspatpen55
 
IAB Native Advertising Playbook 12-04-2013
IAB Native Advertising Playbook 12-04-2013IAB Native Advertising Playbook 12-04-2013
IAB Native Advertising Playbook 12-04-2013Newsmonkey
 
Magazine world is magnifique june 2014
Magazine world is magnifique june 2014Magazine world is magnifique june 2014
Magazine world is magnifique june 2014Prakash Montroy
 
Η Ρώμη - Η Αιώνια Πόλη
Η Ρώμη - Η Αιώνια ΠόληΗ Ρώμη - Η Αιώνια Πόλη
Η Ρώμη - Η Αιώνια Πόληangelosozil118
 
Digital marketing lecture flow
Digital marketing lecture flowDigital marketing lecture flow
Digital marketing lecture flowPranay Gothi
 
Digital marketing lecture flow
Digital marketing lecture flowDigital marketing lecture flow
Digital marketing lecture flowPranay Gothi
 
CDP Supply-Chain-report-2015
CDP Supply-Chain-report-2015CDP Supply-Chain-report-2015
CDP Supply-Chain-report-2015Siddhant Mishra
 

Destaque (19)

Tech giants of the last decade
Tech giants of the last decadeTech giants of the last decade
Tech giants of the last decade
 
標準人壽My Smart Planner Android 應用程式 - 轉換投資選擇
標準人壽My Smart Planner Android 應用程式 - 轉換投資選擇標準人壽My Smart Planner Android 應用程式 - 轉換投資選擇
標準人壽My Smart Planner Android 應用程式 - 轉換投資選擇
 
標準人壽 iOS應用程式 - 轉換投資選擇
標準人壽 iOS應用程式 - 轉換投資選擇標準人壽 iOS應用程式 - 轉換投資選擇
標準人壽 iOS應用程式 - 轉換投資選擇
 
what kind of media institution might distribute your media product and why?
what kind of media institution might distribute your media product and why?what kind of media institution might distribute your media product and why?
what kind of media institution might distribute your media product and why?
 
Danielle hardin
Danielle hardinDanielle hardin
Danielle hardin
 
Frank Jermusek: 5 Useful Commerical Real Estate Tips
Frank Jermusek: 5 Useful Commerical Real Estate TipsFrank Jermusek: 5 Useful Commerical Real Estate Tips
Frank Jermusek: 5 Useful Commerical Real Estate Tips
 
Polish Stocks 6. January 2017
Polish Stocks 6. January 2017 Polish Stocks 6. January 2017
Polish Stocks 6. January 2017
 
Slideshare ps2
Slideshare ps2 Slideshare ps2
Slideshare ps2
 
Vocabulary movie stars
Vocabulary movie starsVocabulary movie stars
Vocabulary movie stars
 
baocao
baocaobaocao
baocao
 
IAB Native Advertising Playbook 12-04-2013
IAB Native Advertising Playbook 12-04-2013IAB Native Advertising Playbook 12-04-2013
IAB Native Advertising Playbook 12-04-2013
 
Kelompok 2 komite etik
Kelompok 2 komite etikKelompok 2 komite etik
Kelompok 2 komite etik
 
Final proposal pp
Final proposal ppFinal proposal pp
Final proposal pp
 
Magazine world is magnifique june 2014
Magazine world is magnifique june 2014Magazine world is magnifique june 2014
Magazine world is magnifique june 2014
 
Η Ρώμη - Η Αιώνια Πόλη
Η Ρώμη - Η Αιώνια ΠόληΗ Ρώμη - Η Αιώνια Πόλη
Η Ρώμη - Η Αιώνια Πόλη
 
Digital marketing lecture flow
Digital marketing lecture flowDigital marketing lecture flow
Digital marketing lecture flow
 
Digital marketing lecture flow
Digital marketing lecture flowDigital marketing lecture flow
Digital marketing lecture flow
 
CDP Supply-Chain-report-2015
CDP Supply-Chain-report-2015CDP Supply-Chain-report-2015
CDP Supply-Chain-report-2015
 
Sap basis slide . pp
Sap basis slide . ppSap basis slide . pp
Sap basis slide . pp
 

Semelhante a JavaScript on Microcontrollers: Running JS on Embedded Devices

JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of ThingsJerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of ThingsSamsung Open Source Group
 
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Thin...
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Thin...JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Thin...
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Thin...Samsung Open Source Group
 
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»Anna Shymchenko
 
Deep Dive on Amazon EC2 instances
Deep Dive on Amazon EC2 instancesDeep Dive on Amazon EC2 instances
Deep Dive on Amazon EC2 instancesAmazon Web Services
 
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...Chester Chen
 
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020Jelastic Multi-Cloud PaaS
 
Improving DragonFly's performance with PostgreSQL by Francois Tigeot
Improving DragonFly's performance with PostgreSQL by Francois TigeotImproving DragonFly's performance with PostgreSQL by Francois Tigeot
Improving DragonFly's performance with PostgreSQL by Francois Tigeoteurobsdcon
 
20141111_SOS3_Gallo
20141111_SOS3_Gallo20141111_SOS3_Gallo
20141111_SOS3_GalloAndrea Gallo
 
Big Lab Problems Solved with Spectrum Scale: Innovations for the Coral Program
Big Lab Problems Solved with Spectrum Scale: Innovations for the Coral ProgramBig Lab Problems Solved with Spectrum Scale: Innovations for the Coral Program
Big Lab Problems Solved with Spectrum Scale: Innovations for the Coral Programinside-BigData.com
 
SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...
SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...
SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...Amazon Web Services
 
Optimizing Servers for High-Throughput and Low-Latency at Dropbox
Optimizing Servers for High-Throughput and Low-Latency at DropboxOptimizing Servers for High-Throughput and Low-Latency at Dropbox
Optimizing Servers for High-Throughput and Low-Latency at DropboxScyllaDB
 
SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...
SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...
SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...Amazon Web Services
 
SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...
SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...
SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...Amazon Web Services
 
Speedrunning the Open Street Map osm2pgsql Loader
Speedrunning the Open Street Map osm2pgsql LoaderSpeedrunning the Open Street Map osm2pgsql Loader
Speedrunning the Open Street Map osm2pgsql LoaderGregSmith458515
 
Computing Performance: On the Horizon (2021)
Computing Performance: On the Horizon (2021)Computing Performance: On the Horizon (2021)
Computing Performance: On the Horizon (2021)Brendan Gregg
 

Semelhante a JavaScript on Microcontrollers: Running JS on Embedded Devices (20)

Introduction to IoT.JS
Introduction to IoT.JSIntroduction to IoT.JS
Introduction to IoT.JS
 
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of ThingsJerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things
 
Introduction to IoT.JS
Introduction to IoT.JSIntroduction to IoT.JS
Introduction to IoT.JS
 
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Thin...
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Thin...JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Thin...
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Thin...
 
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
 
Deep Dive on Amazon EC2 instances
Deep Dive on Amazon EC2 instancesDeep Dive on Amazon EC2 instances
Deep Dive on Amazon EC2 instances
 
Cat @ scale
Cat @ scaleCat @ scale
Cat @ scale
 
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
 
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
 
Improving DragonFly's performance with PostgreSQL by Francois Tigeot
Improving DragonFly's performance with PostgreSQL by Francois TigeotImproving DragonFly's performance with PostgreSQL by Francois Tigeot
Improving DragonFly's performance with PostgreSQL by Francois Tigeot
 
20141111_SOS3_Gallo
20141111_SOS3_Gallo20141111_SOS3_Gallo
20141111_SOS3_Gallo
 
Big Lab Problems Solved with Spectrum Scale: Innovations for the Coral Program
Big Lab Problems Solved with Spectrum Scale: Innovations for the Coral ProgramBig Lab Problems Solved with Spectrum Scale: Innovations for the Coral Program
Big Lab Problems Solved with Spectrum Scale: Innovations for the Coral Program
 
SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...
SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...
SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...
 
Optimizing Servers for High-Throughput and Low-Latency at Dropbox
Optimizing Servers for High-Throughput and Low-Latency at DropboxOptimizing Servers for High-Throughput and Low-Latency at Dropbox
Optimizing Servers for High-Throughput and Low-Latency at Dropbox
 
Clang: More than just a C/C++ Compiler
Clang: More than just a C/C++ CompilerClang: More than just a C/C++ Compiler
Clang: More than just a C/C++ Compiler
 
SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...
SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...
SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...
 
SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...
SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...
SRV402 Deep Dive on Amazon EC2 Instances, Featuring Performance Optimization ...
 
Speedrunning the Open Street Map osm2pgsql Loader
Speedrunning the Open Street Map osm2pgsql LoaderSpeedrunning the Open Street Map osm2pgsql Loader
Speedrunning the Open Street Map osm2pgsql Loader
 
module01.ppt
module01.pptmodule01.ppt
module01.ppt
 
Computing Performance: On the Horizon (2021)
Computing Performance: On the Horizon (2021)Computing Performance: On the Horizon (2021)
Computing Performance: On the Horizon (2021)
 

Último

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Último (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

JavaScript on Microcontrollers: Running JS on Embedded Devices

  • 1. JavaScript on Microcontrollers Samsung Open Source Group 1 Tilmann Scheller LLVM Compiler Engineer t.scheller@samsung.com Samsung Open Source Group Samsung Research UK 2nd Samsung Web Tech Talk San Jose, USA, October 30, 2014
  • 2. Overview ● Introduction ● JavaScript engine code size ● JavaScript engine correctness/performance ● Summary Samsung Open Source Group 2
  • 3. Introduction Samsung Open Source Group 3
  • 4. Introduction ● Wearable devices becoming more and more widespread ● Weight and energy efficiency a big concern ● JavaScript very popular, easy to learn ● Scales from embedded to servers ● Execute JavaScript on a microcontroller! Samsung Open Source Group 4
  • 5. Target hardware ● Cortex-M3 microcontroller (32-bit ARM Thumb-2) ● 96KB of RAM ● 512KB of flash memory ● Clocked at 84MHz Samsung Open Source Group 5
  • 6. JS Engines ● Goal: JS engine which fits in the microcontroller constraints ● Option one: Pick an established JS engine and strip it down to fit on a microcontroller ● Option two: Pick a lightweight engine and make sure that it meets all the requirements Samsung Open Source Group 6
  • 7. JS Engines ● Two approaches pursued in parallel: – Try to minimize JavaScriptCore so that it fits on a microcontroller – Get the lightweight Duktape engine running on a microcontroller Samsung Open Source Group 7
  • 8. JavaScriptCore ● Well-established JS engine running on millions of devices ● High-performance (four distinct levels of optimization) ● Never intended to run in resource-constrained environments, primary focus is maximum performance ● Written in C++ Samsung Open Source Group 8
  • 9. Duktape ● Lightweight JS engine ● Focus on portability and a low footprint ● Written in C and about 40k lines of code (excluding comments) ● ECMAScript E5/E5.1 compliant ● Liberal license ● Active community, has been around for several years Samsung Open Source Group 9
  • 10. Code size Samsung Open Source Group 10
  • 11. JavaScriptCore minimization ● Challenge: JavaScriptCore was never intended for environments like this ● First attempt: – Took r170522 (June 26, 2014) of WebKit and built the EFL configuration for Thumb-2 ● Original (3.63 MB) ● Reduced (2.39 MB) ● Static (21.21 MB) – Several MB of heap memory consumed during runtime Samsung Open Source Group 11
  • 12. JavaScriptCore minimization ● Current snapshot: way too big! ● Second try: Use a snapshot from 2008 just before SquirrelFish was merged ● Performed minimizations: – Qt dependency was removed – Reduced the size of ICU data by disabling extra features – Rebuilt ICU with the –Os compiler option – Pthread was removed – Built older ICU libs – Stripped static JSC binary is now 1,647 KB (was: 19,578 KB) – The engine part of is 311 KB – The Unicode libraries are 562 Kbyte and the remaining size comes from libc, libm and libstdc++ libraries. Samsung Open Source Group 12
  • 13. JavaScriptCore minimization ● Engine size close to target size ● However, libraries rely on too many system calls to make it feasible to run on a baremetal system ● Too much effort to get JSC working on a baremetal system ● Aborting JSC investigation and directing all efforts towards Duktape Samsung Open Source Group 13
  • 14. Duktape ● Compiled for Thumb-2 ● Using the newlib C standard library ● No OS running on the microcontroller ● Statically linked binary ● C library has a big impact on the size of the executable ● Disabling certain optimizations (through preprocessor macros), helps to reduce code size even further Samsung Open Source Group 14
  • 15. Code size Static binary Engine Libraries 108 161 100 83 70 59 212 187 127 318 655 790 1207 311 0 200 400 600 800 1000 1200 1400 1600 1800 Samsung Open Source Group 15 1647 Duktape Thumb-2 baremetal noopt Duktape Thumb-2 baremetal Duktape ARM baremetal Duktape ARM Linux glibc JSC Thumb-2 Linux glibc KB Compiled at -Os ..., noopt = Duktape optimizations not compiled in, baremetal builds link against Newlib
  • 17. Correctness - test262 ● Duktape 0.12 and Arduino library 1.5.8, without DUK_OPT defines ● test262 (ECMAScript conformance test suite) results: – Ran 11824 tests ● Passed 11411 tests (96.5%) ● Failed 413 tests (3.5%) ● Failure details: – 144 tests ran out of memory – 10 tests timed out (300 secs) – 90 tests failed because of an undefined gettimeofday() function – 169 tests fail because of other reasons (have to be investigated) – Summary: 167 failures specific to the Arduino Due and 246 tests which fail on x86-64 as well Samsung Open Source Group 17
  • 18. test262 85 713 288957 Min Avg Max 350000 300000 250000 200000 150000 100000 50000 0 Execution time (ms) Samsung Open Source Group 18 Min Avg Max 80 70 60 50 40 30 20 10 0 54 57 75 Memory usage (KB)
  • 19. SunSpider ● Duktape 0.12 and Arduino library 1.5.8, without DUK_OPT defines ● Ran 26 tests – Passed 9 tests (34.6%) – Failed 17 tests (65.4%) ● Failure details: – 3 tests were too big (string-unpack-code.js (164K), string-tagcloud.js (172K), regexp-dna.js (400K)) – 13 tests run out of memory (3d-cube.js, 3d-morph.js, 3d-raytrace.js, access-binary-trees.js, access-nsieve.js, bitops-nsieve-bits.js, crypto-aes.js, crypto-md5.js, crypto-sha1.js, date-format-tofte.js, date-format-xparb.js, string-base64.js, string-validate-input.js) – 1 test failed because of undefined gettimeofday() function (math-cordic.js) Samsung Open Source Group 19
  • 20. SunSpider access-nbody 160 140 120 100 80 60 40 20 access-fannkuch bitops-bits-in-byte bitops-3bit-bits-in-byte controlflow-recursive bitops-bitwise-and math-partial-sums Samsung Open Source Group 20 math-spectral-norm string-fasta 0 149 41.5 64.3 74.8 140.2 25.9 62.3 21.8 119.9 54 64 50 49 50 70 51 53 57 Execution time (s) Memory usage (KB)
  • 21. Summary Samsung Open Source Group 21
  • 22. Summary ● JavaScriptCore proved to be unsuitable for microcontrollers ● Duktape fits well into flash and main memory ● Duktape has promising correctness results ● Ongoing effort to evaluate Duktape performance Samsung Open Source Group 22
  • 23. Thank you. Samsung Open Source Group 23
  • 24. We are hiring! Contact Information: Tilmann Scheller t.scheller@samsung.com Samsung Open Source Group Samsung Research UK Samsung Open Source Group 24