SlideShare uma empresa Scribd logo
1 de 91
A	
  love/hate	
  rela,onship:	
  	
  
The	
  JVM/OS	
  dialec,c	
  
Marcus	
  Lagergren,	
  Oracle	
  
A	
  love/hate	
  rela,onship:	
  	
  
The	
  JVM/OS	
  dialec,c	
  
Marcus	
  Lagergren,	
  Oracle	
  
and	
  the	
  hardware…	
  
A	
  love/hate	
  rela,onship:	
  	
  
The	
  JVM/OS	
  dialec,c	
  
Marcus	
  Lagergren,	
  Oracle	
  
Fredrik	
  Öhrström,	
  Spo,fy	
  
and	
  the	
  hardware…	
  
The	
  Legal	
  Slide	
  

"THE FOLLOWING IS INTENDED TO OUTLINE OUR
GENERAL PRODUCT DIRECTION. IT IS INTENDED FOR
INFORMATION PURPOSES ONLY, AND MAY NOT BE
INCORPORATED INTO ANY CONTRACT. IT IS NOT A
COMMITMENT TO DELIVER ANY MATERIAL, CODE, OR
FUNCTIONALITY, AND SHOULD NOT BE RELIED UPON
IN MAKING PURCHASING DECISION. THE
DEVELOPMENT, RELEASE, AND TIMING OF ANY
FEATURES OR FUNCTIONALITY DESCRIBED FOR
ORACLE'S PRODUCTS REMAINS AT THE SOLE
DISCRETION OF ORACLE."
	
  
Agenda	
  
•  In	
  the	
  borderlands	
  between	
  hardware,	
  OS	
  and	
  
JVM,	
  both	
  good	
  and	
  bad	
  things	
  happen	
  
•  Computer	
  history	
  
•  How	
  do	
  they	
  affect	
  each	
  other?	
  
•  Where	
  is	
  it	
  all	
  going?	
  
Who	
  am	
  I?	
  
@lagergren	
  
Who	
  am	
  I?	
  
Who	
  am	
  I?	
  
mlvm-­‐dev@openjdk.java.net	
  
nashorn-­‐dev@openjdk.java.net	
  
hRps://avatar.java.net	
  
	
  
Who	
  am	
  I?	
  
Who	
  am	
  I?	
  
Who	
  is	
  Fredrik?	
  
Who	
  is	
  Fredrik?	
  
Who	
  is	
  Fredrik?	
  
Who	
  is	
  Fredrik?	
  
The	
  Past	
  
The	
  Past	
  
(Skipping	
  very	
  quickly	
  over	
  a	
  tremendous	
  
amount	
  of	
  hardware)	
  
Texas	
  Instruments	
  TI	
  99/4a	
  
•  1979-­‐1984	
  
•  Contains	
  an	
  OS	
  and	
  a	
  GPL	
  interpreter	
  
•  Device	
  drivers	
  (DSRs)	
  could	
  be	
  wriRen	
  in	
  GPL	
  
Texas	
  Instruments	
  TI	
  99/4a	
  
•  1979-­‐1984	
  
•  Contains	
  an	
  OS	
  and	
  a	
  GPL	
  interpreter	
  
•  Device	
  drivers	
  (DSRs)	
  could	
  be	
  wriRen	
  in	
  GPL	
  
•  They	
  intended	
  to	
  execute	
  GPL	
  bytecode	
  
na,vely	
  
– But	
  they	
  never	
  did	
  
VIC	
  20	
  and	
  Commodore	
  64	
  
•  1980-­‐1986	
  
VIC	
  20	
  and	
  Commodore	
  64	
  
•  1980-­‐1986	
  
http://codebase64.org
VIC	
  20	
  and	
  Commodore	
  64	
  
•  1980-­‐1986	
  
VIC	
  20	
  and	
  Commodore	
  64	
  
•  1980-­‐1986	
  
•  Basic	
  interpreter	
  wriRen	
  in	
  C	
  on	
  my	
  Mac	
  
– 1000x	
  faster	
  than	
  a	
  physical	
  6502	
  
Nothing	
  new	
  under	
  the	
  sun?	
  
…and	
  stuff	
  
MITS	
  Altair	
  8800,	
  Commodore	
  PET	
  2001,	
  Apple	
  II,	
  Atari	
  
VCS,	
  Tandy	
  Radio	
  Shack	
  TRS-­‐80,	
  ABC	
  80,	
  NASCOM-­‐1,	
  Sharp	
  
MZ-­‐80k,	
  Atari	
  400/800,	
  MaRel	
  Intellivision,	
  Tangerine	
  
Microtan	
  65,	
  HP-­‐85,	
  Sinclair	
  ZX80,	
  Acorn	
  Atom,	
  Sinclair	
  
ZX81,	
  Osborne	
  1,	
  IBM	
  PC,	
  BBC	
  Micro,	
  Sinclair	
  ZX	
  Spectrum,	
  
Coleco	
  Vision,	
  GCE/MB	
  Vectrex,	
  Grundy	
  Newbrain,	
  Dragon	
  
32,	
  Jupiter	
  ACE,	
  Compaq	
  Portable,	
  Apple	
  Lisa,	
  Oric	
  1,	
  
MaRel	
  Aquarius,	
  Nintendo	
  Famicom/NES,	
  Acorn	
  Electron,	
  
Sony	
  MSX,	
  Apple	
  Macintosh,	
  Sinclair	
  QL,	
  Amstrad	
  
CPC-­‐464,	
  IBM	
  PC	
  AT,	
  Tatung	
  Einstein,	
  Atari	
  ST,	
  
