Top Banner
1 Dates Melbourne: December 5-6 Brisbane: December 9-10 Sydney: December 12-13 Early bird tickets on sale early June! Don’t forget YOW! 2012 presentations, videos, interviews and podcasts all available online YOW! 2013 YOW! 2013 Ini-al Speakers Jeff Hawkins Co-Founder of Palm, author of “On Intelligence”, artificial intelligence & the brain Confirmed Keynotes
18

YOW! JVM Demystified Dave Thomas

Jul 17, 2016

Download

Documents

mcdavid0

YOW! JVM Demystified Dave Thomas
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: YOW! JVM Demystified Dave Thomas

1

•  Dates – Melbourne: December 5-6 – Brisbane: December 9-10 – Sydney: December 12-13

•  Early bird tickets on sale early June! •  Don’t forget YOW! 2012

presentations, videos, interviews and podcasts all available online

YOW!  2013  

YOW!  2013  Ini-al  Speakers  

Jeff Hawkins Co-Founder of Palm, author of “On Intelligence”,

artificial intelligence & the brain

Confirmed Keynotes

Page 2: YOW! JVM Demystified Dave Thomas

2

YOW!  2013  Ini-al  Speakers  

Scott Hanselman Microsoft Principal Project Manager, author of

numerous ASP .NET books, host of Hanselminutes and other podcasts

Confirmed Keynotes

YOW!  2013  Ini-al  Speakers  

Philip Wadler Computer Scientist known for his contributions to

programming languages and type theory

Confirmed Keynotes

Page 3: YOW! JVM Demystified Dave Thomas

3

YOW!  2013  Ini-al  Speakers  

§ Kevlin Henney Developer Best Practices

§ Doug Crockford JavaScript guru, inventor of JSON

§ Daniel Spiewak Scala fanatic, functional devotee

§ Scott Murray D3.js

§ Mike Dixon Big Data, google.gov

§ Jesper Richter-Reichhelm Scalability of game servers at Wooga

§ Elizabeth Keogh Agile expert, human psychology

§ Aaron Bedra Application Security at Braintree

•  Ben Christensen RxJava, Netflix

§ Phillipe Kruchten Architecture, creator 4+1 model

§ Jim Webber NoSQL, Neo4J, REST

§ Michael Nygard DevOps, author of “Release It”

§ Steve Vinoski Erlang, IEEE Internet Computing

§ Trish Gee MongoDB, Java high performance

§ Eric Evans Domain Driven Design

§ Charles Nutter Jruby

§ Hadi Harri JetBrains, Kotlin

© 2013 Bedarra Research Labs. All rights reserved.

JVM  Demys*fied  –  A  Tour  of  the    LVM  Engine  Room  

 Dave  Thomas  www.davethomas.net  

¡  Bedarra  Research  Labs  ¡  YOW!  Conferences    

¡  Carleton  University  ¡  Queensland  University  of  Technology  ¡    

Page 4: YOW! JVM Demystified Dave Thomas

4

Outline  

Hardware  Machines  

Virtual  Machines  

Essence  of  a  Language  Virtual  Machine  

700+  languages  in  7  minutes  

LVM  Engineering  Design  Choices  

LVM  Speed  and  Space    

Musings  on  Next  Genera*on  VMs    

Discussion  

 

 

© 2013 Bedarra Research Labs. All rights reserved.

© 2013 Bedarra Research Labs. All rights reserved.

Real  Machines    

Page 5: YOW! JVM Demystified Dave Thomas

5

Modern  Hardware  (Intel  Sandy  Bridge  EP*)  

C 1 C n C 1 C n Registers/Buffers <1ns

L1 L1 L1 L1 ~4 cycles ~1ns

L2 L2 L2 L2 ~12 cycles ~3ns

L3 L3 ~40 cycles ~15ns

~60 cycles ~20ns (dirty hit)

~65ns

DRAM

QPI ~40ns MC MC

DRAM

DRAM

DRAM

DRAM

DRAM

DRAM

DRAM

...

...

...

...

...

...

QPI QPI PCI-e 3 PCI-e 3

40X IO

40X IO

