30
Darjeeling, a Feature-Rich VM for the Resource Poor Niels Brouwers, Peter Corke, and Koen Langendoen

Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Darjeeling, a Feature-Rich VM for the Resource Poor

Niels Brouwers, Peter Corke, and Koen Langendoen

Page 2: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Introduction

Resource

Constrained

Modular,

Concurrent

WSN

Robust

Heterog

eneo

us

11/11/2009 2

Page 3: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Introduction

• Operating systems

• Contiki, TinyOS

• Native code (C/NesC)

• Efficient concurrency

Resource

Constrained

Modular,

Concurrent

• Efficient concurrency

• Virtual Machine

• Interpreted (Java)

• Robust, feature-rich

• Time/space overhead

WSN

Robust

Heterog

eneo

us

11/11/2009 3

Page 4: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Introduction

• We would like a VM that

• Enables a high-level language (Java)

• With an acceptable overhead

• Memory efficiency highest priority

• RAM

• Program flash

11/11/2009 4

Page 5: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Previous work

Feature rich Resource efficient Open source

Sentilla yes yes no

TinyVM (LeJOS) no yes yes

NanoVM no yes yes

Taka Tuka yes yes no

11/11/2009 5

Taka Tuka yes yes no

VM* yes yes no

MoteRunner yes yes no

Java Card no yes no

Squawk (Sun Spot) yes no yes

Page 6: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Darjeeling

• Feature rich

• Threading, synchronisation

• Compacting garbage collection

• Resource efficient

• Can run on devices with 2-10k RAM, ~64k flash

• But, no support for 64-bit or floating point, reflection

• Portable

• Contiki, TinyOS, FOS

• Open source

11/11/2009 6

Page 7: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Infuser tool

• Performs static linking

• Byte code post-processing

• Reduces code footprint by removing entity names

11/11/2009 7

Page 8: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Linked stack architecture

• Light-weight threads

• Stack frames are heap objects

• On demand stack space allocation

Stack Frame

Stack Frame

allocation

• Min memory usage: ~45 bytes Stack Frame

Thread

11/11/2009 8

Page 9: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

16-bit architecture

• Custom instructions for 16-bit data types

• Saves stack space (operand stack, local variables)

• Arithmetic optimisation

11/11/2009 9

Page 10: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Double-ended stack

• Precise, compacting garbage collector

• Compaction requires identifying references on the operand stack

• Darjeeling uses two logical stacks

11/11/2009 10

Page 11: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Performance: Java vs C

30.4

77.781.5

54.47

113.2

40

60

80

100

120

Java/C30.4

0

20

40

MD5 Bubble sort

(32-bit)

Bubble sort

(16-bit)

8x8 vector

convolution

(32-bit)

8x8 vector

convolution

(16-bit)

Java/C

11/11/2009 11

Page 12: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Memory consumption: Stack Space

1819.4

21.7

15.114 14.3

17.3

12.115

20

25

32-bit

0

5

10

Blink CTP Test suite Base library

16-bit

11/11/2009 12

Page 13: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Springbrook

• Rewrite of a real-world application

• CTP implementation in Java

• 22 classes, ~1200 sloc

• <8kB in program flash• <8kB in program flash

• <2kB RAM

• 5 threads

11/11/2009 13

Page 14: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Springbrook power consumption

transmission

transmission

• CPU on-timeincreased by 50%

Time

PowerConsumption

cput

cpu

t

11/11/2009 14

Page 15: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Supported platforms

Tnode Tmote Sky Fleck3/Fleck3B

MCU Atmega128 MSP430 Atmega128(1)

Architecture 8-bit 16-bit 8-bit

RAM 4kB 10kB 4/8kBRAM 4kB 10kB 4/8kB

Radio CC1000 CC2420 nRF905

OS TinyOS Contiki FOS

Concurrency events protothreads threads

11/11/2009 15

Page 16: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Conclusions