Commodore	
  Amiga,	
  Amstrad	
  PCW,	
  Sega	
  Master	
  System,	
  
Acorn	
  Archimedes,	
  NeXT	
  
	
  
The	
  JavaSta,on	
  
•  1996-­‐2000	
  
•  Contains	
  JavaOS,	
  a	
  micro	
  kernel	
  in	
  C	
  with	
  an	
  
interpreter	
  
•  Device	
  drivers	
  were	
  wriRen	
  in	
  Java	
  
The	
  JavaSta,on	
  
•  1996-­‐2000	
  
•  Contains	
  JavaOS,	
  a	
  micro	
  kernel	
  in	
  C	
  with	
  an	
  
interpreter	
  
•  Device	
  drivers	
  were	
  wriRen	
  in	
  Java	
  
•  They	
  intended	
  to	
  execute	
  bytecode	
  na,vely	
  
– But	
  they	
  never	
  did	
  
Intermediate	
  Languages	
  
Intermediate	
  Languages	
  
•  1966:	
  O-­‐code	
  (BCPL)	
  
•  1970:	
  p-­‐code	
  (Pascal)	
  
•  1979:	
  GPL	
  
•  1995:	
  Java	
  Bytecode	
  
Intermediate	
  Languages	
  
•  1966:	
  O-­‐code	
  (BCPL)	
  
•  1970:	
  p-­‐code	
  (Pascal)	
  
•  1979:	
  GPL	
  
•  1995:	
  Java	
  Bytecode	
  
Intermediate	
  Languages	
  
•  1966:	
  O-­‐code	
  (BCPL)	
  
•  1970:	
  p-­‐code	
  (Pascal)	
  
•  1979:	
  GPL	
  
•  1995:	
  Java	
  Bytecode	
  
Intermediate	
  Languages	
  
•  1966:	
  O-­‐code	
  (BCPL)	
  
•  1970:	
  p-­‐code	
  (Pascal)	
  
•  1979:	
  GPL	
  
•  1995:	
  Java	
  Bytecode	
  
…and	
  more	
  stuff	
  
Ac,onscript,	
  Adobe	
  Flash	
  objects,	
  BANCStar,	
  
CLISP,	
  CMUCL,	
  CLR/.NET,	
  Dalvik,	
  Dis,	
  
EiffelStudio,	
  Emacs	
  eLisp-­‐>bytecode,	
  
Embeddable	
  Common	
  Lisp,	
  Erlang/BEAM,	
  Icon,	
  
Unicon,	
  Infocom/Z-­‐machine	
  text	
  adventure	
  
games,	
  LLVM,	
  Lua,	
  m-­‐code/MATLAB,	
  OCaml,	
  
Parrot	
  Virtual	
  Machine,	
  R,	
  Scheme	
  48,	
  Smalltalk,	
  
SPIN/Parallax	
  Propeller	
  Microcontroller,	
  
SWEET16/Apple	
  II	
  Basic	
  ROM,	
  Visual	
  FoxPro	
  
bytecode,	
  YARV,	
  Rubinius	
  
Intermediate	
  Languages	
  
•  1966:	
  O-­‐code	
  (BCPL)	
  
•  1970:	
  p-­‐code	
  (Pascal)	
  
•  1979:	
  GPL	
  
•  1995:	
  Java	
  Bytecode	
  
Intermediate	
  Languages	
  
•  1966:	
  O-­‐code	
  (BCPL)	
  
•  1970:	
  p-­‐code	
  (Pascal)	
  
•  1979:	
  GPL	
  
•  1995:	
  Java	
  Bytecode	
  
– memory	
  protec,on,	
  type	
  and	
  control	
  verifica,on	
  
and	
  explicit	
  security	
  management,	
  “sandbox”	
  
model,	
  “object	
  orienta,on”	
  
Intermediate	
  Languages	
  
•  1966:	
  O-­‐code	
  (BCPL)	
  
•  1970:	
  p-­‐code	
  (Pascal)	
  
•  1979:	
  GPL	
  
•  1995:	
  Java	
  Bytecode	
  
– memory	
  protec,on,	
  type	
  and	
  control	
  verifica,on	
  
and	
  explicit	
  security	
  management,	
  “sandbox”	
  
model,	
  “object	
  orienta,on”	
  
•  1999:	
  The	
  JavaOS	
  is	
  discon,nued	
  
Intermediate	
  Languages	
  
Intermediate	
  Languages	
  
To	
  put	
  it	
  simply	
  
•  The	
  JVM	
  has	
  OS-­‐like	
  behavior	
  
– Threads	
  
– Memory	
  management/protec,on	
  
– Locking	
  
•  All	
  this	
  is	
  somewhat	
  mi,gated	
  through	
  libc	
  &	
  
other	
  libraries	
  
Threads	
  
Threads	
  
•  Heavy	
  weight	
  processes	
  
– Slow	
  switching	
  
– fork()	
  
Threads	
  
•  Heavy	
  weight	
  processes	
  
– Slow	
  switching	
  
– fork()	
  
•  Green	
  threads	
  
– Fast	
  switching,	
  difficult	
  to	
  implement	
  
•  Na,ve	
  Locks?	
  
Threads	
  
•  Heavy	
  weight	
  processes	
  
– Slow	
  switching	
  
– fork()	
  
•  Green	
  threads	
  
– Fast	
  switching,	
  difficult	
  to	
  implement	
  
•  Na,ve	
  Locks?	
  
•  MxN	
  threads	
  
– Even	
  more	
  difficult	
  to	
  implement	
  