* Assumption: 3GHz Processor (c) Martin Thompson 2012 - 2013

Page 6: YOW! JVM Demystified Dave Thomas

6

© 2013 Bedarra Research Labs. All rights reserved.

Real  Hardware  a  Moving  Target  

Real  HW  Virtual  Machines  (Virtualiza*on)  

§  SoZware  which  seeks  to  efficiently  emulate  a  specific  real  machine    

§  VM360,  VMWare,  XEN,  VirtualBox  ,  Azure,  Parallels  …  

§  Simplify  deployment;  isolate  users;    share  resources  

 

© 2013 Bedarra Research Labs. All rights reserved.

Page 7: YOW! JVM Demystified Dave Thomas

7

Real  Language  Machines  

Hardware  which  seeks  to  directly  support  a  high  level  language  features  -­‐Tags,  Write  Barriers,  Contexts  ..  

ALGOL  Burroughs  6700,  APL  IBM  5100,  Lisp  Symbolics,  XPARC  Dorado,  PICK,  Prolog,  ADA  Intel  432,  Smalltalk  SOAR,  Java  Azul;  …  

 

© 2013 Bedarra Research Labs. All rights reserved.

Virtual    HW  Machines  

§  SoZware  which  seeks  to  efficiently  emulate  an  ideal  abstract  HW  machine  on  different  real  HW  plajorms  

§  IBM  AS/400,  Calusa  B-­‐RISC,  Google  Portable  Na*ve  Run*me  

 

© 2013 Bedarra Research Labs. All rights reserved.

Page 8: YOW! JVM Demystified Dave Thomas

8

© 2013 Bedarra Research Labs. All rights reserved.

Language  Virtual  Machines  (LVM)  

§  SoZware  which  seeks  to  efficiently  implement  a  programming  language  by  emula*ng  a  language  specific  machine  representa*on  such  as  byte  codes  

§  Pascal  P-­‐Code,  SECD,  LVMs  for  Smalltalk,  Java,  CLR,  Perl,  R,  MalLab,  Erlang,  PHP,  Python,  Ruby,  JavaScript,  Dart  …  

 Hardware  Machines      Language  Virtual  Machines  

 Instruc*on  Set      Abstract  instruc*on  set  (AST,          byte  Codes…)  

 Registers  and  Memory      Stack  +  Memory    

 Fetch  –  Decode  –  Execute    Read  –  Eval  –  Print  Loop  (REPL)  

         Storage  Manager  (GC)  

   

© 2013 Bedarra Research Labs. All rights reserved.

Why  have  LVMS?  –  Just  Compile  It!  

•  Compilers  and  Interpreters  Easy  

•  Security    

•  Execu*on  Time  Op*miza*on  

 

 

 

© 2013 Bedarra Research Labs. All rights reserved.

Page 9: YOW! JVM Demystified Dave Thomas

9

© 2013 Bedarra Research Labs. All rights reserved.

400+  Languages  in  4  minutes  

© 2013 Bedarra Research Labs. All rights reserved.

400+  Languages  in  4  minutes  

The  READ  –  EVAL  –  PRINT    LOOP  aka  “REPL”  

Meta  circular  Interpreters  and  the  meaning  of  Life    

The  Contour  Model  of  Block  Structure  Processes  

Page 10: YOW! JVM Demystified Dave Thomas

10

© 2013 Bedarra Research Labs. All rights reserved.

400+  Languages  in  4  minutes  

The  READ  –  EVAL  –  PRINT    LOOP  aka  “REPL”  

What  are  the  key  execu*on  *me    differences  between  these  languages?  

 

   

© 2013 Bedarra Research Labs. All rights reserved.

VM  Engineering  Design  Space  

 

 

 

 

 

 

Page 11: YOW! JVM Demystified Dave Thomas

11

© 2013 Bedarra Research Labs. All rights reserved.

VM  Instruc*on  Sets  

   

 

 

   

 

 

 

 

 

Essen*al  or  Exo*c?  

© 2013 Bedarra Research Labs. All rights reserved.

Page 12: YOW! JVM Demystified Dave Thomas

12

© 2013 Bedarra Research Labs. All rights reserved.

