SlideShare a Scribd company logo
LAUNCHING RUBY IN 32
KILOBYTES
MIKHAIL BORTNYK
LAUNCHING RUBY IN 32 KILOBYTES
WHO AM I
▸ Mikhail Bortnyk, (not only) Ruby developer
▸ kottans.org co-founder
▸ github: @vessi
▸ twitter: @mikhailbortnyk
LAUNCHING RUBY IN 32 KILOBYTES
FOR WHY?
▸ because I can
▸ I love Ruby
▸ interested in IoT
▸ learn more about languages virtual machines
▸ learn more about optimisation
▸ get a touch with a real hardware
▸ I want to get fucking led blinking!
LAUNCHING RUBY IN 32 KILOBYTES
OPTIONS I KNEW BEFORE
▸ Ruby
▸ mRuby
LAUNCHING RUBY IN 32 KILOBYTES
RUBY
▸ Pros:
▸ full language stack
▸ very long story
▸ most of bugs cleared
▸ I have everyday work experience
▸ Cons:
▸ consumes too much memory (valgrind shows ~9Mb)
▸ too big
▸ platform-dependent
▸ bytecode is very experimental
LAUNCHING RUBY IN 32 KILOBYTES
MRUBY
▸ Pros:
▸ relatively smaller
▸ actively supported by @matz
▸ proved builds on bigger MCUs (Raspberry Pi and powerful ChipKIT boards)
▸ code can be compiled into byte code to reduce execution time
▸ Cons:
▸ still consumes too much memory (but only 4% from big Ruby, ~400kb)
▸ has complicated build system
▸ partially connected with filesystem so you can’t use FS-less configurations
LAUNCHING RUBY IN 32 KILOBYTES
LIMITATIONS
▸ Result build should:
▸ fit in 32K of RAM
▸ take less than 512K
▸ can operate without file system
▸ It will be good if result build can operate with target’s
hardware
LAUNCHING RUBY IN 32 KILOBYTES
FIRST TRY
▸ Author: Doug Bradbury
▸ Date: 19 Dec 2008
▸ Target board: Glomation GESBC-2440
▸ Target params: 400MHz ARM CPU, 128 MB SDRAM, 64
MB FLASH and Linux 2.6.18
▸ Ruby version: 1.8.6-p111
LAUNCHING RUBY IN 32 KILOBYTES
NEXT STEP (POSSIBLY NOT VERY ACCURATE)
▸ Author: kyab
▸ Date: 31 Dec 2012
▸ Target board: ChipKIT Max32
▸ Target params: PIC32MX795F512L 80MHz MCU, 128KB RAM, 512KB flash
▸ mRuby version: 1.0.0
▸ Caveats: lost Regexps, reduced heap 16 times (64 objects instead of 1024),
lost Time class, gems are disabled
▸ No REPL, only constant code evaluation
▸ requires MPIDE to cross-compile
AND I HAVE
FOUND
LAUNCHING RUBY IN 32 KILOBYTES
LAUNCHING RUBY IN 32 KILOBYTES
MRUBY/C PROTOTYPE
▸ Author: Shimane IT Open-Innovation Centre (in reality the
only developer is Kazuaki Tanaka)
▸ First presentation of idea: 11 Nov 2015, on slideshare
▸ I found this presentation and wrote email to achieve very
alpha version: 4 Mar 2016
▸ Project gone opensource: 17 Mar 2016
LAUNCHING RUBY IN 32 KILOBYTES
MRUBY/C DESCRIPTION
▸ Written in pure C, Makefiles are used to build
▸ Fits in 16K of memory
▸ Totally lost everything in stdlib, only Array, Float and Object
classes left
▸ More than 40% of VM instructions are not implemented yet
▸ Heap is statically linked (length is configurable in time of
compilation)
DEMO TIME
I AM GOING TO COMPILE RUBY AND BYTECODE,
FLASH BOARDS, BLINK LEDS AND LOOK PROUD
FOR NO REASON
LAUNCHING RUBY IN 32 KILOBYTES
LAUNCHING RUBY IN 32 KILOBYTES
WHAT HAVE I DID
▸ Added cross-compiling system (stolen idea from
micropython)
▸ Added simple HAL to avoid printf calls and remove libc
dependency (-10kb of flash size)
▸ Fixed lambda support (not totally)
▸ Added constants support
LAUNCHING RUBY IN 32 KILOBYTES
WHAT I AM PLANNING TO DO
▸ Add IREP subsequences support (IREP is byte code
sequence)
▸ Add runtime class declaration
▸ Move to dynamic memory management system
▸ Try to port lexer and compiler parts
▸ Try to implement REPL
▸ Try to implement network access (need ESP8266 board!)
LAUNCHING RUBY IN 32 KILOBYTES
THANKS SECTION
▸ To Mykhailo Odyniuk: this work would be totally
impossible without him. He provided me two
development boards I used in time of porting
▸ To Shimane ITOC and Kenji Sugihara personally for quick
replies and good presentation
▸ To Kazuaki Tanaka for the great work he did implementing
alpha and beta versions of mruby/c
LAUNCHING RUBY IN 32 KILOBYTES
KAZUAKI TANAKA
▸ The guy to say ‘Arigato!’
▸ @kaz0505 on Github
▸ Associate professor at Kyushu
Institute of Technology
▸ Profile on LinkedIn
QUESTIONS
AND ANSWERS
LAUNCHING RUBY IN 32 KILOBYTES