Threads	
  
•  The	
  old	
  standby:	
  OS	
  Threads	
  
•  No	
  support	
  for	
  stack	
  overflow	
  
•  By	
  defini,on,	
  no	
  memory	
  protec,on	
  between	
  
threads	
  
Locks	
  
Locks	
  
Locks	
  
SYNCHRONIZATION	
  
THREADS	
  
Thin	
  Locks	
  
public class PseudoSpinlock { 

private static final int LOCK_FREE = 0; 
private static final int LOCK_TAKEN = 1; 

public void lock() { 

//burn cycles

while (cmpxchg(LOCK_TAKEN, &lock) == LOCK_TAKEN) {

 
micropause(); //optional

}
} 


public void unlock() { 

 
int old = cmpxchg(LOCK_FREE, &lock); 

 
//guard against recursive locks

 
assert(old == LOCK_TAKEN); 

} 
}
Thin	
  Locks	
  
•  Use	
  whatever	
  atomic	
  support	
  there	
  is	
  in	
  the	
  
hardware	
  /	
  OS	
  
•  Cheap	
  to	
  lock	
  and	
  unlock,	
  expensive	
  to	
  keep	
  
locked	
  
Fat	
  Locks	
  
•  Use	
  OS	
  lock	
  support	
  
•  Expensive	
  to	
  lock	
  and	
  unlock,	
  cheap	
  to	
  keep	
  
locked	
  
•  Need	
  for	
  more	
  advanced	
  synchroniza,on	
  
mechanisms	
  
– wait
– notify
Adap,ve	
  Behavior	
  
•  Profile	
  based	
  transmuta,on	
  of	
  thin	
  locks	
  to	
  fat	
  
locks	
  	
  
– …and	
  vice	
  versa	
  
– Nothing	
  your	
  C	
  program	
  can	
  do	
  
Adap,ve	
  Behavior	
  
•  Profile	
  based	
  transmuta,on	
  of	
  thin	
  locks	
  to	
  fat	
  
locks	
  	
  
– …and	
  vice	
  versa	
  
– Nothing	
  your	
  C	
  program	
  can	
  do	
  
•  Biased	
  locking	
  
Adap,ve	
  Behavior	
  
•  Profile	
  based	
  transmuta,on	
  of	
  thin	
  locks	
  to	
  fat	
  
locks	
  	
  
– …and	
  vice	
  versa	
  
– Nothing	
  your	
  C	
  program	
  can	
  do	
  
•  Biased	
  locking	
  
•  Thread	
  switching	
  heuris,cs	
  /	
  Cache	
  warmup	
  
Adap,ve	
  Behavior	
  
•  Constant	
  tension	
  between	
  OS	
  switching	
  and	
  
Java	
  switching.	
  
– One	
  example	
  of	
  a	
  JVM/OS	
  baRle	
  
Na,ve	
  Memory	
  
Na,ve	
  Memory	
  
Na,ve	
  Memory	
  
Na,ve	
  Memory	
  Tracking	
  
HotSpot:	
  	
  
java –XX:NativeMemoryTracking=<summary|detail> Test
jcmd <pid> VM.native_memory
	
  
JRockit:	
  
USE_OS_MALLOC=0 TRACE_ALLOC_SITES=1 java Test
jrcmd <pid> print_memusage
Memory	
  Models	
  
Memory	
  Models	
  
public class WhileLoop {

//can be accessed by other threads

private boolean finished; 


while (!finished) {

 
do something…

}
}
Memory	
  Models	
  
public class WhileLoop {

//can be accessed by other threads

private boolean finished; 


boolean tmp = finished;

while (!tmp) {

 
do something…

}
}
Memory	
  Models	
  
public class WhileLoop {

//can be accessed by other threads

private volatile boolean finished; 


while (!finished) {

 
do something…

}
}
Memory	
  Models	
  
volatile int x; 
int y; 
volatile boolean finished; 

x = 17; 
y = 4711; 
finished = true; 

if (finished) { 

System.err.println(x); 

System.err.println(y); 
}
Memory	
  Models	
  
volatile int x; 
int y; 
volatile boolean finished; 

x = 17; 
y = 4711; 
finished = true; 

if (finished) { 

System.err.println(x); 

System.err.println(y); 
}
Memory	
  Models	
  
public class GadgetHolder { 

private Gadget theGadget; 


public synchronized Gadget getGadget() { 

 
if (this.theGadget == null) {

 
 
this.theGadget = new Gadget(); 

 
} 

 
return this.theGadget; 

} 
}
Memory	
  Models	
  
public class GadgetHolder { 

private Gadget theGadget; 


public Gadget
 getGadget() { 

 
if (this.theGadget == null) {

 
 
synchronized(this) {

 
 
 
if (this.theGadget == null) {

 
 
 
 
this.theGadget = new Gadget(); 

 
 
 
}

 
 
}

 
} 

 
return this.theGadget; 

} 
}
Memory	
  Models	
  
public class GadgetHolder { 

private volatile Gadget theGadget; 


public Gadget
 getGadget() { 

 
if (this.theGadget == null) {

 
 
synchronized(this) {

 
 
 
if (this.theGadget == null) {

 
 
 
 
this.theGadget = new Gadget(); 

 
 
 
}

 
 
}

 
} 

 
return this.theGadget; 

} 
}
Memory	
  Models	
  
public class GadgetMaker {

public static Gadget theGadget = new Gadget();
}
WTF?	
  
Taking	
  Control	
  of	
  the	
  OS	
  
Taking	
  Control	
  of	
  the	
  OS	
  
