Unikraft: Fast, Specialized Unikernels the Easy Way

Page created by Cody Riley
 
CONTINUE READING
Unikraft: Fast, Specialized Unikernels the Easy Way
Unikraft: Fast, Specialized Unikernels the Easy Way
                    Simon Kuenzer     Vlad-Andrei Bădoiu     Hugo Lefeuvre
                  Sharan Santhanam      Alexander Jung       Gaulthier Gain
                     Cyril Soldani        Costin Lupu      Stefan Teodorescu
                    Costi Răducanu       Cristian Banu       Laurent Mathy
                  Răzvan Deaconescu      Costin Raiciu      Felipe Huici

Eurosys 2021, April 26th-28th
Unikraft: Fast, Specialized Unikernels the Easy Way
Specialization = High Performance

     software        hardware
Unikraft: Fast, Specialized Unikernels the Easy Way
Unikernels = Specialized Virtual Machines
             • Easy to build and run
       GOALS • Easy or no app porting
             • Great performance
Unikraft: Fast, Specialized Unikernels the Easy Way
Design Principles

1. Fully modular kernel

2. Provide high performance specialized APIs
Unikraft: Fast, Specialized Unikernels the Easy Way
Design Principles

1. Fully modular kernel

2. Provide high performance specialized APIs
Unikraft: Fast, Specialized Unikernels the Easy Way
Why not Linux?
                                             207

                                  13         111
                                                            15
                                  164                                                            30
                                                   151              13

                      311
                                                   101                                           6
                      551
                                        24
                                        4                   15           locking          117
                                                                                           2
            34                                2    119
                                                            5
                                                                                    7
                                                                    91
                                   1
                                                                                                      sched 36
Unikra-   is built from scratch to be fully modular
                                                                    39
           ipc   3
                 5
                                  720
                                                            8        4
                                                                           60
                                                                                    2

     time
       77
                   net
                             1
                                                                           16
                                                                                                             53

  fs   90                    2          27                                         465
                                                                                                 8
                      11
                            107         17
                                                   124
                                                                                    2                             mm
                 23
                      110         irq   1    10
                                                    7
                                                                    11             19            25

                                   3                     security           6
                                                                                          122
                                                                                                        36

                 67
                            14
                                             46             10                           block          28
                                                                           22
                            226
                                              2
                                                            37              6
                                        68
                                        95         277
                                                   213
Unikraft: Fast, Specialized Unikernels the Easy Way
With Unikraft
                      Hello World 1      posix-layer
                          boot       3
                                           nolibc
                        ukboot       1    argparse
                                     6
                                     1   ukargparse

                                     1
                                 mm
                                     3
                      ukallocbuddy        ukalloc

                         20

                               security             1
                     9

        fs      1               nginx            10
                                                 39
                                                        posix-layer 61 mm
                     1 sched 2
                             3
           1
             locking     2
                                 net                2
                                                    7
                                                           time
                             1
                                                            ipc
Unikraft: Fast, Specialized Unikernels the Easy Way
Doing it with existing unikernels?

            (1) Require significant expert work to build

     Unikraft(2)is They
                   builtarefrom
                             oftenscratch (with
                                   non-POSIX    borrowing)
                                             compliant

              (3) The (uni)kernels are still monolithic
Unikraft: Fast, Specialized Unikernels the Easy Way
Design Principles

1. Fully modular kernel

2. Provide high performance specialized APIs
Unikraft: Fast, Specialized Unikernels the Easy Way
Specialized API Example
        application

           glibc

       POSIX sockets

          network
           stack
                       UDP

       High-perf API
PLATFORM                                  OS PRIMITIVES                   POSIX COMPAT                                LIBC
  LAYER                                       LAYER                           LAYER                                  LAYER

      KVM                                      NW STACKS

                                                     lwip

                                                     mtcp

   clock
                             uknetdev
                                                                       posix-socket

  virtio-net
                                                                                      posix-fdtab

                                                   FILESYSTEMS

                                                     9pfs
                                                                                                      syscall-shim

                                                     ramfs
                                                                       vfscore

              virtio-block
                             ukblockdev
                                                     ext4

  memregion
                                                                                      posix-process
                                                                                                                      musl

                                SCHEDULERS
     XEN
                                    ukpreempt
                                                                                       …

                                                             uksched

                                          ukcoop
                                                                                                                               application

   clock
  netfront

                                          BOOTERS
                                                                                      pthread
                                                                                                                      newlib

                                  dynamicboot
                                                             ukboot

                                          ukcoop
              blockfront
  memregion

                               MEM . ALLOC.
                                    buddyalloc
                                      tinyualloc
      …

                                            tlsf
                                                             ukalloc

                                          mimalloc
                                           oscar
