2013-08-04 06:04:08 UTC
going to post a larger summary, but I want to split this segment out, since
I think it might the most discussion worthy...
Below is a direct link to a segment where he describes a "research"
game-coding structure idea, based on his unfinished research project
porting Wolfenstein 3d to Haskell.
In a nutshell, he hypothesizes an explicitly two-phase memory structure,
which is a curious hybridization of GC, pure-functional immutability, STM,
and imperative mutability.
I think what he's trying to do is get a system which has some of the
benefits of functional immutability and STM, without the overhead of the
extra copies. To do this, he wants to intertwine the GC's copy/compact with
establish immutability. In a sense, the explicit triggering of the GC is
like a global STM commit. In this model, all code runs at
mutable/imperative speed, and the only copies are the ones that already
happen because of compacting GC.
It sounds interesting, since we want GC but struggle with unpredictable
timing and want STM/immutability but struggle with the cost.
Here is a more complete description of my understanding of his idea..
An explicit "per game frame" compacting collector is responsible not only
for GC, but also for "phase shifting" data. The last phase is not
immediately discarded, but is kept around for one extra cycle, shifted into
self-referential immutable data.
Code-components (entities) are allowed to see mutable pointers to their own
data, but only read-only pointers to the *previous*phase* of data in all
other entities in the system. Using this structure, one can spin up a
thread-per entity, knowing they can't clobber each-other.
Cross-communication between entities is handled by message-passing
partially bound functions which entities apply to themselves during the
next processing phase.
It's not clear whether entities are only allowed borrowed pointers to the
immutable-phase (assuring they can't hold them past the phase shift), or
whether the GC has a two-phase fixup, where it updates references one phase