• Darjeeling is an embedded VM

• Feature rich

• Memory efficient

• Open source• Open source

• Suitable for real-world applications

• Performance overhead acceptable for many applications

11/11/2009 16

Page 17: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Future work

• CLDC 1.0 compliance

• Support for the long data type

• Reflection

• Over-the-air loading• Over-the-air loading

• Generational garbage collector ?

• Operating system independent ?

http://darjeeling.sf.net

11/11/2009 17

Page 18: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Questions?

11/11/2009 18

Page 19: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Code size reduction

27,349

42,834

19,02320000

25000

30000

35000

40000

45000

Java .class

856

13,795

146

7,889

19,023

3,591

0

5000

10000

15000

20000

Blink (-83%) CTP (-71%) Test Suite (-55%) Base library (-75%)

Darjeeling .di

11/11/2009 19

Page 20: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Micro benchmarks: performance

Test C Java Java/C Instr./s

MD5 13.1s 399.7s 30.4 52,294

Bubble sort (32-bit) 0.3s 23.3s 77.7 60,618

Bubble sort (16-bit) 0.2s 19.3 81.5 71,526

8x8 vector convolution (32-bit) 9.1s 496.7s 54.47 65,454

8x8 vector convolution (16-bit) 4.6s 520.9s 113.2 71,512

11/11/2009 20

Page 21: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Micro benchmarks: code size

jar di reduction

Blink 856 146 83%Blink 856 146 83%

CTP 27,349 7,889 71%

Test Suite 42,834 19,023 55%

Base library 13,795 3,591 75%

11/11/2009 21

Page 22: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Micro benchmarks: stack size (1)

JVM DVM reduction

Blink 18 14 22%Blink 18 14 22%

CTP 19.4 14.3 27%

Test suite 21.7 17.3 20%

Base library 15.1 12.1 20%

11/11/2009 22

Page 23: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Micro benchmarks: stack size (2)

JVM DVM reduction

Blink 10 6 40%Blink 10 6 40%

CTP 11.4 6.3 45%

Test suite 13.7 9.3 32%

Base library 7.1 4.1 42%

11/11/2009 23

Page 24: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Portability

Tnode Tmote Sky Fleck3/Fleck3B

MCU Atmega128 MSP430 Atmega128(1)

Architecture 8-bit 16-bit 8-bitArchitecture 8-bit 16-bit 8-bit

RAM 4kB 10kB 4/8kB

Radio CC1000 CC2420 nRF905

OS TinyOS Contiki FOS

Concurrency events protothreads threads

11/11/2009 24

Page 25: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Portability: code complexity

Tnode Tmote Sky Fleck3/Fleck3B

Main 225 359 86

Radio 69 92 69

Sensors 184 157 110

Total 478 608 265

11/11/2009 25

Page 26: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Linked stack architecture

• Test runs three threads, started at the same time

• Each thread performs a binary tree test three times, with a 10 millisecond sleep in between

• Let the heap manager log the total stack size of each • Let the heap manager log the total stack size of each thread as the program executes

• Simulates periodic work, common in WSN

11/11/2009 26

Page 27: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Linked stack architecture

Peak memory

consumption

at 1335 bytes.

11/11/2009 27

Page 28: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Linked stack architecture

• Synchronize threads

• Only one thread may perform work at a time

• Work is serialised automatically

11/11/2009 28

Page 29: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Linked stack architecture

Peak memory

consumption

down to 535

bytes.

11/11/2009 29

Page 30: Darjeeling, a Feature-Rich VM for the Resource Poor · • Program flash 11/11/2009 4. Previous work Feature rich Resource efficient Open source Sentilla yes yes no TinyVM (LeJOS)

Memory consumption: Stack Space

9.3

4.1

11.4

13.7

7.1

Test suite

Base library

16-bit

6

6.3

10

11.4

0 2 4 6 8 10 12 14 16

Blink

CTP 32-bit

11/11/2009 30