• Easy to build and run
GOALS • Easy or no app porting
      • Great performance
• Easy to build and run
GOALS • Easy or no app porting
      • Great performance
Binary Compatibility?
Auto-porting from Source

                     statically                           link

                                                                          (POSIX)

                                                                                     syscalls

                                                                                                Unikraft
                                                                           syscall
                                                (Unikraft build system)

                                                                                                kernel
                     compile

                                                                            musl
App native build                  .obj and .a

                                                                            shim
    system                           files
Compile Time
What about syscall support?
Syscall Support

                                               Eurosys 2016

146 syscalls currently supported   Linux: ~350 syscalls
System call support
                                   100%

                                    10%
                                    20%
                                    30%
                                    40%
                                    50%
                                    60%
                                    70%
                                    80%
                                    90%

                                     0%
                           apache
                               avahi
                              bind9
                          dovecot
                                exim
                            firebird
                          groonga
                                 h2o
                             influxb
                                knot
                                        Supported syscalls

                           lighttpd
                          mariadb
                      memcached
                         mongodb
                                        If top 5 syscalls implemented
                                        If top 10 syscalls implemented

                        mongoose
                          mongrel
                                        If remaining syscalls implemented

                                mutt
                              mysql
                             nghttp
                                                                                  Syscall Support

                               nginx
                         nullmailer
146 syscalls currently supported

                openlitespeedweb
                       opensmtpd
                        postgresql
                               redis
                                                                            Top 30 Debian Popcon Apps

                             sqlite3
                              tntnet
                              webfs
                            weborf
                          whitedb
If all Else Fails – Manual Porting
What Unikraft Supports (sample)

        (ongoing)   (ongoing)
• Easy to build and run
GOALS • Easy or no app por6ng
      • Great performance
Does autoporting sacrifice performance?
SQLite: Manual vs. Auto Port
                               1.153                                  1.121
                                             1.083       1.065
        Time (seconds)

                         1

     AutoporAng doesn’t negaAvely affect performance

                         0
                                Linux        newlib       musl         musl
                              (native)
                               (baseline)   (native)
                                             (manual)   (native)
                                                         (manual)   (external)
                                                                     (autoport)

time for 60K insertions
Transparent Benefits –
Boot, Memory, Size,
Throughput
               cc
Image size
                                                             10MB

                                  2MB
                                        4MB
                                               6MB
                                                     8MB

                          0B

Unik
                                213.0KB

     ra
                                   1.6MB

       ft
                                    1.8MB
                                   1.6MB

          Herm
              i
                                   1.3MB

               t
                                                            hello
                                                            nginx

                ux
                                    1.5MB
                                      2.1MB

                   Lin
                      ux
                                16.4KB
                         User      1.2MB
                                     1.8MB
       Lu                          1.1MB
                                    1.7MB
         p
                                                            redis

          i
                                                            sqlite

           n

                                         3.6MB
            e

                                      2.6MB
                                        3.2MB
       M
        irage

                                         3.3MB

                                              4.5MB
            OS

                                                5.4MB
              v

                                                           8.1MB
                                                5.4MB
  Ru
    m
     p

                                        2.8MB
      r

                                              5.4MB
        un

                                          3.7MB
                                          3.9MB
                                                                     Image Sizes vs. other Projects
Unikraft Boot Times
                                                                               VMM

                                                42.7ms
                              38.4ms
