Object Graph Swapping

870 views
814 views

Published on

Object Graph Swapping, Mariano Martinez Peck, ESUG 2010, Barcelona, Spain.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
870
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
15
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Object Graph Swapping

  1. 1. Object graphs swapping 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 1 Wednesday, September 15, 2010
  2. 2. The context 2 Wednesday, September 15, 2010
  3. 3. The context 2 Wednesday, September 15, 2010
  4. 4. The context 2 Wednesday, September 15, 2010
  5. 5. The context 2 Wednesday, September 15, 2010
  6. 6. The context 2 Wednesday, September 15, 2010
  7. 7. The context 2 Wednesday, September 15, 2010
  8. 8. Problem Use more memory than needed. Make OOP languages unsuitable for memory limited devices. Existence of unused but referenced objects. 3 Wednesday, September 15, 2010
  9. 9. 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 4 Wednesday, September 15, 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 5 Wednesday, September 15, 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 5 Wednesday, September 15, 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 5 Wednesday, September 15, 2010
  13. 13. 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 5 Wednesday, September 15, 2010
  14. 14. But...what happens with referenced yet unused objects? Z X Y A B C D E F G H I J K L 6 Wednesday, September 15, 2010
  15. 15. Idea Swap out (not remove) unused objects to disk. Automatically load them back when needed. 7 Wednesday, September 15, 2010
  16. 16. Related work Large object oriented memory (LOOM). Melt - Supporting memory leaks. ImageSegments. 8 Wednesday, September 15, 2010
  17. 17. But...no one solves all the problems 9 Wednesday, September 15, 2010
  18. 18. Main challenges Not to use more memory than the one released by swapping. Low overhead penalty. Group objects in an smart way. 10 Wednesday, September 15, 2010
  19. 19. Key aspects Mark and trace unused/used objects at runtime. The usage of proxies. Group unused objects (subgraphs). 11 Wednesday, September 15, 2010
  20. 20. 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. 12 Wednesday, September 15, 2010
  21. 21. Why subgraphs? Group of objects that are used (or not used) together. We need few proxies (for the roots) for several objects. 13 Wednesday, September 15, 2010
  22. 22. Experiments done Modify Smalltalk VM to mark and trace objects usage. Visualize objects and memory usage. Take statistics from different scenarios. 14 Wednesday, September 15, 2010
  23. 23. deployed web application example Used Unused Used Unused Amount of objects Amount of memory 4% 15% 85% 96% 15 Wednesday, September 15, 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. 16 Wednesday, September 15, 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 17 Wednesday, September 15, 2010
  26. 26. More problems Should shared objects be Roots Inner Shared External included or not? GC moves objects. X Z Y Subgraph to process Pointers update. A B C (Root) (Root) (Root) Class changes. D E F G H Recreate and reinitialize objects. I J K L Code executed after 18 loading. Wednesday, September 15, 2010
  27. 27. ImageSegment Wednesday, September 15, 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. Wednesday, September 15, 2010
  29. 29. Subgraph traverse Serialized objects WordArray Shared objects Array A B C D E F G H I J K L Wednesday, September 15, 2010
  30. 30. Subgraph traverse A’ B’ C’ Serialized objects WordArray Shared objects Array A B C D E F G H I J K L Wednesday, September 15, 2010
  31. 31. Subgraph traverse A’ B’ C’ Serialized objects WordArray Shared objects Array A B C D E F G H I J K L Wednesday, September 15, 2010
  32. 32. Subgraph traverse A’ B’ C’ Serialized objects WordArray Shared objects Array A B C D E F G H I J K L Wednesday, September 15, 2010
  33. 33. Subgraph traverse A’ B’ C’ Serialized objects WordArray Shared objects Array A B C D E F G H I J K L Wednesday, September 15, 2010
  34. 34. Subgraph traverse A’ B’ C’ D Serialized objects WordArray Shared objects Array A B C D E F G H I J K L Wednesday, September 15, 2010
  35. 35. Subgraph traverse A’ B’ C’ D Serialized objects WordArray Shared objects Array A B C D E F G H I J K L Wednesday, September 15, 2010
  36. 36. Subgraph traverse A’ B’ C’ D Serialized objects WordArray offset Shared objects Array A B C D E F G H I J K L Wednesday, September 15, 2010
  37. 37. Subgraph traverse A’ B’ C’ E’ D Serialized objects WordArray offset Shared objects Array A B C D E F G H I J K L Wednesday, September 15, 2010
  38. 38. Subgraph traverse offset A’ B’ C’ E’ D Serialized objects WordArray offset Shared objects Array A B C D E F G H I J K L Wednesday, September 15, 2010
  39. 39. Subgraph traverse A’ B’ C’ E’ D Serialized objects WordArray Shared objects Array A B C D E F G H I J K L Wednesday, September 15, 2010
  40. 40. Subgraph traverse A’ B’ C’ E’ D Serialized objects WordArray Shared objects Array A B C D E F G H I J K L Wednesday, September 15, 2010
  41. 41. Subgraph traverse 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 L Wednesday, September 15, 2010
  42. 42. 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 L Wednesday, September 15, 2010
  43. 43. 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 L Wednesday, September 15, 2010
  44. 44. anImageSegment A’ B’ C’ E’ I’ H’ L’ D F G J Serialized objects WordArray Shared objects Array P1 P2 P3 D E F G H I J K L Wednesday, September 15, 2010
  45. 45. anImageSegment A’ B’ C’ E’ I’ H’ L’ D F G J Serialized objects WordArray Shared objects Array P1 P2 P3 D E F G H I J K L Wednesday, September 15, 2010
  46. 46. anImageSegment A’ B’ C’ E’ I’ H’ L’ D F G J Serialized objects WordArray Shared objects Array P1 P2 P3 D F G J K Wednesday, September 15, 2010
  47. 47. 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 K Wednesday, September 15, 2010
  48. 48. anImageSegment 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 K Wednesday, September 15, 2010
  49. 49. 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 K Wednesday, September 15, 2010
  50. 50. 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. Wednesday, September 15, 2010
  51. 51. Thanks! Mariano Martinez Peck marianopeck@gmail.com Wednesday, September 15, 2010

×