•  Taking	
  control	
  of	
  the	
  OS	
  
•  Taking	
  control	
  of	
  the	
  na,ve	
  memory	
  
•  Taking	
  control	
  of	
  the	
  C	
  heap	
  
Taking	
  Control	
  of	
  the	
  OS	
  
•  Taking	
  control	
  of	
  the	
  OS	
  
•  Taking	
  control	
  of	
  the	
  na,ve	
  memory	
  
•  Taking	
  control	
  of	
  the	
  C	
  heap	
  
•  Well	
  you	
  can’t	
  really,	
  but	
  you	
  can	
  do	
  your	
  best	
  
Is	
  the	
  JVM	
  an	
  OS?	
  
•  JRockit	
  Virtual	
  Edi,on	
  
•  Azul	
  
•  Cloudius	
  
•  Jnode	
  
•  …	
  
	
  
Is	
  the	
  JVM	
  an	
  OS?	
  
•  JRockit	
  Virtual	
  Edi,on	
  
•  Implemented	
  libc,	
  libraries	
  and	
  the	
  OS	
  
– Not	
  much	
  required	
  for	
  a	
  single	
  process	
  Java	
  OS.	
  
•  Finally,	
  the	
  Java	
  OS?	
  
Is	
  the	
  JVM	
  an	
  OS?	
  
Is	
  the	
  JVM	
  an	
  OS?	
  
Is	
  the	
  JVM	
  an	
  OS?	
  
•  Add	
  a	
  coopera,ve	
  aspect	
  to	
  thread	
  switching	
  
•  Zero-­‐copy	
  networking	
  code	
  
•  Reduce	
  cost	
  of	
  entering	
  OS	
  
•  Balloon	
  driver	
  
•  Runs	
  only	
  on	
  hypervisor	
  
Pauseless	
  GC	
  
•  Hope	
  that	
  a	
  lot	
  of	
  data	
  is	
  thread	
  local	
  and	
  
remains	
  thread	
  local	
  
– (it	
  usually	
  is)	
  
Pauseless	
  GC	
  
•  Hope	
  that	
  a	
  lot	
  of	
  data	
  is	
  thread	
  local	
  and	
  
remains	
  thread	
  local	
  
– (it	
  usually	
  is)	
  
•  Use	
  one	
  large	
  global	
  heap	
  and	
  one	
  thread	
  
local	
  heap	
  per	
  thread	
  
Pauseless	
  GC	
  
•  Hope	
  that	
  a	
  lot	
  of	
  data	
  is	
  thread	
  local	
  and	
  
remains	
  thread	
  local	
  
– (it	
  usually	
  is)	
  
•  Use	
  one	
  large	
  global	
  heap	
  and	
  one	
  thread	
  
local	
  heap	
  per	
  thread	
  
•  If	
  thread	
  local	
  data	
  is	
  exposed	
  to	
  another	
  
thread	
  –	
  promote	
  to	
  global	
  heap	
  
Pauseless	
  GC	
  
•  We	
  need	
  a	
  write	
  barrier	
  
	
  
//x.field = y
void checkWriteAccess(Object x, Object y) {

if (x.isOnGlobalHeap() && !y.isOnGlobalHeap()) {

 
GC.registerReferenceGlobalToLocal(x, y);

}
}
	
  
Pauseless	
  GC	
  
•  …	
  and	
  a	
  read	
  barrier	
  
	
  
//read x.field
void checkReadAccess(Object x) {
int myTid = getThreadId();

//if this object is thread local and 
//belongs to another thread, evacuate to global heap
if (!x.isOnGlobalHeap() && !x.isInternalTo(myTid)) {

x.evaculateToGlobalHeap(); //painful
}
}
	
  
Pauseless	
  GC	
  
•  Barriers	
  have	
  to	
  extremely	
  fast,	
  or	
  everything	
  
will	
  disappear	
  in	
  overhead	
  
Pauseless	
  GC	
  
•  Barriers	
  have	
  to	
  extremely	
  fast,	
  or	
  everything	
  
will	
  disappear	
  in	
  overhead	
  
Pauseless	
  GC	
  
•  We	
  can,	
  because	
  we	
  own	
  and	
  implemented	
  
the	
  thread	
  system	
  
OS/JVM/Hardware	
  improvements	
  
•  Threading	
  
•  Locking	
  
•  Na,ve	
  memory	
  usage	
  
•  Virtual	
  address	
  memory	
  usage/exhaus,on	
  
•  Stack	
  overflows	
  
•  Page	
  protec,on	
  
OS/JVM/Hardware	
  improvements	
  
•  Trap	
  on	
  overflow	
  
•  Read	
  barriers	
  
•  Performance	
  counters	
  
– IP	
  samples	
  
– Cache	
  misses	
  
– Userland,	
  please	
  
•  …	
  
So?	
  	
  
Conclusion	
  	
  
•  It	
  doesn’t	
  hurt	
  to	
  know	
  what’s	
  inside	
  your	
  
execu,on	
  environment	
  
•  In	
  the	
  future	
  –	
  the	
  distance	
  between	
  
hardware,	
  OS	
  and	
  run,me	
  will	
  decrease	
  or	
  
disappear	
  altogether.	
  
Q	
  &	
  A?	
  

Mais conteúdo relacionado

Semelhante a Geek out 2014-lagergren-final

Scala & Spark(1.6) in Performance Aspect for Scala Taiwan
Scala & Spark(1.6) in Performance Aspect for Scala TaiwanScala & Spark(1.6) in Performance Aspect for Scala Taiwan
Scala & Spark(1.6) in Performance Aspect for Scala TaiwanJimin Hsieh
 
