SlideShare a Scribd company logo
Mirage: ML kernels in the cloud Anil Madhavapeddy, University of Cambridge Thomas Gazagnaire, INRIA Computer Laboratory, 15 JJ Thomson Avenue, Cambridge, UK Contributions from Tim Deegan (Citrix), Steven Hand (Cambridge), Steven Smith (Cambridge) , Jon Crowcroft (Cambridge)
Motivation: Layers Hardware Processes OS Kernel Threads Application
Motivation: Layers Hardware Processes OS Kernel Threads Application Language Runtime
Motivation: Layers Hardware Processes OS Kernel Threads Application Hypervisor Language Runtime
Motivation: Security Linux Kernel Mar 1994:  176,250 LoC  May 2010:  13,320,934 LoC Most core Internet services still written in C / C++
Mirage: Approach Construct an OS designed to run on the cloud End-to-end static type safety using OCaml + DSLs More build-time analysis (“whole OS optimisation”) Simple single-threaded core, using the hypervisor to divide up cores
Mirage: OS “signature” begins module  Console :  sig type  t val  create : unit -> t val  write : t -> string -> int -> int -> unit end
Mirage: A simple “hello world” Xen runs  para-virtualized  kernels, that cooperate with the hypervisor. Most code runs unmodified Privileged instructions (page table updates) go via Xen  hypercalls $ echo ‘let _ = print_endline “hello Xen world!”’ > hello.ml $ ocamlopt –output-obj –o app.o hello.ml Linked to a “Xen MiniOS” to make a bootable kernel. Boots in 64-bit mode directly, with starting memory all mapped. Is approximately 50-100KB in size.
Mirage: 64-bit Xen Memory Layout OS Text and Data Network Buffers Reserved OCaml minor heap OCaml major heap
Mirage: Network Buffers OS Text and Data Network Buffers Reserved OCaml minor heap OCaml major heap IP Header TCP Header Transmit packet data IP Header TCP Header Receive packet data
Mirage: x86 superpages for OCaml heap OS Text and Data Network Buffers Reserved OCaml minor heap OCaml major heap Reduces TLB pressure significantly. Is_in_heap  check is much simpler Improve GC/cache interaction using PAT registers?
Mirage: Typed Memory Allocators OS Text and Data Network Buffers Reserved OCaml minor heap OCaml major heap Buddy Allocator dyn_init(type)  dyn_malloc(type, size) dyn_realloc(size)  dyn_free(type) Heap Allocator heap_init(type, pages) heap_extend(type, pages) heap_shrink(type, pages) Page Grant Allocator grant_alloc_page(type) grant_free_page(type)
Mirage: concurrency Xen provides an low-level event interface. Optional interrupts: a perfect fit for co-operative threading! We always know our next timeout (priority queue) So adapted the excellent LWT threading library Block 5s
Mirage: extending the OS signature with timing
Mirage: concurrency using LWT Advantages: Core library is pure OCaml with no magic Excellent camlp4 extension to hide the bind monad. Function type now clearly indicates that it blocks. Open Issues: Creates a lot of runtime closures (lambda lifting, whole program opt?) Threat model: malicious code can now hang whole OS
Mirage: and parallelism? Xen divides up cores into vCPUs, LWT multiplexes on a single core Mirage “process” is a separate OS, communicating via event channels Open Question:  parallelism model (JoCaml, OPIS, explicit futures) vCPU 1 vCPU 2 Mem 1 Mem 2 SHM
Mirage: I/O I/O comes in via Ethernet frames, and “zero copy” parsed via a DSL. We have Ethernet, ARP, ICMP, IPv4, DHCP, TCPv4, HTTP, DNS, SSH all implemented in pure OCaml. Performance in user-space is excellent  (EuroSys 2007),  now benchmarking under Xen  (submission to PLDI 2011) . Zero-copy, bounds optimisation is vital to performance. Ethernet IP TCP Data
Mirage: I/O via MPL packet tcp { source_port: uint16; dest_port: uint16; sequence: uint32; ack_number: uint32; offset: bit[4] value(offset(header_end) / 4); reserved: bit[4] const(0); cwr: bit[1] default(0); ece: bit[1] default(0); urg: bit[1] default(0); ack: bit[1] default(0); psh: bit[1] default(0); rst: bit[1] default(0); syn: bit[1] default(0); fin: bit[1] default(0); window: uint16; checksum: uint16; urgent: uint16 default(0); header_end: label; options: byte[(offset * 4) - offset(header_end)] align(32); data: byte[remaining()]; } OCaml output can both construct  and  parse packets from this DSL. Melange: Towards a ‘Functional’ Internet EuroSys 2007, Madhavapeddy et al.
Mirage: I/O via metaprogramming Seeking a more general solution PADS MetaOCaml BER Requirements: Replace OCaml backend with LLVM parser for data plane (goal is 10GB/s type-safe network I/O). Would like to specify file-systems in this way also.
Mirage: a “multi-scale” operating system type  sockaddr  = | TCP  of ipv4_addr * int | UDP  of ipv4_addr * int module  Flow :  sig type  t val  read: t -> string -> int -> int -> int Lwt.t val  write: t -> string -> int -> int -> int Lwt.t val  connect: sockaddr -> (t -> unit Lwt.t) -> unit Lwt.t val  listen: (sockaddr -> t -> unit Lwt.t) -> sockaddr -> unit Lwt.t end
Mirage: a “multi-scale” operating system Extremely portable signature permits it to adapt to many environments! POSIX/TUNTAP : normal OCaml runtime + Ethernet tap using ML network stack (I/O: Ethernet and higher) POSIX : with normal sockets (I/O: TCP/UDP and higher) Both use high performance  kqueue/epoll  backend. Javascript  using  ocamljs  (Jake Donham) with WebSockets I/O Google AppEngine  using  ocamljava  (Xavier Clerc) with HTTP I/O Android, iMotes  using  ocamlopt  ARM backend.
Mirage: roadmap
Ad