Boxing  and  Tags  

Boxed  Languages  

§  Na*ve  machine  types    

§  No  fully  polymorphic  collec*ons  without  boxing  

Tagged  Languages  

§  Fully  Polymorphic  collec*ons  

§  Tag  bits  take    space  and  need  checking  (SOAR  =>  Sparc)  

 

 

 

 

VM  Implementa*on    

Interpreter,  Compiler,  Mixed,  Mul*ple  …  

Low  Level  Language  –  C/C++  ,  C  

Implement  the  LVM  in  a  subset  of  the  LVM  language  (self  hos*ng)  •  Use  an  exis*ng  implementa*on  of  language  or  a  similar  one  •  Use  a  your  new  language  and  manually  translate  implementa*on  to  low  

level  •  Implement  the  reflec*ve  tower  e.g.  3-­‐Lisp  

Base  Types  -­‐    implemented  inside  the  LVM  e.g.  Integer,  Object…  

§  How  easy  should  it  be  for  others?  §  Opera*ons,  New  types  (CLR  Value  Types),  New  representa*ons  §  Access  to  HW  

Core  Libraries  •  Inside  LVM  or  Open  in  Language?    

©2003 Bedarra Research Labs. All rights reserved.

Page 13: YOW! JVM Demystified Dave Thomas

13

© 2013 Bedarra Research Labs. All rights reserved.

Implementa*on  -­‐  Core  Libraries  

Implement  in  the  language  or  in  the  LVM?  

Library  in  Language      Implement  in  LVM      

 

 

 

   

 

 

 

 

© 2013 Bedarra Research Labs. All rights reserved.

Method/Func*on  Dispatch  

§  Tables,  Dynamic  Lookup/  Dynamic  Transla*on    

§  Polymorphic  Inline  Cache  (PIC)  

§  Run*me  Type  Feedback  (Self-­‐>  Strongtalk-­‐>  Hotspot)  

§  Profile  Guided  Inlining    (also  called  tracing  JIT)  

§  Whole  Program  Compila*on  –  Smart  Eiffel,    Ahead-­‐Of-­‐Time  (AOT)  JIT  IBM,  Excelsior  Jet  …  

 

 

 

 

Page 14: YOW! JVM Demystified Dave Thomas

14

© 2013 Bedarra Research Labs. All rights reserved.

Garbage  Collec*on  

 

     

 

 

© 2013 Bedarra Research Labs. All rights reserved.

Concurrency  Model  

•  Actors  versus  Data  Parallel  §  Immutable  Data  Structures  

§  Low  level  Threads  and  Locks  (semaphores)  

 Na*ve  OS  Threads  

 versus  Green  Threads  

 

 

 

 

Page 15: YOW! JVM Demystified Dave Thomas

15

© 2013 Bedarra Research Labs. All rights reserved.

Applica*on  Performance  versus  Benchmark  Lies  

Very  Few  Know  Where  the  Time  and  Space  Really  Goes!  

Micro  benchmarks  such  as  SPEC,  Sun  Spider,  Octane  

§  Measure  specific  language  features  

§  Seldom  a  predictor  for  applica*on  performance  

           1000000 timesRepeat[12 fibonacci]

Applica*on  Performance  

§  Dominated  by  macro  behavior  of  applica*on  

§  Time  spent  in  OS  or  DB  

§  Time  spent  in  Framework/Library  

§  Applica*on  or  Framework  races  GC  

§  Applica*on  or  Framework  thrashes  cache  

 

 

 

 

 

© 2013 Bedarra Research Labs. All rights reserved.

Your  Mileage  will  Vary!  

Client  Centric  Applica*on  §  Ample  but  limited  memory  4  –  8G  

§  Ample  but  limited  CPU    Server  Centric  Applica*on  §  Significant  GUI  overhead                          Space  per  instance  

§  Startup time per instance §  Persistent Object/Record Serialization and Materialization §  Ample memory 64-1TB + cpu 32 – 128 cores

Embedded  or  Pervasive  §   Power  Constrained  and  Instant  On  

§  Memory  Constrained  

§  Code  in  Flash  

§  Trusted  

