Object swapping issues and the imagesegment implementation

709 views

Published on

Presentation of the research paper entitled "Experiments with a Fast Object Swapper" in Smalltalks 2010, Concepción del Uruguay, Argentina.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Object swapping issues and the imagesegment implementation

  1. 1. Object Swapping Issues and the ImageSegment implementation I n g . m a r i a n o m a rt i n e z p e c k m a r i a n o p e c k @ g m a i l . c o m 1Saturday, November 13, 2010
  2. 2. The context 2Saturday, November 13, 2010
  3. 3. The context 2Saturday, November 13, 2010
  4. 4. The context 2Saturday, November 13, 2010
  5. 5. The context 2Saturday, November 13, 2010
  6. 6. The context 2Saturday, November 13, 2010
  7. 7. Problem Use more memory than needed. Make OOP languages unsuitable for memory limited devices. Existence of unused but referenced objects. 3Saturday, November 13, 2010
  8. 8. The context In OOP primary memory is represented by an object graph Z X Y A B C D E F G H I J K L 4Saturday, November 13, 2010
  9. 9. Garbage Collector Only collects objects that nobody else points to. Z X Y A B C D E F G H I J K L 5Saturday, November 13, 2010
  10. 10. Garbage Collector Only collects objects that nobody else points to. Z X Y A B C D E F G H I J K L 5Saturday, November 13, 2010
  11. 11. Garbage Collector Only collects objects that nobody else points to. Z X Y A B C D E F G H I J K L 5Saturday, November 13, 2010
  12. 12. Garbage Collector Only collects objects that nobody else points to. Z X Y A B C D E F G H I J K L 5Saturday, November 13, 2010
  13. 13. But...what happens with referenced yet unused objects? Z X Y A B C D E F G H I J K L 6Saturday, November 13, 2010
  14. 14. Idea Swap out (not remove) unused objects to disk. Automatically load them back when needed. 7Saturday, November 13, 2010
  15. 15. There are related works...but no one solves all the problems 8Saturday, November 13, 2010
  16. 16. Main challenges Not to use more memory than the one released by swapping. Low overhead penalty. Group objects in an smart way. 9Saturday, November 13, 2010
  17. 17. Key aspects Mark and trace unused/used objects at runtime. The usage of proxies. Group unused objects (subgraphs). 10Saturday, November 13, 2010
  18. 18. Why we need to group objects? Because if we replace each object by a proxy, we release little memory. We want to replace a whole group by one or a few proxies. 11Saturday, November 13, 2010
  19. 19. Why subgraphs? Group of objects that are used (or not used) together. We need few proxies (for the roots) for several objects. 12Saturday, November 13, 2010
  20. 20. Experiments done Modify Smalltalk VM to mark and trace objects usage. Visualize objects and memory usage. Take statistics from different scenarios. 13Saturday, November 13, 2010
  21. 21. deployed web application example 14Saturday, November 13, 2010
  22. 22. deployed web application example Used Unused Amount of objects 4% 96% 14Saturday, November 13, 2010
  23. 23. deployed web application example Used Unused Used Unused Amount of objects Amount of memory 4% 15% 85% 96% 14Saturday, November 13, 2010
  24. 24. Swapping steps and challenges 1.Identify sets of objects and serialize them. Problems: cycles, speed, etc. 2.Write the serialized objects into a file. Problems: file format, encoding, speed, etc. 3. Load the objects from a file. Problems: class reshape, avoid duplicates, speed, etc. 15Saturday, November 13, 2010
  25. 25. Subgraphs Roots Inner Shared External X Z Y Subgraph to process A B C (Root) (Root) (Root) D E F G H I J K L 16Saturday, November 13, 2010
  26. 26. More Should shared objects be problems included or not? GC moves objects. Roots Inner Shared External Pointers update. Z X Y Class changes. Subgraph to process A B C Recreate and reinitialize (Root) (Root) (Root) objects. D E F G H Code executed after loading. I J K L Special objects. 17Saturday, November 13, 2010
  27. 27. ImageSegmentSaturday, November 13, 2010
  28. 28. ImageSegment basis Only write/swap roots and inner objects. Shared objects are NOT swapped. Keep an array in memory for the shared objects. Update object pointers to point to a relative address inside the arrays (offset). Roots are replaced by proxies. Uses GC facilities to detect shared objects.Saturday, November 13, 2010
  29. 29. The goal A B C Input -- Output D E F G H I J K LSaturday, November 13, 2010
  30. 30. The goal P1 P2 P3 Input -- Output D F G J KSaturday, November 13, 2010
  31. 31. aMessage The goal P1 P2 P3 Input -- Output D F G J KSaturday, November 13, 2010
  32. 32. The goal A B C Input -- Output D E F G H I J K LSaturday, November 13, 2010
  33. 33. Simple exampleSaturday, November 13, 2010
  34. 34. Subgraph traverseSaturday, November 13, 2010
  35. 35. Subgraph traverse anImageSegment Serialized objects WordArray Shared objects Array A B C D E F G H I J K LSaturday, November 13, 2010
  36. 36. Subgraph traverse anImageSegment A’ B’ C’ Serialized objects WordArray Shared objects Array A B C D E F G H I J K LSaturday, November 13, 2010
  37. 37. Subgraph traverse anImageSegment A’ B’ C’ Serialized objects WordArray Shared objects Array A B C D E F G H I J K LSaturday, November 13, 2010
  38. 38. Subgraph traverse anImageSegment A’ B’ C’ Serialized objects WordArray Shared objects Array A B C D E F G H I J K LSaturday, November 13, 2010
  39. 39. Subgraph traverse anImageSegment A’ B’ C’ Serialized objects WordArray Shared objects Array A B C D E F G H I J K LSaturday, November 13, 2010
  40. 40. Subgraph traverse anImageSegment A’ B’ C’ D Serialized objects WordArray Shared objects Array A B C D E F G H I J K LSaturday, November 13, 2010
  41. 41. Subgraph traverse anImageSegment A’ B’ C’ D Serialized objects WordArray Shared objects Array A B C D E F G H I J K LSaturday, November 13, 2010
  42. 42. Subgraph traverse anImageSegment A’ B’ C’ D Serialized objects WordArray offset Shared objects Array A B C D E F G H I J K LSaturday, November 13, 2010
  43. 43. Subgraph traverse anImageSegment A’ B’ C’ E’ D Serialized objects WordArray offset Shared objects Array A B C D E F G H I J K LSaturday, November 13, 2010
  44. 44. Subgraph traverse anImageSegment offset A’ B’ C’ E’ D Serialized objects WordArray offset Shared objects Array A B C D E F G H I J K LSaturday, November 13, 2010
  45. 45. Subgraph traverse anImageSegment A’ B’ C’ E’ D Serialized objects WordArray Shared objects Array A B C D E F G H I J K LSaturday, November 13, 2010
  46. 46. Subgraph traverse anImageSegment A’ B’ C’ E’ D Serialized objects WordArray Shared objects Array A B C D E F G H I J K LSaturday, November 13, 2010
  47. 47. Subgraph traverse anImageSegment A’ B’ C’ E’ I’ H’ L’ D F G J Serialized objects WordArray Shared objects Array A B C D E F G H I J K LSaturday, November 13, 2010
  48. 48. Offset Memory address A’ B’ C’ E’ I’ H’ L’ D F G J Serialized objects WordArray Shared objects Array A B C D E F G H I J K LSaturday, November 13, 2010
  49. 49. Roots replaceSaturday, November 13, 2010
  50. 50. anImageSegment A’ B’ C’ E’ I’ H’ L’ D F G JSerialized objects WordArray Shared objects Array A B C D E F G H I J K LSaturday, November 13, 2010
  51. 51. anImageSegment A’ B’ C’ E’ I’ H’ L’ D F G JSerialized objects WordArray Shared objects Array P1 P2 P3 D E F G H I J K LSaturday, November 13, 2010
  52. 52. anImageSegment A’ B’ C’ E’ I’ H’ L’ D F G JSerialized objects WordArray Shared objects Array P1 P2 P3 D F G J KSaturday, November 13, 2010
  53. 53. Write to fileSaturday, November 13, 2010
  54. 54. anImageSegment D F G J A’ B’ C’ E’ I’ H’ L’Serialized objects WordArray Shared objects Array Binary file P1 P2 B P3 C D F G J KSaturday, November 13, 2010
  55. 55. anImageSegment NIL D F G J Shared objects Array Binary file A’ B’ C’ E’ I’ H’ L’ P1 P2 B P3 C D F G J KSaturday, November 13, 2010
  56. 56. ImageSegment conclusions Good speed. Graph traverse is done in VM side. Good use of GC facilities. You have to be aware of shared objects. Bad granularity level. Implicit needed information in object graphs.Saturday, November 13, 2010
  57. 57. Thanks! Mariano Martinez Peck marianopeck@gmail.comSaturday, November 13, 2010

×