More Related Content

What's hot (20)

Kernel Recipes 2017 - EBPF and XDP - Eric Leblond
Kernel Recipes 2017 - EBPF and XDP - Eric LeblondKernel Recipes 2017 - EBPF and XDP - Eric Leblond
Kernel Recipes 2017 - EBPF and XDP - Eric Leblond
Anne Nicolas
 
Artillery Duel Network
Artillery Duel NetworkArtillery Duel Network
Artillery Duel Network
Leif Bloomquist
 
http server on user-level mTCP stack accelerated by DPDK
http server on user-level mTCP stack accelerated by DPDKhttp server on user-level mTCP stack accelerated by DPDK
http server on user-level mTCP stack accelerated by DPDK
Linaro
 
Kernelvm 201312-dlmopen
Kernelvm 201312-dlmopenKernelvm 201312-dlmopen
Kernelvm 201312-dlmopen
Hajime Tazaki
 
Playing BBR with a userspace network stack
Playing BBR with a userspace network stackPlaying BBR with a userspace network stack
Playing BBR with a userspace network stack
Hajime Tazaki
 
Direct Code Execution @ CoNEXT 2013
Direct Code Execution @ CoNEXT 2013Direct Code Execution @ CoNEXT 2013
Direct Code Execution @ CoNEXT 2013
Hajime Tazaki
 
Network stack personality in Android phone - netdev 2.2
Network stack personality in Android phone - netdev 2.2Network stack personality in Android phone - netdev 2.2
Network stack personality in Android phone - netdev 2.2
Hajime Tazaki
 
An evaluation of LLVM compiler for SVE with fairly complicated loops
An evaluation of LLVM compiler for SVE with fairly complicated loopsAn evaluation of LLVM compiler for SVE with fairly complicated loops
An evaluation of LLVM compiler for SVE with fairly complicated loops
Linaro
 
Lustre Best Practices
Lustre Best Practices Lustre Best Practices
Lustre Best Practices
George Markomanolis
 
LibOS as a regression test framework for Linux networking #netdev1.1
LibOS as a regression test framework for Linux networking #netdev1.1LibOS as a regression test framework for Linux networking #netdev1.1
LibOS as a regression test framework for Linux networking #netdev1.1
Hajime Tazaki
 
