Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
VIRTUAL     MACHINESFITC Amsterdam 2013 | Joa Ebert | 02/19/2013
JOA EBERT   @joa
AgendaWHAT is a virtual machine?WHY do we need them?HOW do they work?WHERE are the issues?
WHATis a virtual machine?
„A machine is atool that consistsof one or moreparts, and usesenergy to achievea particular goal.“             WIKIPEDIA
„A virtual machine (VM)is a simulation of a machine(abstract or real) that isusually different from thetarget machine (whe...
Programmers really loveto make it complicated ...
SYSTEM    PROCESSVIRTUAL   VIRTUAL
CODE       EXECUTION  MEMORY       MULTIMANAGEMENT   THREADING
WHYdo we need them?
PLATFORM AGNOSTIC
PROFILING ANDDEBUGGING INPRODUCTION
SANDBOXINGAND SECURITY
OPTIMIZATION
EXISTINGPROGRAMSRUN FASTER WHENTHE VM GETSFASTER.MORE SPACE FORINNOVATION.
HOWdo they work?
CODEEXECUTION
FEEDBACK ABOUT        TYPES AND HOT        SPOTS           NATIVE   VM       CODE                      RUNTIMECODE        ...
HIDDENCLASSESfunction Person(age, gender) {  this.age = age  this.gender = gender}var joa = new Person(26, „male“)
Personfunction Person(age, gender) {  this.age = age  this.gender = gender}var joa = new Person(26, „male“)
age              Person         Person   26                         agefunction Person(age, gender) {  this.age = age  thi...
age            gender              Person         Person            Person   26                         age               ...
POLYMORPHICINLINECACHESfunction isAdult(person) {  return person.age() > 17}
POLYMORPHICINLINECACHESfunction isAdult(person) {  return person.age() > 17}
isAdult   lookup   Person::age...                return this.ageage()...
isAdult   Person::age...       if not Personage()       lookup()...          return this.age
isAdult   PIC stub         Person::age...       if Person        if not Personage()      Person::age()    lookup()...     ...
isAdult   PIC stub...       if Personage()     return this.age...       else if Robot           Robot::age()          else...
SPECULATIVEOPTIMIZATIONS
STATIC   DYNAMICTYPING    TYPING
def using[I <: { def close() }, O](stream: I)(f: I ⇒ O): O =  try {    f(stream)  } finally {    stream.close()  }STRUCTUR...
mem ber thos e PICs?                              Redef using[I <: { def close() }, O](stream: I)(f: I ⇒ O): O =  try {   ...
while(true) {    computeTheAnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything();}             DEOPTIMIZATION       ...
DEBUG   RELEASE
oracle.com/us/technologies/java/java7-renaissance-vm-428200.pdf
GARBAGECOLLECTION
CONSERVATIVE   PRECISE
0x00 0x00 0x00 0x10 0x00 0x00 0x00 0x000x80 0x00 0x00 0x01 0x80 0x00 0x00 0x040xde 0xad 0xbe 0xef 0x00 0x10 0x00 0x00     ...
0x00000010 0x00000000    0x80000001 0x80000004    0xdeadbeef 0x00100000MEMORY (DWORD ALIGNED)
0x00000010 0x00000000    0x80000001 0x80000004    0xdeadbeef 0x00100000MEMORY (DWORD ALIGNED)
0x00000010 0x00000000    0x80000001 0x80000004    0xdeadbeef 0x00100000MEMORY (DWORD ALIGNED)
0x00000010 0x00000000    0x80000001 0x80000004    0xdeadbeef 0x00100000MEMORY (DWORD ALIGNED)
0x00000010 0x00000000    0x80000001 0x80000004    0xdeadbeef 0x00100000MEMORY (DWORD ALIGNED)
Conservative GCs suck!
1      1REFERENCECOUNTING
Reference counting sucks!
COPYINGCOLLECTOR
FROM-SpaceTO-Space
FROM-SpaceTO-Space
TO-SpaceFROM-Space
Copying collectors are really cool but for a8GB heap they require 16GB total memory!
MARK &COMPACT
Young      Survivors      Old Generation               GenerationEPHEMERAL GC
THREADING
CONCURRENCY   PARALLELISM
SHARED   ISOLATED
WHEREare the issues?
ALL VMS ARECREATEDEQUAL.
ALL VMS ARECREATEDEQUAL. NOT.
JAVASCRIPTIS NOTJAVASCRIPT
J   A   V   AIS NOTJ   A   V   A
PEOPLE MAKE ANARGUMENT FOR APARTICULAR VM„Don‘t do this“ IS NOTALWAYS TRUE
STARTUP COSTSARE PAINFULFOR SHORTRUNNINGAPPLICATIONS
TODAYSADVICEIS NOTTRUE FORTOMORROW
BENCHMARKINGIS REALLY HARD.MICROBENCHMARKSARE EVEN MOREUSELESS.
WITH GREATPOWERCOME GREATEXPLOITS
GC DOESNOT COMEFOR FREE
Is your GCpredictable?
MEMORY   vs. SPEED
Write Code for the Future. Don‘t try to outsmart  todays technology.
Always Remember:
Always Remember:Math kicks everyones ass!
O(1) O(log n)    O(n)O(n log n)   O(n²)   O(n³)     ...   O(x n)   O(n!)
THANK                            YOU                                               Enj oy the party tonight andFITC Amster...
Virtual Machines
Virtual Machines
Virtual Machines
Virtual Machines
Virtual Machines
Virtual Machines
Virtual Machines
Virtual Machines
Virtual Machines
Virtual Machines
Virtual Machines
Upcoming SlideShare
Loading in …5
×

Virtual Machines

3,137 views

Published on

From the moment you open up a website in your browser multiple virtual machines (VMs) are at work. The server generating the website might use Java, your browser executes JavaScript and maybe there is some Flash content running — with everything being executed in a VM.

Virtual machines became increasingly important and popular after Google’s introduction of V8. We expect our code to run fast but let’s step back for a second and see how these complicated pieces of software work. With a better understanding of how your daily ActionScript or JavaScript code is being executed you might start coding a little different.

Join Joa and dive deep into the the world of virtual machines. Learn about different garbage collection strategies and understand why those beasts behave the way they do.

Published in: Technology

Virtual Machines

  1. 1. VIRTUAL MACHINESFITC Amsterdam 2013 | Joa Ebert | 02/19/2013
  2. 2. JOA EBERT @joa
  3. 3. AgendaWHAT is a virtual machine?WHY do we need them?HOW do they work?WHERE are the issues?
  4. 4. WHATis a virtual machine?
  5. 5. „A machine is atool that consistsof one or moreparts, and usesenergy to achievea particular goal.“ WIKIPEDIA
  6. 6. „A virtual machine (VM)is a simulation of a machine(abstract or real) that isusually different from thetarget machine (where it isbeing simulated on).“ WIKIPEDIA
  7. 7. Programmers really loveto make it complicated ...
  8. 8. SYSTEM PROCESSVIRTUAL VIRTUAL
  9. 9. CODE EXECUTION MEMORY MULTIMANAGEMENT THREADING
  10. 10. WHYdo we need them?
  11. 11. PLATFORM AGNOSTIC
  12. 12. PROFILING ANDDEBUGGING INPRODUCTION
  13. 13. SANDBOXINGAND SECURITY
  14. 14. OPTIMIZATION
  15. 15. EXISTINGPROGRAMSRUN FASTER WHENTHE VM GETSFASTER.MORE SPACE FORINNOVATION.
  16. 16. HOWdo they work?
  17. 17. CODEEXECUTION
  18. 18. FEEDBACK ABOUT TYPES AND HOT SPOTS NATIVE VM CODE RUNTIMECODE INTERPRETER
  19. 19. HIDDENCLASSESfunction Person(age, gender) { this.age = age this.gender = gender}var joa = new Person(26, „male“)
  20. 20. Personfunction Person(age, gender) { this.age = age this.gender = gender}var joa = new Person(26, „male“)
  21. 21. age Person Person 26 agefunction Person(age, gender) { this.age = age this.gender = gender}var joa = new Person(26, „male“)
  22. 22. age gender Person Person Person 26 age age0x80f54644 genderfunction Person(age, gender) { this.age = age this.gender = gender}var joa = new Person(26, „male“)
  23. 23. POLYMORPHICINLINECACHESfunction isAdult(person) { return person.age() > 17}
  24. 24. POLYMORPHICINLINECACHESfunction isAdult(person) { return person.age() > 17}
  25. 25. isAdult lookup Person::age... return this.ageage()...
  26. 26. isAdult Person::age... if not Personage() lookup()... return this.age
  27. 27. isAdult PIC stub Person::age... if Person if not Personage() Person::age() lookup()... else if Robot Robot::age() return this.age else lookup()
  28. 28. isAdult PIC stub... if Personage() return this.age... else if Robot Robot::age() else lookup()
  29. 29. SPECULATIVEOPTIMIZATIONS
  30. 30. STATIC DYNAMICTYPING TYPING
  31. 31. def using[I <: { def close() }, O](stream: I)(f: I ⇒ O): O = try { f(stream) } finally { stream.close() }STRUCTURAL TYPING
  32. 32. mem ber thos e PICs? Redef using[I <: { def close() }, O](stream: I)(f: I ⇒ O): O = try { f(stream) } finally { stream.close() }STRUCTURAL TYPING
  33. 33. while(true) { computeTheAnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything();} DEOPTIMIZATION AND OSR
  34. 34. DEBUG RELEASE
  35. 35. oracle.com/us/technologies/java/java7-renaissance-vm-428200.pdf
  36. 36. GARBAGECOLLECTION
  37. 37. CONSERVATIVE PRECISE
  38. 38. 0x00 0x00 0x00 0x10 0x00 0x00 0x00 0x000x80 0x00 0x00 0x01 0x80 0x00 0x00 0x040xde 0xad 0xbe 0xef 0x00 0x10 0x00 0x00 MEMORY
  39. 39. 0x00000010 0x00000000 0x80000001 0x80000004 0xdeadbeef 0x00100000MEMORY (DWORD ALIGNED)
  40. 40. 0x00000010 0x00000000 0x80000001 0x80000004 0xdeadbeef 0x00100000MEMORY (DWORD ALIGNED)
  41. 41. 0x00000010 0x00000000 0x80000001 0x80000004 0xdeadbeef 0x00100000MEMORY (DWORD ALIGNED)
  42. 42. 0x00000010 0x00000000 0x80000001 0x80000004 0xdeadbeef 0x00100000MEMORY (DWORD ALIGNED)
  43. 43. 0x00000010 0x00000000 0x80000001 0x80000004 0xdeadbeef 0x00100000MEMORY (DWORD ALIGNED)
  44. 44. Conservative GCs suck!
  45. 45. 1 1REFERENCECOUNTING
  46. 46. Reference counting sucks!
  47. 47. COPYINGCOLLECTOR
  48. 48. FROM-SpaceTO-Space
  49. 49. FROM-SpaceTO-Space
  50. 50. TO-SpaceFROM-Space
  51. 51. Copying collectors are really cool but for a8GB heap they require 16GB total memory!
  52. 52. MARK &COMPACT
  53. 53. Young Survivors Old Generation GenerationEPHEMERAL GC
  54. 54. THREADING
  55. 55. CONCURRENCY PARALLELISM
  56. 56. SHARED ISOLATED
  57. 57. WHEREare the issues?
  58. 58. ALL VMS ARECREATEDEQUAL.
  59. 59. ALL VMS ARECREATEDEQUAL. NOT.
  60. 60. JAVASCRIPTIS NOTJAVASCRIPT
  61. 61. J A V AIS NOTJ A V A
  62. 62. PEOPLE MAKE ANARGUMENT FOR APARTICULAR VM„Don‘t do this“ IS NOTALWAYS TRUE
  63. 63. STARTUP COSTSARE PAINFULFOR SHORTRUNNINGAPPLICATIONS
  64. 64. TODAYSADVICEIS NOTTRUE FORTOMORROW
  65. 65. BENCHMARKINGIS REALLY HARD.MICROBENCHMARKSARE EVEN MOREUSELESS.
  66. 66. WITH GREATPOWERCOME GREATEXPLOITS
  67. 67. GC DOESNOT COMEFOR FREE
  68. 68. Is your GCpredictable?
  69. 69. MEMORY vs. SPEED
  70. 70. Write Code for the Future. Don‘t try to outsmart todays technology.
  71. 71. Always Remember:
  72. 72. Always Remember:Math kicks everyones ass!
  73. 73. O(1) O(log n) O(n)O(n log n) O(n²) O(n³) ... O(x n) O(n!)
  74. 74. THANK YOU Enj oy the party tonight andFITC Amsterdam 2013 | Joa Ebert | 02/19/2013 b on voyage!

×