1 / 26

Compiler Optimizations for Nondeferred Reference-Counting Garbage Collection

Compiler Optimizations for Nondeferred Reference-Counting Garbage Collection. Pramod G. Joisha Microsoft Research, Redmond. Classic Reference-Counting (RC) Garbage Collection. All references (stack, statics, heap) tallied Based on the nondeferred RC invariant

kaethe
Download Presentation

Compiler Optimizations for Nondeferred Reference-Counting Garbage Collection

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Compiler Optimizations for Nondeferred Reference-Counting Garbage Collection Pramod G. Joisha Microsoft Research, Redmond

  2. Classic Reference-Counting (RC) Garbage Collection • All references (stack, statics, heap) tallied • Based on the nondeferred RC invariant • Nonzero means at least one incident reference and zero means garbage • High processing costs • Counts need to be updated on every mutation

  3. Past Solution to High Overhead • Count only a subset of references • Deferred RC collection (1976) • Ulterior RC collection (2003) • Based on the deferred RC invariant • Nonzero means at least one incident reference but zero means maybe garbage • Faster, but • more “floating” garbage • longer pauses

  4. Our Solution • Program analyses • Idea: Eliminate redundant RC updates • Redundancy with respect to RC invariant • Advantages • Reclamation characteristics unchanged • Pause time no worse than unoptimized case

  5. Talk Outline • Optimizations (and related analyses) • RC subsumption • Acyclic object RC update specialization • Experimental results • Impact on execution times • Comparison with deferred RC collection • Conclusions

  6. Optimizations • Fall into three categories • Data-centric (immortal RC update elision, acyclic object RC update specialization) • Program-centric (RC subsumption, RC update coalescing, null-check omission) • RC update-centric (RC update inlining)

  7. RC Subsumption: Intuition

  8. Flow-Insensitive RC Subsumption x • y is always RC subsumed by x if • All live ranges of y are contained in x • The variable y is never live through a redefinition of either y or x • Everything reachable from y is also reachable from x y

  9. x := ... y := x x := ... y := x ... y ... ... y ... ... x ... Live Range Webs

  10. Provision 1: Live-Range Subsumption Graph • Directed graph GL • Nodes represent local references • Edges denote live-range containment • (y, x) means “y is always contained in x” • Quadratic algorithm • Start with G = (V,E) • Add (u, v) if u is live and v dead at point P • Complement of G is GL

  11. A Contingent Opportunity

  12. Provision 2: Uncut Live-Range Subsumption Graph • Handles redefinition provision • Directed graph GE • Start with GL • Find livethru(s) and defsmay(s) • Then liverdef(s) = livethru(s)  defsmay(s) • Delete (u, x) if u liverdef(s) • Delete (y, u) if y livethru(s) and u liverdef(s)

  13. v u := v A u := v.g (gis a read-only field) stack u B u := v[e] (v is thread local and v[e] isn’t written into before v dies) u := v.f (vis thread local andv.f isn’t written into before v dies) Overlooking Roots

  14. w v u Provision 3: RC Subsumption Graph • Start with GE • Delete (u, v), where uv • nothing overlooks u at its definition • u is overlooked by w and (w, v)  GR • Delete until fixed point is reached • Approximate overlooking roots’ set used

  15. Talk Outline • Optimizations (and related analyses) • RC subsumption • Acyclic object RC update specialization • Experimental results • Impact on execution times • Comparison with deferred RC collection • Conclusions

  16. The Problem of Garbage Cycles • Reference counting can’t capture cycles • Three solutions: • Programming paradigms • Back-up tracing collector • Local tracing solution: trial deletion

  17. Background on Trial Deletion • Decremented references buffered • Trial deletion adds overheads • Bookkeeping memory (PLC buffer, PLC link) • Extra processing in RC updates • Idea: Statically identify acyclic objects

  18. v x w z Acyclic Type Analysis • Determine types that are always acyclic • Type hierarchy and field information • Type connectivity (TC) graph • SCC decomposition of TC graph y

  19. Building the TC Graph • Separate compilation • Immortal object optimization • Array subtyping issues

  20. Other Optimizations • RC updates on immortal objects • vtables, string literals, GC tables • Coalescing of RC updates • Non-null operand RC update specialization • RC update inlining

  21. Talk Outline • Optimizations (and related analyses) • RC subsumption • Acyclic object RC update specialization • Experimental results • Impact on execution times • Comparison with deferred RC collection • Conclusions

  22. Benchmarks

  23. Optimization Effects

  24. Overlooking Roots’ Set Effects

  25. RC Update Distributions

  26. Summary • High overheads can be drastically reduced without compromising on benefits! • Key: a new analysis called RC subsumption • Improvements due to it alone often significant • Execution times on a par with deferred RC collection on a number of programs • Challenges wisdom on classic RC efficiency • Scope for further improvement exists • Future Work: Multithreading

More Related