Asymmetric Multiprocessing - Kynetics ELC 2018 portland
Asymmetric Multiprocessing - Kynetics ELC 2018 portlandAsymmetric Multiprocessing - Kynetics ELC 2018 portland
Asymmetric Multiprocessing - Kynetics ELC 2018 portland
Nicola La Gloria
 
Heterogeneous multiprocessing on androd and i.mx7
Heterogeneous multiprocessing on androd and i.mx7Heterogeneous multiprocessing on androd and i.mx7
Heterogeneous multiprocessing on androd and i.mx7
Kynetics
 
LinuxCon 2015 Linux Kernel Networking Walkthrough
LinuxCon 2015 Linux Kernel Networking WalkthroughLinuxCon 2015 Linux Kernel Networking Walkthrough
LinuxCon 2015 Linux Kernel Networking Walkthrough
Thomas Graf
 
Cilium - Fast IPv6 Container Networking with BPF and XDP
Cilium - Fast IPv6 Container Networking with BPF and XDPCilium - Fast IPv6 Container Networking with BPF and XDP
Cilium - Fast IPv6 Container Networking with BPF and XDP
Thomas Graf
 
Network Stack in Userspace (NUSE)
Network Stack in Userspace (NUSE)Network Stack in Userspace (NUSE)
Network Stack in Userspace (NUSE)
Hajime Tazaki
 
CETH for XDP [Linux Meetup Santa Clara | July 2016]
CETH for XDP [Linux Meetup Santa Clara | July 2016] CETH for XDP [Linux Meetup Santa Clara | July 2016]
CETH for XDP [Linux Meetup Santa Clara | July 2016]
IO Visor Project
 
Is It Faster to Go with Redpanda Transactions than Without Them?!
Is It Faster to Go with Redpanda Transactions than Without Them?!Is It Faster to Go with Redpanda Transactions than Without Them?!
Is It Faster to Go with Redpanda Transactions than Without Them?!
ScyllaDB
 
Cilium - Bringing the BPF Revolution to Kubernetes Networking and Security
Cilium - Bringing the BPF Revolution to Kubernetes Networking and SecurityCilium - Bringing the BPF Revolution to Kubernetes Networking and Security
Cilium - Bringing the BPF Revolution to Kubernetes Networking and Security
Thomas Graf
 
Evolving Virtual Networking with IO Visor
Evolving Virtual Networking with IO VisorEvolving Virtual Networking with IO Visor
Evolving Virtual Networking with IO Visor
Larry Lang
 
Cilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDPCilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDP
Thomas Graf
 
Kernel Recipes 2017 - EBPF and XDP - Eric Leblond
Kernel Recipes 2017 - EBPF and XDP - Eric LeblondKernel Recipes 2017 - EBPF and XDP - Eric Leblond
Kernel Recipes 2017 - EBPF and XDP - Eric Leblond
Anne Nicolas
 
http server on user-level mTCP stack accelerated by DPDK
http server on user-level mTCP stack accelerated by DPDKhttp server on user-level mTCP stack accelerated by DPDK
http server on user-level mTCP stack accelerated by DPDK
Linaro
 
Kernelvm 201312-dlmopen
Kernelvm 201312-dlmopenKernelvm 201312-dlmopen
Kernelvm 201312-dlmopen
Hajime Tazaki
 
Playing BBR with a userspace network stack
Playing BBR with a userspace network stackPlaying BBR with a userspace network stack
Playing BBR with a userspace network stack
Hajime Tazaki
 
Direct Code Execution @ CoNEXT 2013
Direct Code Execution @ CoNEXT 2013Direct Code Execution @ CoNEXT 2013
Direct Code Execution @ CoNEXT 2013
Hajime Tazaki
 
Network stack personality in Android phone - netdev 2.2
Network stack personality in Android phone - netdev 2.2Network stack personality in Android phone - netdev 2.2
Network stack personality in Android phone - netdev 2.2
Hajime Tazaki
 
An evaluation of LLVM compiler for SVE with fairly complicated loops
An evaluation of LLVM compiler for SVE with fairly complicated loopsAn evaluation of LLVM compiler for SVE with fairly complicated loops
An evaluation of LLVM compiler for SVE with fairly complicated loops
Linaro
 
