digitalmars.D - Proposal: a somewhat concurrent GC for D
- downs (13/13) May 04 2008 If I remember correctly, the biggest problem with creating a concurrent ...
If I remember correctly, the biggest problem with creating a concurrent garbage collector for a language like D, is moving pointer information from <before the mark scan> to <behind the mark scan> while the scan is running, thus creating the impression that an object isn't referenced anymore. Thus, I request the introduction of a safemode { } block (keyword name up for debate). While inside a safemode { } block, a thread is considered paused from the GC's point of view. When all, or a sufficient number of, threads are in safemode, the GC can be run concurrently without worrying about pointer movement. Basically, safemode { } is mainly intended for areas of code where most of the time is spent on non-pointer logic. This is because every pointer/reference write access in safemode { } is subject to a GC callback, to check if it's okay to execute that write. If the address being written lies in an area that has already been scanned, the thread is paused until garbage collection ends. (Alternatively, mark the written data manually). If a safemode { } block ends before the GC has finished, the thread is blocked until it has. Programs should be able to use GC calls to give an estimate for the remaining time in a safemode block, to aid the GC in deciding whether to run or not. All of this should allow us, for a certain class of programs where pointer logic consumes a very small part of total runtime, to run garbage collection almost or entirely in parallel. Whaddya think? --downs
May 04 2008