Presentation is loading. Please wait.

Presentation is loading. Please wait.

A Principled Approach to Nondeferred Reference-Counting Garbage Collection † Pramod G. Joisha HP Labs, Palo Alto † This work was done when the author was.

Similar presentations


Presentation on theme: "A Principled Approach to Nondeferred Reference-Counting Garbage Collection † Pramod G. Joisha HP Labs, Palo Alto † This work was done when the author was."— Presentation transcript:

1 A Principled Approach to Nondeferred Reference-Counting Garbage Collection † Pramod G. Joisha HP Labs, Palo Alto † This work was done when the author was at Microsoft Research. VEE’08 (ACM SIGPLAN/SIGOPS International Conference on Virtual Execution Environments)March 7, 2008

2 VEE’08 1 Classic RC Instrumentation local references global reference

3 VEE’08 2 Unique Advantages Prompt reuse –Cache effect gives performance benefits Low footprint –Can run in a smaller heap Useful in memory-constrained environments Incremental in time and space –No repeated traversals of long-lived data –Spatial locality usually no worse than mutator Can present simpler overall designs –No stack maps needed, at least in single-thread case

4 VEE’08 3 What is “Nondeferred” RC Collection? Three invariants should always hold: 1.All live data have positive reference counts 2.Reference count is zero when last reference disappears 3.Zero reference count implies dead data Classic reference counting is nondeferred –Deutsch & Bobrow’s reference counting is not There are subtleties in the definition –“Last reference” is from mutator’s standpoint –Reference count could be zero even before

5 VEE’08 4 Deutsch & Bobrow’s Reference Counting Approximate reference counts –Only heap references tallied –Zero-Count Table (ZCT) Threads paused to reconcile –Stacks scanned to purge ZCT –Remaining entries garbage Nondeferred invariants might not always hold stack x y z a 1 b 0 heap c 1 f.g globals

6 VEE’08 5 The Spectrum of RC Techniques

7 VEE’08 6 What is Different from Previous Efforts? Past work addressed optimizations: –Given a nondeferred app, how to make it faster? 2006 & 2007 ACM International Symposium on Memory Management This work addresses a different obstacle: –How to convert object-oriented apps to use nondeferred? The line of work has an overarching goal: –Making nondeferred RC garbage collection practical –Making general reference counting more efficient

8 VEE’08 7 Contributions of This Work Addresses main problems to conversion: –How to handle object-oriented instruction sets uniformly? –How to insert RC updates to achieve early reclamation? –How to do this in the midst of modern language features? Exceptions, object pinning, interior pointers –How to treat the run-time system? Interaction of conversion with other phases –Impact on downstream phases should be minimal –Conversion has implications on inlining

9 VEE’08 8 Talk Outline The RC update insertion phase –High-level process –Code templates Trading code quality with eagerness The scope of the insertion phase How does the technique fare? Summary Some Further Thoughts

10 VEE’08 9 The RC Update Insertion Phase

11 VEE’08 10 Motivation: Normalize the IR Key step: Subsume interior pointers –Interior pointers similar to conventional pointers –But can only be used in a few well-defined ways –Should be honored by the garbage collector Approach: Shadow interior pointer accesses Preprocessing Stage shadow interior ptr 12345678910 array object

12 VEE’08 11 Find dying references using liveness analysis –Supplementary decrements may be needed If references are both defined and live on entry to the statement s If other references could be defined in s Liveness modified for pinned references Analysis Stage

13 VEE’08 12 Injection Stage Three kinds of RC updates inserted –RC increment, standard and eager RC decrement Operates in three steps –Insert RC updates against definitions and deaths –Insert RC increments against explicit intrafunction throws –Insert standard RC decrements into exception headers Injection guided by code templates –Based on classifying a statement as call or “non-call”

14 VEE’08 13 Non-Call Statements

15 VEE’08 14 An Example

16 VEE’08 15 Issue with Representing the Eager Decrement

17 VEE’08 16 Trading Code Quality with Eagerness

18 VEE’08 17 Everything Shouldn’t be Converted! All code in the run-time isn’t converted Presently, C# attributes flag special code –[PreInitRefCounts] Bootstrap memory allocation, and static initializers –[RecursiveRefCounts] Code transitively reachable from addref and release –[ManualRefCounts] Methods that directly manipulate reference counts –[ZombieRefCounts] Code accessing zombie objects Affixation rules can be mechanized

19 VEE’08 18 Related Work The use of liveness in GC isn’t new –But past work considers it for a tracing collector This work considers reference deaths –Important distinction: Arises from a basic difference between tracing and reference counting One looks at live matter and the other at matter that is dead (see Bacon et al. OOPSLA’04). Certain complications are unique here –E.g. exceptions

20 VEE’08 19 How does Nondeferred Fare? Xlisp interpreter (SPEC CINT95 port)

21 VEE’08 20 Summary A systematic conversion algorithm –Instructions are treated in a uniform manner –Modern language features handled –Degree of eagerness can be varied Conversion has implications on other parts Has been implemented in a compiler –Many large programs have been successfully compiled

22 What remains for primetime? –Optimizing single-thread heap reference counting –Concurrent nondeferred reference counting –Cycle reclamation –Fragmentation An ecosystem of supporting tools required –Presently, a memory leak verifier and profiler exist –But more needed! VEE’08 21 decreasing importance Some Further Thoughts

23 VEE’08 22 Questions?


Download ppt "A Principled Approach to Nondeferred Reference-Counting Garbage Collection † Pramod G. Joisha HP Labs, Palo Alto † This work was done when the author was."

Similar presentations


Ads by Google