After 3 months of coding weekends, my attempt to create a relocating nonblocking garbage collector in C++ has failed. It works in theory, but in practice the read barrier is pervasive and costly, and the threading invariants are incredibly tricky to maintain.
-
-
How do you keep track of roots? Don't you still need to trace through arbitrary C++ structures which may be holding on to `ref<t>`s to determine if they're reachable (and where, once again, you don't know what's a pointer and what isn't)?
-
I maintain a bitmask of all locations in unmanaged memory that contain ref<t>, set in the ctor and cleared in the dtor. Those bits are used to locate roots (conservatively, given races), plus there’s a dirty-flag per object to indicate recent rootedness.
- 2 more replies
New conversation -
-
-
So where did the cost come in, compared to other reference-based languages? I think that looking into C++/CLI might also be interesting.
-
When reading a garbage collector managed pointer from an object in a thread, it needs to be sanitized through a hazard pointer or similar synchronization mechanism. This is expensive, and needed for every pointer copy and operator->.
- 1 more reply
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.