Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

Improving Pharo Snapshots

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Prochain SlideShare
Object-oriented concepts
Object-oriented concepts
Chargement dans…3
×

Consultez-les par la suite

1 sur 43 Publicité

Plus De Contenu Connexe

Similaire à Improving Pharo Snapshots (20)

Plus par ESUG (20)

Publicité

Plus récents (20)

Improving Pharo Snapshots

  1. 1. Improving Pharo Snapshots P. Tesone - G. Polito - N. Palumbo - ESUG’22 @tesonep @guillep @noTwitter guillermo.polito@univ-lille.fr pablo.tesone@inria.fr nahuel.palumbo@inria.fr
  2. 2. 2022 VM+ Team 2
  3. 3. • Numbers • Characters • Strings • Arrays • Closures • Classes • Methods • … Everythingis an Object
  4. 4. • Numbers • Characters • Strings • Arrays • Closures • Classes • Methods • … Everythingis an Object
  5. 5. • Numbers • Characters • Strings • Arrays • Closures • Classes • Methods • … Everythingis an Object
  6. 6. • Numbers • Characters • Strings • Arrays • Closures • Classes • Methods • … Everythingis an Object
  7. 7. • Numbers • Characters • Strings • Arrays • Closures • Classes • Methods • … Everythingis an Object
  8. 8. • Numbers • Characters • Strings • Arrays • Closures • Classes • Methods • … Lots of Objects
  9. 9. • Numbers • Characters • Strings • Arrays • Closures • Classes • Methods • … Lots of Objects Lots of Stress
  10. 10. • GC Stress • Autocompletion Stress • Search Stress • Spotter Stress • Startup Stress Lots of Objects Lots of Stress
  11. 11. Large Image Support • https://github.com/pharo-project/largeImages • MIT Licenced
  12. 12. Large Image Support: Highlights • Generator based searches • Spotter • Code Completion • GC Fine Tuning API generator ^ generator ifNil: [ generator := Generator on: [ :g | self entriesDo: [ :entry | (self acceptsEntry: entry) ifTrue: [ g yield: entry ] ] ] ]
  13. 13. GC Fine Tuning • Con fi gure • Eden Size • Full GC Ratio • Growth Headroom • Shrink Threshold GCConfiguration readFromVM fullGCRatio: 1.0; activeDuring: [ “something" ].
  14. 14. • Numbers • Characters • Strings • Arrays • Closures • Classes • Methods • … Lots of Objects
  15. 15. • Numbers • Characters • Strings • Arrays • Closures • Classes • Methods • … Images = Heap Snapshots .image save load Heap
  16. 16. Snapshot Current Design Points • Bootstrap once, then mutate • Portable • Object References are pointers • Load code • Create Objects • Run your app • Maybe GC! • Repeat .image .image Heap
  17. 17. But it could be better… • VM startup is bound by disk! • Large heaps take long to load/save • 3-4GB heaps = seconds to GC • pauses • long pauses • Load code • Create Objects • Run your app • Maybe GC! • Repeat .image .image Heap
  18. 18. Snapshots vs Runtime Memory Mismatch App and System Objects Threads State as Objects JIT Machine Code Thread Stacks New Objects Old Objects .image
  19. 19. Current Loading Snapshot to Memory JIT Machine Code Thread Stacks New Objects Old Objects Direct Mapping Rebuild Empty Empty .image App and System Objects Threads State as Objects Start with a cold VM, startup is slow
  20. 20. Reference Swizzling • Traverse the heap to remap old references by delta • Slow for large heaps (2/4GB) Hot Methods Machine Code Process 1 Thread Stacks New Objects Old Objects Hot Methods Machine Code Process 2 Thread Stacks New Objects Old Objects R e m a p p e d delta
  21. 21. Current Snapshot to Disk JIT Machine Code Thread Stacks New Objects Old Objects App and System Objects Threads State as Objects .image
  22. 22. Current Snapshot to Disk JIT Machine Code Thread Stacks New Objects Old Objects 1.Discard App and System Objects Threads State as Objects .image
  23. 23. JIT Machine Code Thread Stacks New Objects Old Objects 1.Discard 2. Save as objects App and System Objects Threads State as Objects .image Current Snapshot to Disk
  24. 24. JIT Machine Code Thread Stacks New Objects Old Objects 1.Discard 2. Save as objects 3. Promote to old App and System Objects Threads State as Objects .image Current Snapshot to Disk
  25. 25. JIT Machine Code Thread Stacks New Objects Old Objects 1.Discard 2. Save as objects 3. Promote to old 4. Save to Disk App and System Objects Threads State as Objects .image Current Snapshot to Disk
  26. 26. JIT Machine Code Thread Stacks New Objects Old Objects 1.Discard 2. Save as objects 3. Promote to old 4. Save to Disk Discards all optimisations: slow shutdown => slow startup App and System Objects Threads State as Objects .image Current Snapshot to Disk
  27. 27. Goals • Faster loading • Faster snapshot • Faster Multi-GB Heaps • Load code • Create Objects • Run your app • Maybe GC! • Repeat .image .image Heap
  28. 28. Towards a Multi-file Snapshot Format JIT Machine Code Thread Stacks New Objects Old Objects JIT Machine Code Thread Stacks New Objects Old Objects Direct Mapping .image • System memory mapping • Minimize Swizzling • Lazy loading of memory segments
  29. 29. Multiple Memory Segments JIT Machine Code Thread Stacks New Objects Old Objects JIT Machine Code Thread Stacks New Objects Old Objects Direct Mapping .image • Independently and lazy loadable • Independently storable Old Objects’ Old Objects’
  30. 30. New Memory Segments JIT Machine Code Thread Stacks New Objects Old Objects JIT Machine Code Thread Stacks New Objects Old Objects Direct Mapping .image • Reduced garbage collection pressure • Great for opaque objects, and rarely changing objects (code, literals…) Perm Objects Perm Objects
  31. 31. Semi-permanent Heap Segments Heap
  32. 32. Separating Permanent Objects • Permanent objects are roots • But not all of them are roots • We don’t want to iterate all permanent objects!
  33. 33. Maintaining a Remembered Set • Get the real roots in a remembered set • Updated with a write barrier and cleaned at GC
  34. 34. Semi-permanent Object Selection
  35. 35. Bad Semi-permanent Object Selection Worst case: all permanent are remembered (!!)
  36. 36. What objects should be permanent?
  37. 37. What objects should be permanent? How to minimise remembered objects?
  38. 38. Pitfalls of Semi-permanent Object Selection • The remembered set can explode easily. E.g., • Objects that reference nil, true, false are always remembered • If you make a class permanent • => you probably want to make its method dictionary too • => and its methods, and literals • => and …
  39. 39. Potential: GC cut by half • For production Apps! • Some Heuristics: • Code (+related) is semi-permanent • Collections go with their inner array • Association values are not (!!) Relative Speedups
  40. 40. Automatic Object Selection via Simulations • Estimate • permanent segment size • remembered set size • Understand the leaking reasons • And extract better heuristics for production code (e.g., better move all classes with all method dictionaries…)
  41. 41. Future Perspectives • Sharing permanent immutable objects, copy on write • Scaling multi-process applications • Application-speci fi c permanent object selection JIT Machine Code Thread Stacks New Objects Old Objects Perm Objects JIT Machine Code Thread Stacks New Objects Old Objects JIT Machine Code Thread Stacks New Objects Old Objects
  42. 42. We are hiring! • We have • Engineer Positions • Phd Positions • Keywords: Compilers, Interpreters, Memory Management, Security • Come talk to us! 42
  43. 43. Conclusion • Multi- fi le snapshot format • Permanent Objects and Selection • 2x GC improvements • Load code • Create Objects • Run your app • Maybe GC! • Repeat .image .image JIT Machine Code Thread Stacks New Objects Old Objects Perm Objects Relative Speedups

×