News for hackers. Stuff that matters.
Re:Treadmill garbage collector by H. Baker by oecumena on Monday July 25, 2022 @11:44PM (#32234010)
Double-linked list (Baker calls it "Knuth's double-linked list") allows O(1) insertions and deletions (hence moving) without actually moving objects and without additional indirection. Each object has a header that contains pointers to the next and previous objects in the list. To remove obj from the list do { obj->next->prev, obj->prev->next = obj->prev, obj->next } (I use "parallel assignment" for simplicity), similarly for insertion, see https://en.wikipedia.org/wiki/Doubly_linked_list . So the circles in the diagram are not actual address space (in the sense that object addresses are not increasing monotonically as you go clockwise), but there is no additional indirection because the header with the forward and backward pointers is part of the object.
Re:Treadmill garbage collector by H. Baker by travisgriggs on Tuesday July 26, 2022 @02:01AM (#32234827)
Iirc, there are two approaches to managing your treadmill.

You either use one treadmill with a fixed size abject header/pointer. The “guts” of the object are placed on a heap which gets spaghettified and fragmented pretty fast, especially if your not going to move bodies, because… real time.

The other approach is to use multiple treadmills/rings for different size objects. Different rings are then used for different sizes of objects. In this way, your heap fragmentation/locality improves, but at the added cost of indirecting on object size.

Re:Treadmill garbage collector by H. Baker by RodgerTheGreat on Monday July 25, 2022 @11:49PM (#32234042)
It does mean that in a short period your heap will be a knotted spaghetti of objects with virtually pessimal locality as you chase pointers around the loop.
Re:Treadmill garbage collector by H. Baker by oecumena on Tuesday July 26, 2022 @12:04AM (#32234123)
That's true, the worst case is bad. But if mutator locality of reference is reasonable, the scanner will preserve it. After all, Baker rejected his earlier copying design for a reason.