The Java Virtual Machine is Over - The Polyglot VM is here - Marcus Lagergren...
The Java Virtual Machine is Over - The Polyglot VM is here - Marcus Lagergren...The Java Virtual Machine is Over - The Polyglot VM is here - Marcus Lagergren...
The Java Virtual Machine is Over - The Polyglot VM is here - Marcus Lagergren...jaxLondonConference
 
Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)Martijn Verburg
 
Building Asynchronous Applications
Building Asynchronous ApplicationsBuilding Asynchronous Applications
Building Asynchronous ApplicationsJohan Edstrom
 
Rust Programming Language
Rust Programming LanguageRust Programming Language
Rust Programming LanguageJaeju Kim
 
A Post-Apocalyptic sun.misc.Unsafe World by Christoph engelbert
A Post-Apocalyptic sun.misc.Unsafe World by Christoph engelbertA Post-Apocalyptic sun.misc.Unsafe World by Christoph engelbert
A Post-Apocalyptic sun.misc.Unsafe World by Christoph engelbertJ On The Beach
 
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvmScala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvmSkills Matter
 
Java in High Frequency Trading
Java in High Frequency TradingJava in High Frequency Trading
Java in High Frequency TradingViktor Sovietov
 
Renaissance of sparc UKOUG 2014
Renaissance of sparc UKOUG 2014Renaissance of sparc UKOUG 2014
Renaissance of sparc UKOUG 2014Philippe Fierens
 
Modern Java Concurrency (Devoxx Nov/2011)
Modern Java Concurrency (Devoxx Nov/2011)Modern Java Concurrency (Devoxx Nov/2011)
Modern Java Concurrency (Devoxx Nov/2011)Martijn Verburg
 
You Call that Micro, Mr. Docker? How OSv and Unikernels Help Micro-services S...
You Call that Micro, Mr. Docker? How OSv and Unikernels Help Micro-services S...You Call that Micro, Mr. Docker? How OSv and Unikernels Help Micro-services S...
You Call that Micro, Mr. Docker? How OSv and Unikernels Help Micro-services S...rhatr
 
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)OpenBlend society
 
From Commodore 64 to the Cloud — Lessons from 30 years of programming
From Commodore 64 to the Cloud — Lessons from 30 years of programmingFrom Commodore 64 to the Cloud — Lessons from 30 years of programming
From Commodore 64 to the Cloud — Lessons from 30 years of programmingSteven Shaw
 
Lagergren jvmls-2014-final
Lagergren jvmls-2014-finalLagergren jvmls-2014-final
Lagergren jvmls-2014-finalMarcus Lagergren
 
Application Profiling for Memory and Performance
Application Profiling for Memory and PerformanceApplication Profiling for Memory and Performance
Application Profiling for Memory and Performancepradeepfn
 
Peyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futurePeyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futureTakayuki Muranushi
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSkills Matter
 
How we got to 1 millisecond latency in 99% under repair, compaction, and flus...
How we got to 1 millisecond latency in 99% under repair, compaction, and flus...How we got to 1 millisecond latency in 99% under repair, compaction, and flus...
How we got to 1 millisecond latency in 99% under repair, compaction, and flus...ScyllaDB
 
Towards a Scalable Non-Blocking Coding Style
Towards a Scalable Non-Blocking Coding StyleTowards a Scalable Non-Blocking Coding Style
Towards a Scalable Non-Blocking Coding StyleAzul Systems Inc.
 

Semelhante a Geek out 2014-lagergren-final (20)

Scala & Spark(1.6) in Performance Aspect for Scala Taiwan
Scala & Spark(1.6) in Performance Aspect for Scala TaiwanScala & Spark(1.6) in Performance Aspect for Scala Taiwan
Scala & Spark(1.6) in Performance Aspect for Scala Taiwan
 
The Java Virtual Machine is Over - The Polyglot VM is here - Marcus Lagergren...
The Java Virtual Machine is Over - The Polyglot VM is here - Marcus Lagergren...The Java Virtual Machine is Over - The Polyglot VM is here - Marcus Lagergren...
The Java Virtual Machine is Over - The Polyglot VM is here - Marcus Lagergren...
 
Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)
 
Building Asynchronous Applications
Building Asynchronous ApplicationsBuilding Asynchronous Applications
Building Asynchronous Applications
 
Rust Programming Language
Rust Programming LanguageRust Programming Language
Rust Programming Language
 
A Post-Apocalyptic sun.misc.Unsafe World by Christoph engelbert
A Post-Apocalyptic sun.misc.Unsafe World by Christoph engelbertA Post-Apocalyptic sun.misc.Unsafe World by Christoph engelbert
A Post-Apocalyptic sun.misc.Unsafe World by Christoph engelbert
 
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvmScala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
 
Java in High Frequency Trading
Java in High Frequency TradingJava in High Frequency Trading
Java in High Frequency Trading
 
Renaissance of sparc UKOUG 2014
Renaissance of sparc UKOUG 2014Renaissance of sparc UKOUG 2014
Renaissance of sparc UKOUG 2014
 
Modern Java Concurrency (Devoxx Nov/2011)
Modern Java Concurrency (Devoxx Nov/2011)Modern Java Concurrency (Devoxx Nov/2011)
Modern Java Concurrency (Devoxx Nov/2011)
 
You Call that Micro, Mr. Docker? How OSv and Unikernels Help Micro-services S...
You Call that Micro, Mr. Docker? How OSv and Unikernels Help Micro-services S...You Call that Micro, Mr. Docker? How OSv and Unikernels Help Micro-services S...
You Call that Micro, Mr. Docker? How OSv and Unikernels Help Micro-services S...
 
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
 