LibOS as a regression test framework for Linux networking #netdev1.1
LibOS as a regression test framework for Linux networking #netdev1.1LibOS as a regression test framework for Linux networking #netdev1.1
LibOS as a regression test framework for Linux networking #netdev1.1
Hajime Tazaki
 
Asymmetric Multiprocessing - Kynetics ELC 2018 portland
Asymmetric Multiprocessing - Kynetics ELC 2018 portlandAsymmetric Multiprocessing - Kynetics ELC 2018 portland
Asymmetric Multiprocessing - Kynetics ELC 2018 portland
Nicola La Gloria
 
Heterogeneous multiprocessing on androd and i.mx7
Heterogeneous multiprocessing on androd and i.mx7Heterogeneous multiprocessing on androd and i.mx7
Heterogeneous multiprocessing on androd and i.mx7
Kynetics
 
LinuxCon 2015 Linux Kernel Networking Walkthrough
LinuxCon 2015 Linux Kernel Networking WalkthroughLinuxCon 2015 Linux Kernel Networking Walkthrough
LinuxCon 2015 Linux Kernel Networking Walkthrough
Thomas Graf
 
Cilium - Fast IPv6 Container Networking with BPF and XDP
Cilium - Fast IPv6 Container Networking with BPF and XDPCilium - Fast IPv6 Container Networking with BPF and XDP
Cilium - Fast IPv6 Container Networking with BPF and XDP
Thomas Graf
 
Network Stack in Userspace (NUSE)
Network Stack in Userspace (NUSE)Network Stack in Userspace (NUSE)
Network Stack in Userspace (NUSE)
Hajime Tazaki
 
CETH for XDP [Linux Meetup Santa Clara | July 2016]
CETH for XDP [Linux Meetup Santa Clara | July 2016] CETH for XDP [Linux Meetup Santa Clara | July 2016]
CETH for XDP [Linux Meetup Santa Clara | July 2016]
IO Visor Project
 
Is It Faster to Go with Redpanda Transactions than Without Them?!
Is It Faster to Go with Redpanda Transactions than Without Them?!Is It Faster to Go with Redpanda Transactions than Without Them?!
Is It Faster to Go with Redpanda Transactions than Without Them?!
ScyllaDB
 
Cilium - Bringing the BPF Revolution to Kubernetes Networking and Security
Cilium - Bringing the BPF Revolution to Kubernetes Networking and SecurityCilium - Bringing the BPF Revolution to Kubernetes Networking and Security
Cilium - Bringing the BPF Revolution to Kubernetes Networking and Security
Thomas Graf
 
Evolving Virtual Networking with IO Visor
Evolving Virtual Networking with IO VisorEvolving Virtual Networking with IO Visor
Evolving Virtual Networking with IO Visor
Larry Lang
 
Cilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDPCilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDP
Thomas Graf
 

Viewers also liked (20)

Practical ,Transparent Operating System Support For Superpages
Practical ,Transparent Operating System Support For SuperpagesPractical ,Transparent Operating System Support For Superpages
Practical ,Transparent Operating System Support For Superpages
Nadeeshani Hewage
 
Camomile : A Unicode library for OCaml
Camomile : A Unicode library for OCamlCamomile : A Unicode library for OCaml
Camomile : A Unicode library for OCaml
Yamagata Yoriyuki
 
Ocaml
OcamlOcaml
Ocaml
Jackson dos Santos Olveira
 
Using functional programming within an industrial product group: perspectives...
Using functional programming within an industrial product group: perspectives...Using functional programming within an industrial product group: perspectives...
Using functional programming within an industrial product group: perspectives...
Anil Madhavapeddy
 
A taste of Functional Programming
A taste of Functional ProgrammingA taste of Functional Programming
A taste of Functional Programming
Jordan Open Source Association
 
Introduction to functional programming using Ocaml
Introduction to functional programming using OcamlIntroduction to functional programming using Ocaml
Introduction to functional programming using Ocaml
pramode_ce
 
Haskell - Functional Programming
Haskell - Functional ProgrammingHaskell - Functional Programming
Haskell - Functional Programming
Giovane Berny Possebon
 
An Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using HaskellAn Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using Haskell
Michel Rijnders
 
計算数学
計算数学計算数学
計算数学
blackenedgold
 
Introduction to haskell
Introduction to haskellIntroduction to haskell
Introduction to haskell
Luca Molteni
 
OCamlでWebアプリケーションを作るn個の方法
OCamlでWebアプリケーションを作るn個の方法OCamlでWebアプリケーションを作るn個の方法
OCamlでWebアプリケーションを作るn個の方法
Hiroki Mizuno
 
Os Peytonjones
Os PeytonjonesOs Peytonjones
Os Peytonjones
oscon2007
 
OCaml Labs introduction at OCaml Consortium 2012
OCaml Labs introduction at OCaml Consortium 2012OCaml Labs introduction at OCaml Consortium 2012
OCaml Labs introduction at OCaml Consortium 2012
Anil Madhavapeddy
 
Hey! There's OCaml in my Rust!
Hey! There's OCaml in my Rust!Hey! There's OCaml in my Rust!
Hey! There's OCaml in my Rust!
Kel Cecil
 
Real World OCamlを読んでLispと協調してみた
Real World OCamlを読んでLispと協調してみたReal World OCamlを読んでLispと協調してみた
Real World OCamlを読んでLispと協調してみた
blackenedgold
 
関数型プログラミング入門 with OCaml
関数型プログラミング入門 with OCaml関数型プログラミング入門 with OCaml
関数型プログラミング入門 with OCaml
Haruka Oikawa
 
PythonistaがOCamlを実用する方法
PythonistaがOCamlを実用する方法PythonistaがOCamlを実用する方法
PythonistaがOCamlを実用する方法
Yosuke Onoue
 
Why Haskell
Why HaskellWhy Haskell
Why Haskell
Susan Potter
 
Neural Turing Machine Tutorial
Neural Turing Machine TutorialNeural Turing Machine Tutorial
Neural Turing Machine Tutorial
Mark Chang
 
Practical ,Transparent Operating System Support For Superpages
Practical ,Transparent Operating System Support For SuperpagesPractical ,Transparent Operating System Support For Superpages
Practical ,Transparent Operating System Support For Superpages
Nadeeshani Hewage
 
Camomile : A Unicode library for OCaml
Camomile : A Unicode library for OCamlCamomile : A Unicode library for OCaml
Camomile : A Unicode library for OCaml
Yamagata Yoriyuki
 
Using functional programming within an industrial product group: perspectives...
Using functional programming within an industrial product group: perspectives...Using functional programming within an industrial product group: perspectives...
Using functional programming within an industrial product group: perspectives...
Anil Madhavapeddy
 
Introduction to functional programming using Ocaml
Introduction to functional programming using OcamlIntroduction to functional programming using Ocaml
Introduction to functional programming using Ocaml
pramode_ce
 
An Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using HaskellAn Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using Haskell
Michel Rijnders
 
Introduction to haskell
Introduction to haskellIntroduction to haskell
Introduction to haskell
Luca Molteni
 
OCamlでWebアプリケーションを作るn個の方法
OCamlでWebアプリケーションを作るn個の方法OCamlでWebアプリケーションを作るn個の方法
OCamlでWebアプリケーションを作るn個の方法
Hiroki Mizuno
 
Os Peytonjones
Os PeytonjonesOs Peytonjones
Os Peytonjones
oscon2007
 
OCaml Labs introduction at OCaml Consortium 2012
OCaml Labs introduction at OCaml Consortium 2012OCaml Labs introduction at OCaml Consortium 2012
OCaml Labs introduction at OCaml Consortium 2012
Anil Madhavapeddy
 
Hey! There's OCaml in my Rust!
Hey! There's OCaml in my Rust!Hey! There's OCaml in my Rust!
Hey! There's OCaml in my Rust!
Kel Cecil
 
Real World OCamlを読んでLispと協調してみた
Real World OCamlを読んでLispと協調してみたReal World OCamlを読んでLispと協調してみた
Real World OCamlを読んでLispと協調してみた
blackenedgold
 
