Docsity

Comparing Incremental and Concurrent Garbage Collection: Techniques and Challenges, Study notes of Computer Science

Partial preview of the text

Download Comparing Incremental and Concurrent Garbage Collection: Techniques and Challenges and more Study notes Computer Science in PDF only on Docsity!

RCGC is naturally incremental, how about making it concurrent โ€ฆ

Review Incremental mark-sweep

๏‚— Steeleโ€™s multiprocessing, compactifying collector ๏‚— Dijkstraโ€™s on-the-fly collector ๏‚— Kung and Song improved four-color collector ๏‚— Yuasa sequential collector ๏‚— Uses snapshot-at-the-beginning write-barrier ๏‚— Compared using these metrics ๏‚— Operation of write-barrier ๏‚— Treatment of new objects ๏‚— Cost of initialization & termination of each GC cycle

Bounding initiation pause

๏‚— Kung & Song: ๏‚— Push roots on double-ended mark queue one at a time ๏‚— Incremental: mutatorโ€™s computation is unrestricted ๏‚— Yuasa: ๏‚— Copy entire program stack to saved_stack using a fast copy method (e.g. UNIX memcpy ) ๏‚— Entries in saved_stack transferred to mark stack k2 at a time ๏‚— Reduces fragmentation

Marking in concurrent system

๏‚— Concurrent system: ๏‚— Multiple processes or thread execute at the same time and potentially interact with each other ๏‚— Collector locks mark stack while examining it

Concurrent reference counting

๏‚— Updating a RC must be atomic to avoid race conditions between threads ๏‚— Can lead to premature collection of objects ๏‚— Atomicity requires locking shared objects ๏‚— Increases cost of pointer assignment ๏‚— Increase mutator performance ๏‚— Run collector in separate thread ๏‚— Make collector responsible for updating RC fields ๏‚— Mutators no longer update RC but log assignments in a block of a transaction queue (figure on next slide)

Modula-2+ RC architecture

Jones and Lin: Diagram 8.

Reducing RC cost

๏‚— Distinguish assignments to local variables from assignments to global variables and heap data ๏‚— Only reference count shared-pointer-valued-variables ๏‚— RC is only lower bound of refs to object from local & shared variables

Mutator code: shared references

update(A, C){ LOCK mutex insert (A, C, tq) // insert in transaction queue if( tq is full){ notify_collector(tq) // send block to collector tq = gt_next_block() } *A = C }

Collector code: shared references

13

collector(){ while (; ;){ tq = wait_next_block() for each thread th { LOCK mutex{ suspend(th) scan_thread(th) restart(th) } } adjust_counts(tq) free_block(tq) adjust_shared_copunts() process_ZCL() }

Processing ZCL

๏‚— If objectโ€™s shared RC no longer 0, it is removed from ZCL ๏‚— If object is found in a thread state, it is left in ZCL ๏‚— It may be freed in future collection ๏‚— Otherwise object is removed from ZCL and recursively freed ๏‚— Note: Can reduce cost of assignment ๏‚— Use per thread transaction queue