§  Na*ve  Code  Interoperability  

§  Real-­‐*me  GC  

 

Page 16: YOW! JVM Demystified Dave Thomas

16

Java  JVM  Challenges  Today    

Java  Developers  s*ll  face  big  challenges    §  “Cloud”  -­‐  virtualiza*on,  footprint/density,  run*me  dynamism  

§   “Big*.*”  -­‐  data,  threads,  memory,  scale  out,  scale  up  

§  Security  -­‐  cri*cal  to  connected  soZware  and  hard  to  get  right  §  Compa*bility  –  need  to  innovate  and  protect  exis*ng  investment  in  

code  and  tools    

§  Plus  ...  mobile  ,  polyglot  ,  development  efficiency,  simplicity    

 

©  John  Duwimovich  CTO  IBM  Java  VMs  “  We  can  do  beler  …”  

© 2013 Bedarra Research Labs. All rights reserved.

Musings  on  Next  Genera*on  VMs  

Challenges  with  JVM  and  CLR…    •  Stacks  easy  for  compiler,  hard  for  JIT  •  Security  difficult  at  best  and  limits  access  to  some  na*ve  HW  

features  •  Difficult  to  exploit  major  changes  in  HW  e.g.  memory  models,  

massive  concurrency…  •  LVM  are  always  L  Biased  to  the  LVM  family  of  languages    

§  E.g.  strong  types,  no  tags,  no  call  cc…    

Is  it  possible  to  have  a  UVM  which  lets  interesOng  languages  bloom  and  prosper  to  avoid  bloaOng  My  Language  PL/I,  Ada,  

Java  7+,  C++  11  …?    

© 2013 Bedarra Research Labs. All rights reserved.

Page 17: YOW! JVM Demystified Dave Thomas

17

Further  Reading  

Structure  and  Interpreta*on  of  Computer  Programs,  Abelson  and  Sussman  

The  Lambda  Papers,  Guy  Steele,  MIT  Technical  Reports  

Understanding  Java  Garbage  Collec*on,  Gil  Tene  

JVM  JIT  for  Dummies,  Charles  Nuler  

We  Can  Do  Beler,  IBM’s    Vision  for  Next  Genera*on  Java  VMs,  EclipseCon  Europe  

Smalltalk-­‐80:  The  Language  and  its  Implementa*on,  Goldberg,  A.,  Robson.  I,    Addison-­‐Wesley,  1983.    

Op*mizing  Dynamically-­‐Dispatched  with  Run-­‐Time  Type  Feedback,    

Urs  Holzle  

V8  A  High  Performance  Open  Source  JavaScript  Engine,  Kasper  Lund  

Trace-­‐based  Just-­‐in-­‐Time  Type  Specializa*on  for  Dynamic  Languages,  Andreas  Gal  et  al  

 

 

 

 

 

 

 

 

 

 

 

© 2013 Bedarra Research Labs. All rights reserved.

Musings  on  Next  Genera*on  VMs  

Back  to  the  Future?  –  Virtual  Instruc*on  Set  Computers  (VISC)    

•  AS/400,  DAISY,  B-­‐RISC,  Transmeta,  LLDA,  AMD  HAS,  Google  PNaCl…  

•  Supports  many  language  using  so7ware  fault  isola-on  •  Infinite    register  machine    •  Single  assignment  3  address  instruc*ons  •  Op*onal  data  flow  and  control  flow  informa*on  

 

 

© 2013 Bedarra Research Labs. All rights reserved.

Page 18: YOW! JVM Demystified Dave Thomas

18

Musings  on  Next  Genera*on  VMs  

© 2013 Bedarra Research Labs. All rights reserved.

•  JIT  Virtual  Machine  to  Real  Machine    •  LLVM  low  level  infrastructure  popular  plajorm  •  Google  PNaCl  “Pinnacle”  claim  7%  overhead  on  Intel  and  5%  on  

ARM  for  C/C++  •  AMD  Heterogeneous  System  Architecture  (HAS)  VSIC  for  CPU+  

GPU  …  

 

Thanks!    Please  give  them  the  applause  

© 2013 Bedarra Research Labs. All rights reserved.