関数型プログラミング入門 with OCaml
関数型プログラミング入門 with OCaml関数型プログラミング入門 with OCaml
関数型プログラミング入門 with OCaml
Haruka Oikawa
 
PythonistaがOCamlを実用する方法
PythonistaがOCamlを実用する方法PythonistaがOCamlを実用する方法
PythonistaがOCamlを実用する方法
Yosuke Onoue
 
Neural Turing Machine Tutorial
Neural Turing Machine TutorialNeural Turing Machine Tutorial
Neural Turing Machine Tutorial
Mark Chang
 
Ad

Similar to Mirage: ML kernels in the cloud (ML Workshop 2010) (20)

L05 parallel
L05 parallelL05 parallel
L05 parallel
MEPCO Schlenk Engineering College
 
Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?
Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?
Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?
Julien Vermillard
 
Unmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeUnmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/Invoke
Dmitri Nesteruk
 
20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris
imec.archive
 
SNAP MACHINE LEARNING
SNAP MACHINE LEARNINGSNAP MACHINE LEARNING
SNAP MACHINE LEARNING
Ganesan Narayanasamy
 
Distributed Computing
Distributed ComputingDistributed Computing
Distributed Computing
Sudarsun Santhiappan
 
Programmable Exascale Supercomputer
Programmable Exascale SupercomputerProgrammable Exascale Supercomputer
Programmable Exascale Supercomputer
Sagar Dolas
 
Strata Singapore: Gearpump Real time DAG-Processing with Akka at Scale
Strata Singapore: GearpumpReal time DAG-Processing with Akka at ScaleStrata Singapore: GearpumpReal time DAG-Processing with Akka at Scale
Strata Singapore: Gearpump Real time DAG-Processing with Akka at Scale
Sean Zhong
 
Exascale Capabl
Exascale CapablExascale Capabl
Exascale Capabl
Sagar Dolas
 
FEC & File Multicast
FEC & File MulticastFEC & File Multicast
FEC & File Multicast
Yoss Cohen
 
parallel-computation.pdf
parallel-computation.pdfparallel-computation.pdf
parallel-computation.pdf
Jayanti Prasad Ph.D.
 
High Performance Parallel Computing with Clouds and Cloud Technologies
High Performance Parallel Computing with Clouds and Cloud TechnologiesHigh Performance Parallel Computing with Clouds and Cloud Technologies
High Performance Parallel Computing with Clouds and Cloud Technologies
jaliyae
 
ZeroMQ with NodeJS
ZeroMQ with NodeJSZeroMQ with NodeJS
ZeroMQ with NodeJS
Fernando Sanabria
 
Dryad Paper Review and System Analysis
Dryad Paper Review and System AnalysisDryad Paper Review and System Analysis
Dryad Paper Review and System Analysis
JinGui LI
 
Multiple Cores, Multiple Pipes, Multiple Threads – Do we have more Parallelis...
Multiple Cores, Multiple Pipes, Multiple Threads – Do we have more Parallelis...Multiple Cores, Multiple Pipes, Multiple Threads – Do we have more Parallelis...
Multiple Cores, Multiple Pipes, Multiple Threads – Do we have more Parallelis...
Slide_N
 
Open HFT libraries in @Java
Open HFT libraries in @JavaOpen HFT libraries in @Java
Open HFT libraries in @Java
Peter Lawrey
 
2016-09-eclipse-iot-cf-summit
2016-09-eclipse-iot-cf-summit2016-09-eclipse-iot-cf-summit
2016-09-eclipse-iot-cf-summit
Mike Milinkovich
 
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati
Python Ireland
 
Parallel computation
Parallel computationParallel computation
Parallel computation
Jayanti Prasad Ph.D.
 
Porting a Streaming Pipeline from Scala to Rust
Porting a Streaming Pipeline from Scala to RustPorting a Streaming Pipeline from Scala to Rust
Porting a Streaming Pipeline from Scala to Rust
Evan Chan
 
Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?
Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?
Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?
Julien Vermillard
 
Unmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeUnmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/Invoke
Dmitri Nesteruk
 
20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris
imec.archive
 