Total Boot Time (ms)
                       102                                                     Unikraft Guest

                                                             9.1ms

                                                                       3.1ms

                                                                                          3.1ms
                       101

                       100

                        0

                               M
                                U                IC)          M
                                                               U
                                                                 )     lo5
                                                                                           ker
                             QE               (1
                                                N           E
                                                          Q oV  M    So                 rac
                                                                                      c
                                         M
                                          U                icr                    ri e
                                                                                 F
                                       QE                (M
Minimum Memory Requirement

                               16MB
                                      24MB
                                              32MB
                                                     40MB
                                                            48MB

                        8MB

                 0B

   Un
     ik
                       2MB

        ra
                        5MB

          ft
                         7MB
                        4MB

    Doc
                         6MB

       k
                                                       hello

                         7MB
                                                       nginx

        er
                         7MB

 R
                         6MB

  um
    p
                          8MB

     r
                            12MB

       un
                            13MB
                           10MB

          Her m
               i
                              11MB
                                                       redis

                t
                                                       sqlite

                 ux

                               13MB
                              10MB
    Lu
      p

                                      20MB
       in

                                      21MB
         e

                                      21MB
                                      21MB
                                        24MB
        OS

                                         26MB
          v

                                                       40MB
                                             26MB
M
 ic

                                              29MB
   ro
     u

                                              29MB
      x

                                              30MB
 Lin VM
                                                                   Minimum Memory Requirements

                                              29MB
M               Average Throughput (x1000 req/s)
 ira

                              100
                                     150
                                            200
                                                  250
                                                        300
                                                              350

    ge

                         50

                     0
            So
               lo
       Li        5       25.9
          nu
             x
               FC
     Lu                       60.1
         pi
           ne
    Li         FC
       nu                      71.6
          x
             KV
   R             M
     um                             104.5
D         p
 oc          KV
     ke          M                         152.6
         rN
  Li         at
               ive
    nu
        x                                  160.3
           N
  Lu         at
               ive
      pi
        ne                                   175.6
                                                                    nginx Throughput

             KV
     O           M                            189.0
        Sv
U            KV
   ni
     kr          M                                  232.7
        af
            tK
               VM
                                                          291.8
Redis Performance

  Aver. Throughput (Million req/s)

                                                                                                                                2.68
                                                     GET                      SET

                                                                                                                      2.44
                                     3.0

                                                                                                                             2.26
                                                                                                                   2.01
                                                                                                            1.98
                                                                                                  1.95
                                     2.5

                                                                                         1.82

                                                                                                1.68

                                                                                                         1.54
                                                                                1.54

                                                                                       1.52
                                                                       1.33
                                     2.0

                                                                              1.31
                                                             1.26

                                                                    1.17
                                                    1.14
                                                   1.06

                                                           0.93
                                     1.5
                                            0.37

                                     1.0
                                           0.24

                                     0.5

                                     0.0
               ve FC     C VM VM VM                   iv e       M     i ve       M
             y          F                           at        V      at          V
           uH inux pine    p
                             K
                                  ux
                                     K
                                           e
                                             K
                                                 r N       v
                                                             K      N        ft K
     ti u
         x      L   u    um     in      pin    ke       O S      ux
                                                                         k ra
                  L    R       L       u      c                in     n i
  r m                                L      Do               L      U
He
Boot Times - Different Allocators
                       3.5                           virtio        rootfs       misc

                                 3.07
                                                     vfscore       pthreads     lwip
                       3.0                           ukbus         plat         alloc
Total Boot Time (ms)

                       2.5

                       2.0

                       1.5

                                            0.94

                                                                     0.87
                       1.0

                                                                               0.51
                                                          0.49
                       0.5

                       0.0
                             Binary buddy Mimalloc     Bootalloc   tinyalloc   TLSF
Redis Throughput
Aver. Throughput (Million req/s)
                                                  Different Allocators

                                         2.72
                                   3.0                                       GET           SET

                                                       2.47

                                                                      2.32
                                                2.22
                                   2.5

                                                              1.97

                                                                             1.89
                                   2.0

                                   1.5

                                                                                    1.01

                                                                                           0.78
                                   1.0

                                   0.5

                                   0.0
                                         Mimalloc        TLSF        Binary buddy    tinyalloc
Specialized APIs
Specializa)on Benefits –
 Filesystem Performance
Filesystem Specialization – SHFS
                                      Unikraft                                        Linux

                                FILE EXISTS             NO FILE

                                                                                                    (1126ns)
                                                                                                      4054
                5000

                                                                            (910ns)
                                                                             3277
Average # TSC

                4000

                                                                                          (735ns)
                                                                                           2647
                                                     (617ns)
                                                      2219

                                                                  (547ns)
                3000

                                                                   1968
                                           (455ns)
                                            1637
                2000
                       (86ns)

                                 (81ns)
                        308

                                  291

                1000

                   0
                          SHFS                   VFS                  VFS                      VFS
                                                                   (No mitig.)
High performance POSIX unikernels are now a reality!

Info: https://unikraft.org/
Code: https://github.com/unikraft
Reproduce: https://github.com/unikraft/eurosys21-artifacts
You can also read