From Commodore 64 to the Cloud — Lessons from 30 years of programming
From Commodore 64 to the Cloud — Lessons from 30 years of programmingFrom Commodore 64 to the Cloud — Lessons from 30 years of programming
From Commodore 64 to the Cloud — Lessons from 30 years of programming
 
Lagergren jvmls-2014-final
Lagergren jvmls-2014-finalLagergren jvmls-2014-final
Lagergren jvmls-2014-final
 
Application Profiling for Memory and Performance
Application Profiling for Memory and PerformanceApplication Profiling for Memory and Performance
Application Profiling for Memory and Performance
 
Peyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futurePeyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_future
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelism
 
How we got to 1 millisecond latency in 99% under repair, compaction, and flus...
How we got to 1 millisecond latency in 99% under repair, compaction, and flus...How we got to 1 millisecond latency in 99% under repair, compaction, and flus...
How we got to 1 millisecond latency in 99% under repair, compaction, and flus...
 
ZeroMQ
ZeroMQZeroMQ
ZeroMQ
 
Towards a Scalable Non-Blocking Coding Style
Towards a Scalable Non-Blocking Coding StyleTowards a Scalable Non-Blocking Coding Style
Towards a Scalable Non-Blocking Coding Style
 

Último

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 

Último (20)

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

Geek out 2014-lagergren-final

  • 1. A  love/hate  rela,onship:     The  JVM/OS  dialec,c   Marcus  Lagergren,  Oracle  
  • 2. A  love/hate  rela,onship:     The  JVM/OS  dialec,c   Marcus  Lagergren,  Oracle   and  the  hardware…  
  • 3. A  love/hate  rela,onship:     The  JVM/OS  dialec,c   Marcus  Lagergren,  Oracle   Fredrik  Öhrström,  Spo,fy   and  the  hardware…  
  • 4. The  Legal  Slide   "THE FOLLOWING IS INTENDED TO OUTLINE OUR GENERAL PRODUCT DIRECTION. IT IS INTENDED FOR INFORMATION PURPOSES ONLY, AND MAY NOT BE INCORPORATED INTO ANY CONTRACT. IT IS NOT A COMMITMENT TO DELIVER ANY MATERIAL, CODE, OR FUNCTIONALITY, AND SHOULD NOT BE RELIED UPON IN MAKING PURCHASING DECISION. THE DEVELOPMENT, RELEASE, AND TIMING OF ANY FEATURES OR FUNCTIONALITY DESCRIBED FOR ORACLE'S PRODUCTS REMAINS AT THE SOLE DISCRETION OF ORACLE."  
  • 5. Agenda   •  In  the  borderlands  between  hardware,  OS  and   JVM,  both  good  and  bad  things  happen   •  Computer  history   •  How  do  they  affect  each  other?   •  Where  is  it  all  going?  
  • 6. Who  am  I?   @lagergren  
  • 8. Who  am  I?   mlvm-­‐dev@openjdk.java.net   nashorn-­‐dev@openjdk.java.net   hRps://avatar.java.net    
  • 15.
  • 17. The  Past   (Skipping  very  quickly  over  a  tremendous   amount  of  hardware)  
  • 18. Texas  Instruments  TI  99/4a   •  1979-­‐1984   •  Contains  an  OS  and  a  GPL  interpreter   •  Device  drivers  (DSRs)  could  be  wriRen  in  GPL  
  • 19. Texas  Instruments  TI  99/4a   •  1979-­‐1984   •  Contains  an  OS  and  a  GPL  interpreter   •  Device  drivers  (DSRs)  could  be  wriRen  in  GPL   •  They  intended  to  execute  GPL  bytecode   na,vely   – But  they  never  did  
  • 20. VIC  20  and  Commodore  64   •  1980-­‐1986  
  • 21. VIC  20  and  Commodore  64   •  1980-­‐1986   http://codebase64.org
  • 22. VIC  20  and  Commodore  64   •  1980-­‐1986  
  • 23. VIC  20  and  Commodore  64   •  1980-­‐1986   •  Basic  interpreter  wriRen  in  C  on  my  Mac   – 1000x  faster  than  a  physical  6502  
  • 24. Nothing  new  under  the  sun?  
  • 25. …and  stuff   MITS  Altair  8800,  Commodore  PET  2001,  Apple  II,  Atari   VCS,  Tandy  Radio  Shack  TRS-­‐80,  ABC  80,  NASCOM-­‐1,  Sharp   MZ-­‐80k,  Atari  400/800,  MaRel  Intellivision,  Tangerine   Microtan  65,  HP-­‐85,  Sinclair  ZX80,  Acorn  Atom,  Sinclair   ZX81,  Osborne  1,  IBM  PC,  BBC  Micro,  Sinclair  ZX  Spectrum,   Coleco  Vision,  GCE/MB  Vectrex,  Grundy  Newbrain,  Dragon   32,  Jupiter  ACE,  Compaq  Portable,  Apple  Lisa,  Oric  1,   MaRel  Aquarius,  Nintendo  Famicom/NES,  Acorn  Electron,   Sony  MSX,  Apple  Macintosh,  Sinclair  QL,  Amstrad   CPC-­‐464,  IBM  PC  AT,  Tatung  Einstein,  Atari  ST,   Commodore  Amiga,  Amstrad  PCW,  Sega  Master  System,   Acorn  Archimedes,  NeXT    
  • 26. The  JavaSta,on   •  1996-­‐2000   •  Contains  JavaOS,  a  micro  kernel  in  C  with  an   interpreter   •  Device  drivers  were  wriRen  in  Java  
  • 27. The  JavaSta,on   •  1996-­‐2000   •  Contains  JavaOS,  a  micro  kernel  in  C  with  an   interpreter   •  Device  drivers  were  wriRen  in  Java   •  They  intended  to  execute  bytecode  na,vely   – But  they  never  did  
  • 29. Intermediate  Languages   •  1966:  O-­‐code  (BCPL)   •  1970:  p-­‐code  (Pascal)   •  1979:  GPL   •  1995:  Java  Bytecode  
  • 30. Intermediate  Languages   •  1966:  O-­‐code  (BCPL)   •  1970:  p-­‐code  (Pascal)   •  1979:  GPL   •  1995:  Java  Bytecode  
  • 31. Intermediate  Languages   •  1966:  O-­‐code  (BCPL)   •  1970:  p-­‐code  (Pascal)   •  1979:  GPL   •  1995:  Java  Bytecode  
  • 32. Intermediate  Languages   •  1966:  O-­‐code  (BCPL)   •  1970:  p-­‐code  (Pascal)   •  1979:  GPL   •  1995:  Java  Bytecode  
  • 33. …and  more  stuff   Ac,onscript,  Adobe  Flash  objects,  BANCStar,   CLISP,  CMUCL,  CLR/.NET,  Dalvik,  Dis,   EiffelStudio,  Emacs  eLisp-­‐>bytecode,   Embeddable  Common  Lisp,  Erlang/BEAM,  Icon,   Unicon,  Infocom/Z-­‐machine  text  adventure   games,  LLVM,  Lua,  m-­‐code/MATLAB,  OCaml,   Parrot  Virtual  Machine,  R,  Scheme  48,  Smalltalk,   SPIN/Parallax  Propeller  Microcontroller,   SWEET16/Apple  II  Basic  ROM,  Visual  FoxPro   bytecode,  YARV,  Rubinius  
  • 34. Intermediate  Languages   •  1966:  O-­‐code  (BCPL)   •  1970:  p-­‐code  (Pascal)   •  1979:  GPL   •  1995:  Java  Bytecode  
  • 35. Intermediate  Languages   •  1966:  O-­‐code  (BCPL)   •  1970:  p-­‐code  (Pascal)   •  1979:  GPL   •  1995:  Java  Bytecode   – memory  protec,on,  type  and  control  verifica,on   and  explicit  security  management,  “sandbox”   model,  “object  orienta,on”  
  • 36. Intermediate  Languages   •  1966:  O-­‐code  (BCPL)   •  1970:  p-­‐code  (Pascal)   •  1979:  GPL   •  1995:  Java  Bytecode   – memory  protec,on,  type  and  control  verifica,on   and  explicit  security  management,  “sandbox”   model,  “object  orienta,on”   •  1999:  The  JavaOS  is  discon,nued  
  • 39. To  put  it  simply   •  The  JVM  has  OS-­‐like  behavior   – Threads   – Memory  management/protec,on   – Locking   •  All  this  is  somewhat  mi,gated  through  libc  &   other  libraries  
  • 41. Threads   •  Heavy  weight  processes   – Slow  switching   – fork()  
  • 42. Threads   •  Heavy  weight  processes   – Slow  switching   – fork()   •  Green  threads   – Fast  switching,  difficult  to  implement   •  Na,ve  Locks?  
  • 43. Threads   •  Heavy  weight  processes   – Slow  switching   – fork()   •  Green  threads   – Fast  switching,  difficult  to  implement   •  Na,ve  Locks?   •  MxN  threads   – Even  more  difficult  to  implement  
  • 44. Threads   •  The  old  standby:  OS  Threads   •  No  support  for  stack  overflow   •  By  defini,on,  no  memory  protec,on  between   threads  
  • 48. Thin  Locks   public class PseudoSpinlock { private static final int LOCK_FREE = 0; private static final int LOCK_TAKEN = 1; public void lock() { //burn cycles while (cmpxchg(LOCK_TAKEN, &lock) == LOCK_TAKEN) { micropause(); //optional } } public void unlock() { int old = cmpxchg(LOCK_FREE, &lock); //guard against recursive locks assert(old == LOCK_TAKEN); } }
  • 49. Thin  Locks   •  Use  whatever  atomic  support  there  is  in  the   hardware  /  OS   •  Cheap  to  lock  and  unlock,  expensive  to  keep   locked  
  • 50. Fat  Locks   •  Use  OS  lock  support   •  Expensive  to  lock  and  unlock,  cheap  to  keep   locked   •  Need  for  more  advanced  synchroniza,on   mechanisms   – wait – notify
  • 51. Adap,ve  Behavior   •  Profile  based  transmuta,on  of  thin  locks  to  fat   locks     – …and  vice  versa   – Nothing  your  C  program  can  do  
  • 52. Adap,ve  Behavior   •  Profile  based  transmuta,on  of  thin  locks  to  fat   locks     – …and  vice  versa   – Nothing  your  C  program  can  do   •  Biased  locking  
  • 53. Adap,ve  Behavior   •  Profile  based  transmuta,on  of  thin  locks  to  fat   locks     – …and  vice  versa   – Nothing  your  C  program  can  do   •  Biased  locking   •  Thread  switching  heuris,cs  /  Cache  warmup  
  • 54. Adap,ve  Behavior   •  Constant  tension  between  OS  switching  and   Java  switching.   – One  example  of  a  JVM/OS  baRle  
  • 58. Na,ve  Memory  Tracking   HotSpot:     java –XX:NativeMemoryTracking=<summary|detail> Test jcmd <pid> VM.native_memory   JRockit:   USE_OS_MALLOC=0 TRACE_ALLOC_SITES=1 java Test jrcmd <pid> print_memusage
  • 60. Memory  Models   public class WhileLoop { //can be accessed by other threads private boolean finished; while (!finished) { do something… } }
  • 61. Memory  Models   public class WhileLoop { //can be accessed by other threads private boolean finished; boolean tmp = finished; while (!tmp) { do something… } }
  • 62. Memory  Models   public class WhileLoop { //can be accessed by other threads private volatile boolean finished; while (!finished) { do something… } }
  • 63. Memory  Models   volatile int x; int y; volatile boolean finished; x = 17; y = 4711; finished = true; if (finished) { System.err.println(x); System.err.println(y); }
  • 64. Memory  Models   volatile int x; int y; volatile boolean finished; x = 17; y = 4711; finished = true; if (finished) { System.err.println(x); System.err.println(y); }
  • 65. Memory  Models   public class GadgetHolder { private Gadget theGadget; public synchronized Gadget getGadget() { if (this.theGadget == null) { this.theGadget = new Gadget(); } return this.theGadget; } }
  • 66. Memory  Models   public class GadgetHolder { private Gadget theGadget; public Gadget getGadget() { if (this.theGadget == null) { synchronized(this) { if (this.theGadget == null) { this.theGadget = new Gadget(); } } } return this.theGadget; } }
  • 67. Memory  Models   public class GadgetHolder { private volatile Gadget theGadget; public Gadget getGadget() { if (this.theGadget == null) { synchronized(this) { if (this.theGadget == null) { this.theGadget = new Gadget(); } } } return this.theGadget; } }
  • 68. Memory  Models   public class GadgetMaker { public static Gadget theGadget = new Gadget(); }
  • 70. Taking  Control  of  the  OS  
  • 71. Taking  Control  of  the  OS   •  Taking  control  of  the  OS   •  Taking  control  of  the  na,ve  memory   •  Taking  control  of  the  C  heap  
  • 72. Taking  Control  of  the  OS   •  Taking  control  of  the  OS   •  Taking  control  of  the  na,ve  memory   •  Taking  control  of  the  C  heap   •  Well  you  can’t  really,  but  you  can  do  your  best  
  • 73. Is  the  JVM  an  OS?   •  JRockit  Virtual  Edi,on   •  Azul   •  Cloudius   •  Jnode   •  …    
  • 74. Is  the  JVM  an  OS?   •  JRockit  Virtual  Edi,on   •  Implemented  libc,  libraries  and  the  OS   – Not  much  required  for  a  single  process  Java  OS.   •  Finally,  the  Java  OS?  
  • 75. Is  the  JVM  an  OS?  
  • 76.
  • 77. Is  the  JVM  an  OS?  
  • 78. Is  the  JVM  an  OS?   •  Add  a  coopera,ve  aspect  to  thread  switching   •  Zero-­‐copy  networking  code   •  Reduce  cost  of  entering  OS   •  Balloon  driver   •  Runs  only  on  hypervisor  
  • 79. Pauseless  GC   •  Hope  that  a  lot  of  data  is  thread  local  and   remains  thread  local   – (it  usually  is)  
  • 80. Pauseless  GC   •  Hope  that  a  lot  of  data  is  thread  local  and   remains  thread  local   – (it  usually  is)   •  Use  one  large  global  heap  and  one  thread   local  heap  per  thread  
  • 81. Pauseless  GC   •  Hope  that  a  lot  of  data  is  thread  local  and   remains  thread  local   – (it  usually  is)   •  Use  one  large  global  heap  and  one  thread   local  heap  per  thread   •  If  thread  local  data  is  exposed  to  another   thread  –  promote  to  global  heap  
  • 82. Pauseless  GC   •  We  need  a  write  barrier     //x.field = y void checkWriteAccess(Object x, Object y) { if (x.isOnGlobalHeap() && !y.isOnGlobalHeap()) { GC.registerReferenceGlobalToLocal(x, y); } }  
  • 83. Pauseless  GC   •  …  and  a  read  barrier     //read x.field void checkReadAccess(Object x) { int myTid = getThreadId(); //if this object is thread local and //belongs to another thread, evacuate to global heap if (!x.isOnGlobalHeap() && !x.isInternalTo(myTid)) { x.evaculateToGlobalHeap(); //painful } }  
  • 84. Pauseless  GC   •  Barriers  have  to  extremely  fast,  or  everything   will  disappear  in  overhead  
  • 85. Pauseless  GC   •  Barriers  have  to  extremely  fast,  or  everything   will  disappear  in  overhead  
  • 86. Pauseless  GC   •  We  can,  because  we  own  and  implemented   the  thread  system  
  • 87. OS/JVM/Hardware  improvements   •  Threading   •  Locking   •  Na,ve  memory  usage   •  Virtual  address  memory  usage/exhaus,on   •  Stack  overflows   •  Page  protec,on  
  • 88. OS/JVM/Hardware  improvements   •  Trap  on  overflow   •  Read  barriers   •  Performance  counters   – IP  samples   – Cache  misses   – Userland,  please   •  …  
  • 90. Conclusion     •  It  doesn’t  hurt  to  know  what’s  inside  your   execu,on  environment   •  In  the  future  –  the  distance  between   hardware,  OS  and  run,me  will  decrease  or   disappear  altogether.