Programmable Exascale Supercomputer
Programmable Exascale SupercomputerProgrammable Exascale Supercomputer
Programmable Exascale Supercomputer
Sagar Dolas
 
Strata Singapore: Gearpump Real time DAG-Processing with Akka at Scale
Strata Singapore: GearpumpReal time DAG-Processing with Akka at ScaleStrata Singapore: GearpumpReal time DAG-Processing with Akka at Scale
Strata Singapore: Gearpump Real time DAG-Processing with Akka at Scale
Sean Zhong
 
FEC & File Multicast
FEC & File MulticastFEC & File Multicast
FEC & File Multicast
Yoss Cohen
 
High Performance Parallel Computing with Clouds and Cloud Technologies
High Performance Parallel Computing with Clouds and Cloud TechnologiesHigh Performance Parallel Computing with Clouds and Cloud Technologies
High Performance Parallel Computing with Clouds and Cloud Technologies
jaliyae
 
Dryad Paper Review and System Analysis
Dryad Paper Review and System AnalysisDryad Paper Review and System Analysis
Dryad Paper Review and System Analysis
JinGui LI
 
Multiple Cores, Multiple Pipes, Multiple Threads – Do we have more Parallelis...
Multiple Cores, Multiple Pipes, Multiple Threads – Do we have more Parallelis...Multiple Cores, Multiple Pipes, Multiple Threads – Do we have more Parallelis...
Multiple Cores, Multiple Pipes, Multiple Threads – Do we have more Parallelis...
Slide_N
 
Open HFT libraries in @Java
Open HFT libraries in @JavaOpen HFT libraries in @Java
Open HFT libraries in @Java
Peter Lawrey
 
2016-09-eclipse-iot-cf-summit
2016-09-eclipse-iot-cf-summit2016-09-eclipse-iot-cf-summit
2016-09-eclipse-iot-cf-summit
Mike Milinkovich
 
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati
Python Ireland
 
Porting a Streaming Pipeline from Scala to Rust
Porting a Streaming Pipeline from Scala to RustPorting a Streaming Pipeline from Scala to Rust
Porting a Streaming Pipeline from Scala to Rust
Evan Chan
 
Ad

