prioritized garbage collection using the garbage
play

Prioritized Garbage Collection Using the Garbage Collector to - PowerPoint PPT Presentation

Prioritized Garbage Collection Using the Garbage Collector to Support Caching Diogenes Nunez , Samuel Z. Guyer, Emery D. Berger Tufts University, University of Massachusetts Amherst November 2, 2016 D. Nunez, S. Guyer, E. Berger Prioritized GC


  1. Prioritized Garbage Collection Using the Garbage Collector to Support Caching Diogenes Nunez , Samuel Z. Guyer, Emery D. Berger Tufts University, University of Massachusetts Amherst November 2, 2016 D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 1 / 47

  2. Caches are everywhere D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 2 / 47

  3. Caches are everywhere D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 2 / 47

  4. Caches are everywhere D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 2 / 47

  5. Caches are everywhere D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 2 / 47

  6. Caches are a space-time tradeoff. 40 Total Runtime 35 30 25 Time (sec) 20 15 10 5 0 0 50 100 150 200 250 300 350 400 450 500 550 600 Number of cache entries D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 3 / 47

  7. Caches are a space-time tradeoff. 40 Total Runtime 35 30 25 Time (sec) 20 15 10 5 0 0 50 100 150 200 250 300 350 400 450 500 550 600 Number of cache entries D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 4 / 47

  8. Caches are a space-time tradeoff. 40 Total Runtime 35 30 25 Time (sec) 20 15 10 5 0 0 50 100 150 200 250 300 350 400 450 500 550 600 Number of cache entries D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 5 / 47

  9. Caches are a space-time tradeoff? 40 Total Runtime 35 30 25 Time (sec) 20 15 10 5 0 0 50 100 150 200 250 300 350 400 450 500 550 600 Number of cache entries D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 6 / 47

  10. Garbage collection dominates runtime. 40 Other GC 35 30 25 Time (sec) 20 15 10 5 0 0 50 100 150 200 250 300 350 400 450 500 550 600 Number of cache entries D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 7 / 47

  11. Perfect Cache Size D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 8 / 47

  12. Elements can be too small. The cache can use more space. D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 9 / 47

  13. Elements can be too big. The cache needs to use less space. D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 10 / 47

  14. Evicted elements remain in memory until next GC. D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 11 / 47

  15. Evicted elements remain in memory until next GC. D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 12 / 47

  16. Evicted elements remain in memory until next GC. D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 13 / 47

  17. Problem Can we . . . Keep the garbage collector from dominating program run time Handle entries of various sizes D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 14 / 47

  18. Soft References Removed prior to an OutOfMemory exception JVMs can remove them during normal operation ◮ Hotspot removes them over time in a Least-Recently-Used (LRU) order D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 15 / 47

  19. All soft references are equal. All Soft References placed in a global queue Queue is cleared in an LRU policy over time Results in removal of cache values from cold code D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 16 / 47

  20. Our Solution Make the Garbage Collector aware of the cache and its contents D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 17 / 47

  21. Our Solution Prioritized Garbage Collector ◮ Separate the references into logical spaces with unique eviction policies ◮ Compute how much memory each reference is responsible for Sache ◮ Use the Prioritized Garbage Collector to limit the memory used by stored values D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 18 / 47

  22. Prioritized Garbage Collection: Using PrioSpaces // Specify memory limit in number of bytes ... PrioSpace <Tree > space = VM.getSpace (500); //.. or percentage of heap PrioSpace <Tree > space = VM.getSpace (0.6); D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 19 / 47

  23. Register objects into a PrioSpace Tree t; PrioReference <T> ref = space.newReference (t); D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 20 / 47

  24. Updates the reference’s priority every use. PrioReference <Tree > ref; Tree t = ref.get (); /* Results in a call to * space. updateReference (t); */ D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 21 / 47

  25. Compare two PrioReferences int compare(PrioReference <T> a, PrioReference <T> b); Determines the eviction policy of the space given by programmer D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 22 / 47

  26. Compare two PrioReferences int compare(PrioReference <T> a, PrioReference <T> b); Determines the eviction policy of the space given by programmer Determines the priority of a reference in the space ◮ Higher priority → More likely to not be evicted D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 22 / 47

  27. Prioritized Garbage Collection: Cleaning PrioSpaces For each PrioSpace , garbage collector calculates and stores the amount of memory used by strucures Garbage collector frees structures according to priority of the references D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 23 / 47

  28. Sache ( S pace A ware Ca che ) User puts a limit on size of Sache in bytes Tell the prioritized garbage collector what values are in the cache and the order of eviction ◮ Current eviction policy is LRU Measure the amount of memory used by these values during garbage collection If keeping a value means the Sache exceeds the size limit, evict that value D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 24 / 47

  29. Sache: Interface class Sache <K,V> extends HashMap <K, PrioReference <V>> { protected int priority; protected PrioSpace <V> priospace; public Sache(long maxSize ); public boolean put(K key , V value ); public V get(K key); public V remove(K key); private void update (); } D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 25 / 47

  30. Sache: Using Sache Sache map = new Sache(60); space : map.put("1", d); c map.put("2", a); map.put("3", h); a b map.get("1"); //Garbage collection occurs d g h f Marked by Mark Sweep e i Marked by Prioritized GC D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 26 / 47

  31. Sache: Using Sache Sache map = new Sache(60); limit = 60 bytes space : map.put("1", d); map.put("2", a); c map.put("3", h); map.get("1"); a b //Garbage collection occurs map d g h f Marked by Mark Sweep e i Marked by Prioritized GC D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 26 / 47

  32. Sache: Using Sache Sache map = new Sache(60); limit = 60 bytes space : map.put("1", d); map.put("2", a); c map.put("3", h); map.get("1"); a b //Garbage collection occurs map d g h f Marked by Mark Sweep e i Marked by Prioritized GC D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 26 / 47

  33. Sache: Using Sache Sache map = new Sache(60); limit = 60 bytes space : d map.put("1", d); map.put("2", a); c map.put("3", h); map.get("1"); a b //Garbage collection occurs map d g h f Marked by Mark Sweep e i Marked by Prioritized GC D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 26 / 47

  34. Sache: Using Sache Sache map = new Sache(60); limit = 60 bytes space : d map.put("1", d); map.put("2", a); c map.put("3", h); map.get("1"); a b //Garbage collection occurs map d g h f Marked by Mark Sweep e i Marked by Prioritized GC D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 26 / 47

  35. Sache: Using Sache Sache map = new Sache(60); limit = 60 bytes space : a d map.put("1", d); map.put("2", a); c map.put("3", h); map.get("1"); a b //Garbage collection occurs map d g h f Marked by Mark Sweep e i Marked by Prioritized GC D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 26 / 47

  36. Sache: Using Sache Sache map = new Sache(60); limit = 60 bytes space : a d map.put("1", d); map.put("2", a); c map.put("3", h); map.get("1"); a b //Garbage collection occurs map d g h f Marked by Mark Sweep e i Marked by Prioritized GC D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 26 / 47

  37. Sache: Using Sache Sache map = new Sache(60); limit = 60 bytes space : h a d map.put("1", d); map.put("2", a); c map.put("3", h); map.get("1"); a b //Garbage collection occurs map d g h f Marked by Mark Sweep e i Marked by Prioritized GC D. Nunez, S. Guyer, E. Berger Prioritized GC November 2, 2016 26 / 47

Recommend


More recommend