More Related Content

What's hot

Introducing CentOS container pipeline
Introducing CentOS container pipelineIntroducing CentOS container pipeline
Introducing CentOS container pipeline
Dharmit Shah
 
NUS-ISS Learning Day 2017 - Bots-Managed CloudOps
NUS-ISS Learning Day 2017 - Bots-Managed CloudOpsNUS-ISS Learning Day 2017 - Bots-Managed CloudOps
NUS-ISS Learning Day 2017 - Bots-Managed CloudOps
NUS-ISS
 
CRI Runtimes Deep-Dive: Who's Running My Pod!?
CRI Runtimes Deep-Dive: Who's Running My Pod!?CRI Runtimes Deep-Dive: Who's Running My Pod!?
CRI Runtimes Deep-Dive: Who's Running My Pod!?
Phil Estes
 
Docker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los AngelesDocker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los Angeles
Jérôme Petazzoni
 
Introduction to Docker, December 2014 "Tour de France" Edition
Introduction to Docker, December 2014 "Tour de France" EditionIntroduction to Docker, December 2014 "Tour de France" Edition
Introduction to Docker, December 2014 "Tour de France" Edition
Jérôme Petazzoni
 
Docker e git lab
Docker e git labDocker e git lab
Docker e git lab
Gianluca Padovani
 
Types - slice, map, new, make, struct - Gopherlabs
Types - slice, map, new, make, struct - Gopherlabs Types - slice, map, new, make, struct - Gopherlabs
Types - slice, map, new, make, struct - Gopherlabs
sangam biradar
 
Whose Job Is It Anyway? Kubernetes, CRI, & Container Runtimes
Whose Job Is It Anyway? Kubernetes, CRI, & Container RuntimesWhose Job Is It Anyway? Kubernetes, CRI, & Container Runtimes
Whose Job Is It Anyway? Kubernetes, CRI, & Container Runtimes
Phil Estes
 
Docker intro workshop: Dockerize your PHP app
Docker  intro workshop: Dockerize your PHP appDocker  intro workshop: Dockerize your PHP app
Docker intro workshop: Dockerize your PHP app
Andrés Collado
 
Decision making - for loop , nested loop ,if-else statements , switch in goph...
Decision making - for loop , nested loop ,if-else statements , switch in goph...Decision making - for loop , nested loop ,if-else statements , switch in goph...
Decision making - for loop , nested loop ,if-else statements , switch in goph...
sangam biradar
 
Gluster containers!
Gluster containers!Gluster containers!
Gluster containers!
Humble Chirammal
 
Workshop on Source control, git merge walkthroughs
Workshop on Source control, git merge walkthroughsWorkshop on Source control, git merge walkthroughs
Workshop on Source control, git merge walkthroughs
David Lawrence
 
Build and run applications in a dockerless kubernetes world - DevConf India 18
Build and run applications in a dockerless kubernetes world - DevConf India 18Build and run applications in a dockerless kubernetes world - DevConf India 18
Build and run applications in a dockerless kubernetes world - DevConf India 18
Jorge Morales
 
Vagrant, Ansible and Docker - How they fit together for productive flexible d...
Vagrant, Ansible and Docker - How they fit together for productive flexible d...Vagrant, Ansible and Docker - How they fit together for productive flexible d...
Vagrant, Ansible and Docker - How they fit together for productive flexible d...
Samuel Lampa
 
[KubeCon EU 2020] containerd Deep Dive
[KubeCon EU 2020] containerd Deep Dive[KubeCon EU 2020] containerd Deep Dive
[KubeCon EU 2020] containerd Deep Dive
Akihiro Suda
 
Boston Code Dojo - Docker meetup slides
Boston Code Dojo - Docker meetup slidesBoston Code Dojo - Docker meetup slides
Boston Code Dojo - Docker meetup slides
Calvin Froedge
 
Understand docker
Understand dockerUnderstand docker
Understand docker
Harry Oh
 
Fabric8 CI/CD
Fabric8 CI/CDFabric8 CI/CD
Fabric8 CI/CD
Izzet Mustafaiev
 
[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...
[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...
[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...
Akihiro Suda
 
The world of Containers with Podman, Buildah, Skopeo by Seema - CCDays
The world of Containers with Podman, Buildah, Skopeo by Seema - CCDaysThe world of Containers with Podman, Buildah, Skopeo by Seema - CCDays
The world of Containers with Podman, Buildah, Skopeo by Seema - CCDays
CodeOps Technologies LLP
 

What's hot (20)

Introducing CentOS container pipeline
Introducing CentOS container pipelineIntroducing CentOS container pipeline
Introducing CentOS container pipeline
 
NUS-ISS Learning Day 2017 - Bots-Managed CloudOps
NUS-ISS Learning Day 2017 - Bots-Managed CloudOpsNUS-ISS Learning Day 2017 - Bots-Managed CloudOps
NUS-ISS Learning Day 2017 - Bots-Managed CloudOps
 
CRI Runtimes Deep-Dive: Who's Running My Pod!?
CRI Runtimes Deep-Dive: Who's Running My Pod!?CRI Runtimes Deep-Dive: Who's Running My Pod!?
CRI Runtimes Deep-Dive: Who's Running My Pod!?
 
Docker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los AngelesDocker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los Angeles
 
Introduction to Docker, December 2014 "Tour de France" Edition
Introduction to Docker, December 2014 "Tour de France" EditionIntroduction to Docker, December 2014 "Tour de France" Edition
Introduction to Docker, December 2014 "Tour de France" Edition
 
Docker e git lab
Docker e git labDocker e git lab
Docker e git lab
 
Types - slice, map, new, make, struct - Gopherlabs
Types - slice, map, new, make, struct - Gopherlabs Types - slice, map, new, make, struct - Gopherlabs
Types - slice, map, new, make, struct - Gopherlabs
 
Whose Job Is It Anyway? Kubernetes, CRI, & Container Runtimes
Whose Job Is It Anyway? Kubernetes, CRI, & Container RuntimesWhose Job Is It Anyway? Kubernetes, CRI, & Container Runtimes
Whose Job Is It Anyway? Kubernetes, CRI, & Container Runtimes
 
Docker intro workshop: Dockerize your PHP app
Docker  intro workshop: Dockerize your PHP appDocker  intro workshop: Dockerize your PHP app
Docker intro workshop: Dockerize your PHP app
 
Decision making - for loop , nested loop ,if-else statements , switch in goph...
Decision making - for loop , nested loop ,if-else statements , switch in goph...Decision making - for loop , nested loop ,if-else statements , switch in goph...
Decision making - for loop , nested loop ,if-else statements , switch in goph...
 
Gluster containers!
Gluster containers!Gluster containers!
Gluster containers!
 
Workshop on Source control, git merge walkthroughs
Workshop on Source control, git merge walkthroughsWorkshop on Source control, git merge walkthroughs
Workshop on Source control, git merge walkthroughs
 
Build and run applications in a dockerless kubernetes world - DevConf India 18
Build and run applications in a dockerless kubernetes world - DevConf India 18Build and run applications in a dockerless kubernetes world - DevConf India 18
Build and run applications in a dockerless kubernetes world - DevConf India 18
 
Vagrant, Ansible and Docker - How they fit together for productive flexible d...
Vagrant, Ansible and Docker - How they fit together for productive flexible d...Vagrant, Ansible and Docker - How they fit together for productive flexible d...
Vagrant, Ansible and Docker - How they fit together for productive flexible d...
 
[KubeCon EU 2020] containerd Deep Dive
[KubeCon EU 2020] containerd Deep Dive[KubeCon EU 2020] containerd Deep Dive
[KubeCon EU 2020] containerd Deep Dive
 
Boston Code Dojo - Docker meetup slides
Boston Code Dojo - Docker meetup slidesBoston Code Dojo - Docker meetup slides
Boston Code Dojo - Docker meetup slides
 
Understand docker
Understand dockerUnderstand docker
Understand docker
 
Fabric8 CI/CD
Fabric8 CI/CDFabric8 CI/CD
Fabric8 CI/CD
 
[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...
[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...
[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...
 
The world of Containers with Podman, Buildah, Skopeo by Seema - CCDays
The world of Containers with Podman, Buildah, Skopeo by Seema - CCDaysThe world of Containers with Podman, Buildah, Skopeo by Seema - CCDays
The world of Containers with Podman, Buildah, Skopeo by Seema - CCDays
 

Similar to Let's Count Bytes! Launching Ruby in 32K of RAM

DockerCon EU 2015: Breaking the RPiDocker Challenge
DockerCon EU 2015: Breaking the RPiDocker Challenge DockerCon EU 2015: Breaking the RPiDocker Challenge
DockerCon EU 2015: Breaking the RPiDocker Challenge
Docker, Inc.
 
Breaking the RpiDocker challenge
Breaking the RpiDocker challenge Breaking the RpiDocker challenge
Breaking the RpiDocker challenge
Nicolas De Loof
 
Docker Online Meetup #27: Raspberry Pi DockerCon Challenge
Docker Online Meetup #27: Raspberry Pi DockerCon ChallengeDocker Online Meetup #27: Raspberry Pi DockerCon Challenge
Docker Online Meetup #27: Raspberry Pi DockerCon Challenge
Docker, Inc.
 
Breaking the Ruby Performance Barrier with YJIT
Breaking the Ruby Performance Barrier with YJITBreaking the Ruby Performance Barrier with YJIT
Breaking the Ruby Performance Barrier with YJIT
maximechevalierboisv1
 
Headless Android at AnDevCon3
Headless Android at AnDevCon3Headless Android at AnDevCon3
Headless Android at AnDevCon3
Opersys inc.
 
Docker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12xDocker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12x
rkr10
 
A Gentle Introduction to Docker and Containers
A Gentle Introduction to Docker and ContainersA Gentle Introduction to Docker and Containers
A Gentle Introduction to Docker and ContainersDocker, Inc.
 
Untangling fall2017 week2_try2
Untangling fall2017 week2_try2Untangling fall2017 week2_try2
Untangling fall2017 week2_try2
Derek Jacoby
 
Untangling fall2017 week2
Untangling fall2017 week2Untangling fall2017 week2
Untangling fall2017 week2
Derek Jacoby
 
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special EditionIntroduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
Jérôme Petazzoni
 
Pentesting an unfriendly environment: bypassing (un)common defences and mate ...
Pentesting an unfriendly environment: bypassing (un)common defences and mate ...Pentesting an unfriendly environment: bypassing (un)common defences and mate ...
Pentesting an unfriendly environment: bypassing (un)common defences and mate ...
Sandro Zaccarini
 
Mono Repo
Mono RepoMono Repo
Mono Repo
Zacky Pickholz
 
Take care of hundred containers and not go crazy
Take care of hundred containers and not go crazyTake care of hundred containers and not go crazy
Take care of hundred containers and not go crazy
Honza Horák
 
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo..."Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
Yandex
 
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
dotCloud
 
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Docker, Inc.
 
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @GuidewireIntroduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
dotCloud
 
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Jérôme Petazzoni
 
A Gentle Introduction To Docker And All Things Containers
A Gentle Introduction To Docker And All Things ContainersA Gentle Introduction To Docker And All Things Containers
A Gentle Introduction To Docker And All Things Containers
Jérôme Petazzoni
 
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
Introduction to Docker and all things containers, Docker Meetup at RelateIQIntroduction to Docker and all things containers, Docker Meetup at RelateIQ
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
dotCloud
 

Similar to Let's Count Bytes! Launching Ruby in 32K of RAM (20)

DockerCon EU 2015: Breaking the RPiDocker Challenge
DockerCon EU 2015: Breaking the RPiDocker Challenge DockerCon EU 2015: Breaking the RPiDocker Challenge
DockerCon EU 2015: Breaking the RPiDocker Challenge
 
Breaking the RpiDocker challenge
Breaking the RpiDocker challenge Breaking the RpiDocker challenge
Breaking the RpiDocker challenge
 
Docker Online Meetup #27: Raspberry Pi DockerCon Challenge
Docker Online Meetup #27: Raspberry Pi DockerCon ChallengeDocker Online Meetup #27: Raspberry Pi DockerCon Challenge
Docker Online Meetup #27: Raspberry Pi DockerCon Challenge
 
Breaking the Ruby Performance Barrier with YJIT
Breaking the Ruby Performance Barrier with YJITBreaking the Ruby Performance Barrier with YJIT
Breaking the Ruby Performance Barrier with YJIT
 
Headless Android at AnDevCon3
Headless Android at AnDevCon3Headless Android at AnDevCon3
Headless Android at AnDevCon3
 
Docker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12xDocker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12x
 
A Gentle Introduction to Docker and Containers
A Gentle Introduction to Docker and ContainersA Gentle Introduction to Docker and Containers
A Gentle Introduction to Docker and Containers
 
Untangling fall2017 week2_try2
Untangling fall2017 week2_try2Untangling fall2017 week2_try2
Untangling fall2017 week2_try2
 
Untangling fall2017 week2
Untangling fall2017 week2Untangling fall2017 week2
Untangling fall2017 week2
 
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special EditionIntroduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
 
Pentesting an unfriendly environment: bypassing (un)common defences and mate ...
Pentesting an unfriendly environment: bypassing (un)common defences and mate ...Pentesting an unfriendly environment: bypassing (un)common defences and mate ...
Pentesting an unfriendly environment: bypassing (un)common defences and mate ...
 
Mono Repo
Mono RepoMono Repo
Mono Repo
 
Take care of hundred containers and not go crazy
Take care of hundred containers and not go crazyTake care of hundred containers and not go crazy
Take care of hundred containers and not go crazy
 
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo..."Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
 
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
 
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
 
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @GuidewireIntroduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
 
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
 
A Gentle Introduction To Docker And All Things Containers
A Gentle Introduction To Docker And All Things ContainersA Gentle Introduction To Docker And All Things Containers
A Gentle Introduction To Docker And All Things Containers
 
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
Introduction to Docker and all things containers, Docker Meetup at RelateIQIntroduction to Docker and all things containers, Docker Meetup at RelateIQ
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
 

More from Amoniac OÜ

Dokku your own heroku 21
Dokku   your own heroku 21Dokku   your own heroku 21
Dokku your own heroku 21
Amoniac OÜ
 
GO in Heterogeneous Language Environments
GO in Heterogeneous Language EnvironmentsGO in Heterogeneous Language Environments
GO in Heterogeneous Language Environments
Amoniac OÜ
 
Cleaners of Caribbean
Cleaners of CaribbeanCleaners of Caribbean
Cleaners of Caribbean
Amoniac OÜ
 
Ruby JIT Compilation
Ruby JIT CompilationRuby JIT Compilation
Ruby JIT Compilation
Amoniac OÜ
 
Ambiguous Sinatra
Ambiguous SinatraAmbiguous Sinatra
Ambiguous Sinatra
Amoniac OÜ
 
Capistrano and SystemD
Capistrano and SystemDCapistrano and SystemD
Capistrano and SystemD
Amoniac OÜ
 
Distributed Cluster in Ruby
Distributed Cluster in RubyDistributed Cluster in Ruby
Distributed Cluster in Ruby
Amoniac OÜ
 
Roda: Putting the Fun Back into Ruby Web Development
Roda: Putting the Fun Back into Ruby Web DevelopmentRoda: Putting the Fun Back into Ruby Web Development
Roda: Putting the Fun Back into Ruby Web Development
Amoniac OÜ
 
Rubymotion: Overview and Ecosystem
Rubymotion: Overview and EcosystemRubymotion: Overview and Ecosystem
Rubymotion: Overview and Ecosystem
Amoniac OÜ
 
Rupher
RupherRupher
Rupher
Amoniac OÜ
 
Different Ways of Integrating React into Rails - Pros and Cons
Different Ways of Integrating React into Rails - Pros and ConsDifferent Ways of Integrating React into Rails - Pros and Cons
Different Ways of Integrating React into Rails - Pros and Cons
Amoniac OÜ
 
Functional Web Apps with WebMachine Framework
Functional Web Apps with WebMachine FrameworkFunctional Web Apps with WebMachine Framework
Functional Web Apps with WebMachine Framework
Amoniac OÜ
 
Functional Ruby
Functional RubyFunctional Ruby
Functional Ruby
Amoniac OÜ
 
How to Become a Сhef
How to Become a СhefHow to Become a Сhef
How to Become a Сhef
Amoniac OÜ
 
Deployment tales
Deployment talesDeployment tales
Deployment tales
Amoniac OÜ
 

More from Amoniac OÜ (15)

Dokku your own heroku 21
Dokku   your own heroku 21Dokku   your own heroku 21
Dokku your own heroku 21
 
GO in Heterogeneous Language Environments
GO in Heterogeneous Language EnvironmentsGO in Heterogeneous Language Environments
GO in Heterogeneous Language Environments
 
Cleaners of Caribbean
Cleaners of CaribbeanCleaners of Caribbean
Cleaners of Caribbean
 
Ruby JIT Compilation
Ruby JIT CompilationRuby JIT Compilation
Ruby JIT Compilation
 
Ambiguous Sinatra
Ambiguous SinatraAmbiguous Sinatra
Ambiguous Sinatra
 
Capistrano and SystemD
Capistrano and SystemDCapistrano and SystemD
Capistrano and SystemD
 
Distributed Cluster in Ruby
Distributed Cluster in RubyDistributed Cluster in Ruby
Distributed Cluster in Ruby
 
Roda: Putting the Fun Back into Ruby Web Development
Roda: Putting the Fun Back into Ruby Web DevelopmentRoda: Putting the Fun Back into Ruby Web Development
Roda: Putting the Fun Back into Ruby Web Development
 
Rubymotion: Overview and Ecosystem
Rubymotion: Overview and EcosystemRubymotion: Overview and Ecosystem
Rubymotion: Overview and Ecosystem
 
Rupher
RupherRupher
Rupher
 
Different Ways of Integrating React into Rails - Pros and Cons
Different Ways of Integrating React into Rails - Pros and ConsDifferent Ways of Integrating React into Rails - Pros and Cons
Different Ways of Integrating React into Rails - Pros and Cons
 
Functional Web Apps with WebMachine Framework
Functional Web Apps with WebMachine FrameworkFunctional Web Apps with WebMachine Framework
Functional Web Apps with WebMachine Framework
 
Functional Ruby
Functional RubyFunctional Ruby
Functional Ruby
 
How to Become a Сhef
How to Become a СhefHow to Become a Сhef
How to Become a Сhef
 
Deployment tales
Deployment talesDeployment tales
Deployment tales
 

Recently uploaded

WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Hivelance Technology
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
NaapbooksPrivateLimi
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Why React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdfWhy React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdf
ayushiqss
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
varshanayak241
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 

Recently uploaded (20)

WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Why React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdfWhy React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdf
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 

Let's Count Bytes! Launching Ruby in 32K of RAM

  • 1. LAUNCHING RUBY IN 32 KILOBYTES MIKHAIL BORTNYK
  • 2. LAUNCHING RUBY IN 32 KILOBYTES WHO AM I ▸ Mikhail Bortnyk, (not only) Ruby developer ▸ kottans.org co-founder ▸ github: @vessi ▸ twitter: @mikhailbortnyk
  • 3. LAUNCHING RUBY IN 32 KILOBYTES FOR WHY? ▸ because I can ▸ I love Ruby ▸ interested in IoT ▸ learn more about languages virtual machines ▸ learn more about optimisation ▸ get a touch with a real hardware ▸ I want to get fucking led blinking!
  • 4. LAUNCHING RUBY IN 32 KILOBYTES OPTIONS I KNEW BEFORE ▸ Ruby ▸ mRuby
  • 5. LAUNCHING RUBY IN 32 KILOBYTES RUBY ▸ Pros: ▸ full language stack ▸ very long story ▸ most of bugs cleared ▸ I have everyday work experience ▸ Cons: ▸ consumes too much memory (valgrind shows ~9Mb) ▸ too big ▸ platform-dependent ▸ bytecode is very experimental
  • 6. LAUNCHING RUBY IN 32 KILOBYTES MRUBY ▸ Pros: ▸ relatively smaller ▸ actively supported by @matz ▸ proved builds on bigger MCUs (Raspberry Pi and powerful ChipKIT boards) ▸ code can be compiled into byte code to reduce execution time ▸ Cons: ▸ still consumes too much memory (but only 4% from big Ruby, ~400kb) ▸ has complicated build system ▸ partially connected with filesystem so you can’t use FS-less configurations
  • 7. LAUNCHING RUBY IN 32 KILOBYTES LIMITATIONS ▸ Result build should: ▸ fit in 32K of RAM ▸ take less than 512K ▸ can operate without file system ▸ It will be good if result build can operate with target’s hardware
  • 8. LAUNCHING RUBY IN 32 KILOBYTES FIRST TRY ▸ Author: Doug Bradbury ▸ Date: 19 Dec 2008 ▸ Target board: Glomation GESBC-2440 ▸ Target params: 400MHz ARM CPU, 128 MB SDRAM, 64 MB FLASH and Linux 2.6.18 ▸ Ruby version: 1.8.6-p111
  • 9. LAUNCHING RUBY IN 32 KILOBYTES NEXT STEP (POSSIBLY NOT VERY ACCURATE) ▸ Author: kyab ▸ Date: 31 Dec 2012 ▸ Target board: ChipKIT Max32 ▸ Target params: PIC32MX795F512L 80MHz MCU, 128KB RAM, 512KB flash ▸ mRuby version: 1.0.0 ▸ Caveats: lost Regexps, reduced heap 16 times (64 objects instead of 1024), lost Time class, gems are disabled ▸ No REPL, only constant code evaluation ▸ requires MPIDE to cross-compile
  • 10. AND I HAVE FOUND LAUNCHING RUBY IN 32 KILOBYTES
  • 11. LAUNCHING RUBY IN 32 KILOBYTES MRUBY/C PROTOTYPE ▸ Author: Shimane IT Open-Innovation Centre (in reality the only developer is Kazuaki Tanaka) ▸ First presentation of idea: 11 Nov 2015, on slideshare ▸ I found this presentation and wrote email to achieve very alpha version: 4 Mar 2016 ▸ Project gone opensource: 17 Mar 2016
  • 12. LAUNCHING RUBY IN 32 KILOBYTES MRUBY/C DESCRIPTION ▸ Written in pure C, Makefiles are used to build ▸ Fits in 16K of memory ▸ Totally lost everything in stdlib, only Array, Float and Object classes left ▸ More than 40% of VM instructions are not implemented yet ▸ Heap is statically linked (length is configurable in time of compilation)
  • 13. DEMO TIME I AM GOING TO COMPILE RUBY AND BYTECODE, FLASH BOARDS, BLINK LEDS AND LOOK PROUD FOR NO REASON LAUNCHING RUBY IN 32 KILOBYTES
  • 14. LAUNCHING RUBY IN 32 KILOBYTES WHAT HAVE I DID ▸ Added cross-compiling system (stolen idea from micropython) ▸ Added simple HAL to avoid printf calls and remove libc dependency (-10kb of flash size) ▸ Fixed lambda support (not totally) ▸ Added constants support
  • 15. LAUNCHING RUBY IN 32 KILOBYTES WHAT I AM PLANNING TO DO ▸ Add IREP subsequences support (IREP is byte code sequence) ▸ Add runtime class declaration ▸ Move to dynamic memory management system ▸ Try to port lexer and compiler parts ▸ Try to implement REPL ▸ Try to implement network access (need ESP8266 board!)
  • 16. LAUNCHING RUBY IN 32 KILOBYTES THANKS SECTION ▸ To Mykhailo Odyniuk: this work would be totally impossible without him. He provided me two development boards I used in time of porting ▸ To Shimane ITOC and Kenji Sugihara personally for quick replies and good presentation ▸ To Kazuaki Tanaka for the great work he did implementing alpha and beta versions of mruby/c
  • 17. LAUNCHING RUBY IN 32 KILOBYTES KAZUAKI TANAKA ▸ The guy to say ‘Arigato!’ ▸ @kaz0505 on Github ▸ Associate professor at Kyushu Institute of Technology ▸ Profile on LinkedIn