Mirage: ML kernels in the cloud (ML Workshop 2010)

  • 1. Mirage: ML kernels in the cloud Anil Madhavapeddy, University of Cambridge Thomas Gazagnaire, INRIA Computer Laboratory, 15 JJ Thomson Avenue, Cambridge, UK Contributions from Tim Deegan (Citrix), Steven Hand (Cambridge), Steven Smith (Cambridge) , Jon Crowcroft (Cambridge)
  • 2. Motivation: Layers Hardware Processes OS Kernel Threads Application
  • 3. Motivation: Layers Hardware Processes OS Kernel Threads Application Language Runtime
  • 4. Motivation: Layers Hardware Processes OS Kernel Threads Application Hypervisor Language Runtime
  • 5. Motivation: Security Linux Kernel Mar 1994: 176,250 LoC May 2010: 13,320,934 LoC Most core Internet services still written in C / C++
  • 6. Mirage: Approach Construct an OS designed to run on the cloud End-to-end static type safety using OCaml + DSLs More build-time analysis (“whole OS optimisation”) Simple single-threaded core, using the hypervisor to divide up cores
  • 7. Mirage: OS “signature” begins module Console : sig type t val create : unit -> t val write : t -> string -> int -> int -> unit end
  • 8. Mirage: A simple “hello world” Xen runs para-virtualized kernels, that cooperate with the hypervisor. Most code runs unmodified Privileged instructions (page table updates) go via Xen hypercalls $ echo ‘let _ = print_endline “hello Xen world!”’ > hello.ml $ ocamlopt –output-obj –o app.o hello.ml Linked to a “Xen MiniOS” to make a bootable kernel. Boots in 64-bit mode directly, with starting memory all mapped. Is approximately 50-100KB in size.
  • 9. Mirage: 64-bit Xen Memory Layout OS Text and Data Network Buffers Reserved OCaml minor heap OCaml major heap
  • 10. Mirage: Network Buffers OS Text and Data Network Buffers Reserved OCaml minor heap OCaml major heap IP Header TCP Header Transmit packet data IP Header TCP Header Receive packet data
  • 11. Mirage: x86 superpages for OCaml heap OS Text and Data Network Buffers Reserved OCaml minor heap OCaml major heap Reduces TLB pressure significantly. Is_in_heap check is much simpler Improve GC/cache interaction using PAT registers?
  • 12. Mirage: Typed Memory Allocators OS Text and Data Network Buffers Reserved OCaml minor heap OCaml major heap Buddy Allocator dyn_init(type) dyn_malloc(type, size) dyn_realloc(size) dyn_free(type) Heap Allocator heap_init(type, pages) heap_extend(type, pages) heap_shrink(type, pages) Page Grant Allocator grant_alloc_page(type) grant_free_page(type)
  • 13. Mirage: concurrency Xen provides an low-level event interface. Optional interrupts: a perfect fit for co-operative threading! We always know our next timeout (priority queue) So adapted the excellent LWT threading library Block 5s
  • 14. Mirage: extending the OS signature with timing
  • 15. Mirage: concurrency using LWT Advantages: Core library is pure OCaml with no magic Excellent camlp4 extension to hide the bind monad. Function type now clearly indicates that it blocks. Open Issues: Creates a lot of runtime closures (lambda lifting, whole program opt?) Threat model: malicious code can now hang whole OS
  • 16. Mirage: and parallelism? Xen divides up cores into vCPUs, LWT multiplexes on a single core Mirage “process” is a separate OS, communicating via event channels Open Question: parallelism model (JoCaml, OPIS, explicit futures) vCPU 1 vCPU 2 Mem 1 Mem 2 SHM
  • 17. Mirage: I/O I/O comes in via Ethernet frames, and “zero copy” parsed via a DSL. We have Ethernet, ARP, ICMP, IPv4, DHCP, TCPv4, HTTP, DNS, SSH all implemented in pure OCaml. Performance in user-space is excellent (EuroSys 2007), now benchmarking under Xen (submission to PLDI 2011) . Zero-copy, bounds optimisation is vital to performance. Ethernet IP TCP Data
  • 18. Mirage: I/O via MPL packet tcp { source_port: uint16; dest_port: uint16; sequence: uint32; ack_number: uint32; offset: bit[4] value(offset(header_end) / 4); reserved: bit[4] const(0); cwr: bit[1] default(0); ece: bit[1] default(0); urg: bit[1] default(0); ack: bit[1] default(0); psh: bit[1] default(0); rst: bit[1] default(0); syn: bit[1] default(0); fin: bit[1] default(0); window: uint16; checksum: uint16; urgent: uint16 default(0); header_end: label; options: byte[(offset * 4) - offset(header_end)] align(32); data: byte[remaining()]; } OCaml output can both construct and parse packets from this DSL. Melange: Towards a ‘Functional’ Internet EuroSys 2007, Madhavapeddy et al.
  • 19. Mirage: I/O via metaprogramming Seeking a more general solution PADS MetaOCaml BER Requirements: Replace OCaml backend with LLVM parser for data plane (goal is 10GB/s type-safe network I/O). Would like to specify file-systems in this way also.
  • 20. Mirage: a “multi-scale” operating system type sockaddr = | TCP of ipv4_addr * int | UDP of ipv4_addr * int module Flow : sig type t val read: t -> string -> int -> int -> int Lwt.t val write: t -> string -> int -> int -> int Lwt.t val connect: sockaddr -> (t -> unit Lwt.t) -> unit Lwt.t val listen: (sockaddr -> t -> unit Lwt.t) -> sockaddr -> unit Lwt.t end
  • 21. Mirage: a “multi-scale” operating system Extremely portable signature permits it to adapt to many environments! POSIX/TUNTAP : normal OCaml runtime + Ethernet tap using ML network stack (I/O: Ethernet and higher) POSIX : with normal sockets (I/O: TCP/UDP and higher) Both use high performance kqueue/epoll backend. Javascript using ocamljs (Jake Donham) with WebSockets I/O Google AppEngine using ocamljava (Xavier Clerc) with HTTP I/O Android, iMotes using ocamlopt ARM backend.
  翻译: