Successfully reported this slideshow.
Your SlideShare is downloading. ×

The Cog VM evolution

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
CogVM
Evolution
Clément Béra
Thursday, August 25, 16
CogVM ?
• Smalltalk virtual machine
• DefaultVM for
• Pharo
• Squeak
• Newspeak
• Cuis
Thursday, August 25, 16
Cog Philosophy
• Open source (MIT)
• Simple
• Is the optimization / feature worth the
added complexity ?
• Cross-Platform ...

YouTube videos are no longer supported on SlideShare

View original on YouTube

Upcoming SlideShare
Pharo Update
Pharo Update
Loading in …3
×

Check these out next

1 of 64 Ad

The Cog VM evolution

Download to read offline

The Cog VM evolution
Video: https://youtu.be/Gi0WiIxvJ60

Thu, August 25, 11:30am – 12:00pm

First Name: Clement
Last Name: Bera
Email: bera.clement@gmail.com
Title: The Cog VM evolution
Type: Talk

Abstract: In 2008, the Squeak VM repository made by Dan Ingalls was
forked to give birth to the high-performance Cog VM, which is now the
default VM for multiple Smalltalk dialects such as Pharo, Squeak or
Cuis. Since the fork, new features and performance enhancements have
been introduced every year. This talk sums up all the main features
and main performance tweaks that were added to the Cog VM in
chronological order from 2008 to today. The focus is on the execution
engine: Memory management, interpretation, JIT compilation and FFI.
The talk lastly discusses the current work in-progress and short-term
future work.

Bio: Clément Béra is a PhD student working on virtual machines for
object oriented languages at Inria, Lille. He is now focusing on
runtime optimisations for the Cog virtual machine and its Smalltalk
clients.

The Cog VM evolution
Video: https://youtu.be/Gi0WiIxvJ60

Thu, August 25, 11:30am – 12:00pm

First Name: Clement
Last Name: Bera
Email: bera.clement@gmail.com
Title: The Cog VM evolution
Type: Talk

Abstract: In 2008, the Squeak VM repository made by Dan Ingalls was
forked to give birth to the high-performance Cog VM, which is now the
default VM for multiple Smalltalk dialects such as Pharo, Squeak or
Cuis. Since the fork, new features and performance enhancements have
been introduced every year. This talk sums up all the main features
and main performance tweaks that were added to the Cog VM in
chronological order from 2008 to today. The focus is on the execution
engine: Memory management, interpretation, JIT compilation and FFI.
The talk lastly discusses the current work in-progress and short-term
future work.

Bio: Clément Béra is a PhD student working on virtual machines for
object oriented languages at Inria, Lille. He is now focusing on
runtime optimisations for the Cog virtual machine and its Smalltalk
clients.

Advertisement
Advertisement

More Related Content

Slideshows for you (20)

Similar to The Cog VM evolution (20)

Advertisement
Advertisement

The Cog VM evolution

  1. 1. CogVM Evolution Clément Béra Thursday, August 25, 16
  2. 2. CogVM ? • Smalltalk virtual machine • DefaultVM for • Pharo • Squeak • Newspeak • Cuis Thursday, August 25, 16
  3. 3. Cog Philosophy • Open source (MIT) • Simple • Is the optimization / feature worth the added complexity ? • Cross-Platform (Processors, OS, 32/64 bits) Thursday, August 25, 16
  4. 4. Execution engine • VM • Execution engine • Plugins: graphics, file, etc. Thursday, August 25, 16
  5. 5. Execution engine • Interpreter • JIT • Memory Manager (including GC) Thursday, August 25, 16
  6. 6. Evolution • User and Customer driven • Where did we start ? • What problems did we solve ? Thursday, August 25, 16
  7. 7. Starting blocks • InterpreterVM • Made by Dan Ingalls Team • Simple Interpreter • Spaghetti stack • Smart but simple Memory Manager Thursday, August 25, 16
  8. 8. Performance ! Short-term delivery Performance for 3D application Thursday, August 25, 16
  9. 9. Performance ! Short-term delivery Performance for 3D application • Fast Interpreter Thursday, August 25, 16
  10. 10. • Context-to-stack Mapping • 85% of context allocation removed • No copying of arguments • New hash logic • Primitive function caching StackVM Thursday, August 25, 16
  11. 11. Issue • Closure implementation • No temporaries • BlockAlreadyEvaluated error • Non obvious bugs • New implementation Thursday, August 25, 16
  12. 12. 0 2 4 6 8 10 12 14 Interpreter Stack Cog V1 Cog V2 Spur Sista Binary Tree benchmark Thursday, August 25, 16
  13. 13. More Performance ! Short-term delivery Performance for 3D application Thursday, August 25, 16
  14. 14. More Performance ! Short-term delivery Performance for 3D application • First JIT compiler Thursday, August 25, 16
  15. 15. CogVM • x86 back-end • Simple machine code generation • Except inline caches Thursday, August 25, 16
  16. 16. Binary Tree benchmark 0 2 4 6 8 10 12 14 Interpreter Stack Cog V1 Cog V2 Spur Sista Thursday, August 25, 16
  17. 17. JIT Abstractions V3 Object Representation SimpleStackCogit Cogit Implementation x86 Machine back-end Thursday, August 25, 16
  18. 18. Yet More Performance ! Short-term delivery Performance for 3D application Thursday, August 25, 16
  19. 19. Yet More Performance ! Short-term delivery Performance for 3D application • Second JIT compiler Thursday, August 25, 16
  20. 20. CogVM • Machine code generation • Linear scan register allocation • Avoids many stack operations • Register-based calling convention Thursday, August 25, 16
  21. 21. Binary Tree benchmark 0 2 4 6 8 10 12 14 Interpreter Stack Cog V1 Cog V2 Spur Sista Thursday, August 25, 16
  22. 22. JIT Abstractions V3 Object Representation SimpleStackCogit StackToRegisterMappingCogit Cogit Implementation x86 Machine back-end Thursday, August 25, 16
  23. 23. Newspeak support ? Newspeak is Smalltalk-like New kind of sends Thursday, August 25, 16
  24. 24. Newspeak support ? • Multiple bytecode set support • Newspeak specific operations • Interpreter • Machine code generation Thursday, August 25, 16
  25. 25. 64 bits ? Images larger than 1 or 2 Gb ? Moving objects during FFI call-backs ? Even more performance ! Ephemerons ? Become is so slow it cannot be used. Thursday, August 25, 16
  26. 26. 64 bits ? Images larger than 1 or 2 Gb ? Moving objects during FFI call-backs ? Even more performance ! Ephemerons ? Become is so slow it cannot be used. Short-term delivery Thursday, August 25, 16
  27. 27. 64 bits ? Images larger than 1 or 2 Gb ? Moving objects during FFI call-backs ? Even more performance ! Ephemerons ? Become is so slow it cannot be used. Short-term delivery • New Memory Manager Thursday, August 25, 16
  28. 28. Spur Memory Manager • Class-table (efficient caches and compactness) • Efficient scavenging • Fast become • New object layouts (Ephemerons, ShortArrays) • Memory representation 64-bits compatible • Pinned objects • Segmented Memory Thursday, August 25, 16
  29. 29. Binary Tree benchmark 0 2 4 6 8 10 12 14 Interpreter Stack Cog V1 Cog V2 Spur Sista Thursday, August 25, 16
  30. 30. JIT Abstractions V3 Spur32 Spur64 Object Representation SimpleStackCogit StackToRegisterMappingCogit Cogit Implementation x86 Machine back-end V3 Spur32 Spur64 Object Representation x86 Machine back-end 32 bits 64 bits Thursday, August 25, 16
  31. 31. Raspberry Pi performance ? Scratch support Thursday, August 25, 16
  32. 32. • ARMv6 support Raspberry Pi performance ? Scratch support Thursday, August 25, 16
  33. 33. ARMv6 support • JIT ARMv6 back-end • JIT abstraction over literal management • JIT abstraction over CISC / RISC Thursday, August 25, 16
  34. 34. JIT Abstractions V3 Spur32 Spur64 Object Representation SimpleStackCogit StackToRegisterMappingCogit Cogit Implementation x86 Machine back-end V3 Spur32 Spur64 Object Representation x86 ARMv6 MIPSEL Machine back-end 32 bits 64 bits Inline Outline Literal Manager Thursday, August 25, 16
  35. 35. Ryan (contributor) Working with the DartVM Dart runs on more platform than Newspeak. Thursday, August 25, 16
  36. 36. Ryan (contributor) Working with the DartVM Dart runs on more platform than Newspeak. • MIPSEL support Thursday, August 25, 16
  37. 37. JIT Abstractions V3 Spur32 Spur64 Object Representation SimpleStackCogit StackToRegisterMappingCogit Cogit Implementation x86 Machine back-end V3 Spur32 Spur64 Object Representation x86 ARMv6 MIPSEL Machine back-end 32 bits 64 bits Inline Outline Literal Manager Thursday, August 25, 16
  38. 38. 64 bits support ? 64 bits library binding Heap over 2Gb Thursday, August 25, 16
  39. 39. 64 bits support ? 64 bits library binding Heap over 2Gb • x64 support • Immediate float Thursday, August 25, 16
  40. 40. JIT Abstractions V3 Spur32 Spur64 Object Representation Inline Outline Literal Manager SimpleStackCogit StackToRegisterMappingCogit Cogit Implementation x86 ARMv6 MIPSEL x64 Machine back-end 32 bits 64 bits Thursday, August 25, 16
  41. 41. Yet even more performance ! Computation lasting 3 to 6 hours Thursday, August 25, 16
  42. 42. Yet even more performance ! Computation lasting 3 to 6 hours • Speculative optimizations Thursday, August 25, 16
  43. 43. SistaVM • The program introspects • Optimize the code for performance • Deoptimize when it took incorrect decisions Thursday, August 25, 16
  44. 44. Issues • Bytecode set • Literal mutability • Closure implementation Thursday, August 25, 16
  45. 45. Bytecode set limitations ? Code generator tools Thursday, August 25, 16
  46. 46. Sista bytecode set • Lifting encoding limitations • Encode instructions for the Sista / Lowcode Thursday, August 25, 16
  47. 47. Efficient modification trackers ? Literal inconsistency ? Thursday, August 25, 16
  48. 48. • Read-only objects • IWST talk this afternoon • Hopefully allows more compiler optimizations Efficient modification trackers ? Literal inconsistency ? Thursday, August 25, 16
  49. 49. Closure implementation • Method and closure get more similar • Simplifies part of theVM • Simplifies the runtime compiler Thursday, August 25, 16
  50. 50. Integration • Closed alpha version • Integrating dependencies: • Bytecode set integrated • Read-only objects integrated (but disabled) • Closure implementation in progress Thursday, August 25, 16
  51. 51. Binary Tree benchmark 0 2 4 6 8 10 12 14 Interpreter Stack Cog V1 Cog V2 Spur Sista Thursday, August 25, 16
  52. 52. JIT Abstractions V3 Spur32 Spur64 Object Representation Inline Outline Literal Manager SimpleStackCogit StackToRegisterMappingCogit RegisterAllocatingCogit SistaCogit Cogit Implementation x86 ARMv6 MIPSEL x64 Machine back-end 32 bits 64 bits Thursday, August 25, 16
  53. 53. Image compaction ? Sometimes, large images when saving Thursday, August 25, 16
  54. 54. Image compaction ? Sometimes, large images when saving • Better compactor Thursday, August 25, 16
  55. 55. Pauses ? 0.5 second freezes in UI application Thursday, August 25, 16
  56. 56. Pauses ? 0.5 second freezes in UI application • Incremental GC Thursday, August 25, 16
  57. 57. Many hidden parts ... Thursday, August 25, 16
  58. 58. • C generated from Slang • Many were fixed • Towards compilation with -WAll -WError C compiler warning ? Thursday, August 25, 16
  59. 59. • LargeInteger plugin more efficient • Computation moved from 8bits to 32 bits • Different compilation flags Faster arithmetic ? Thursday, August 25, 16
  60. 60. • Slang-to-C compiler • Many improvements • Type inference Slang ? Thursday, August 25, 16
  61. 61. Contribution Thursday, August 25, 16
  62. 62. CogVM team • Started with Eliot Miranda • Many more contributors now: • Tim Rowledge • Clément Béra (myself) • Nicolas Cellier • Fabio Niephaus & Tim Felgentreff • Ryan Macnak Thursday, August 25, 16
  63. 63. Conclusion • Lots of new features and improvements over years • A lot more is incoming • If you want to support, talk to us ! • ARMv8 ? • Incremental GC ? • Performance (escaping, floats) ? Thursday, August 25, 16

×