[DGD] Garbage collection...is it worth it?

Mikael Lind mikkelin at gmail.com
Fri Jan 5 09:14:47 CET 2007


Hello,

2007/1/4, Shentino <shentino at gmail.com>:
> Just thought I'd get some coding philosophy..
>
> I put a couple of "GC patrol" objects that scan for objects that fail
> their invariants and nuke them.
>
> However, I do eat up a sliver of CPU time going on patrol.
>
> Is it worth it?
>
> opinions please.

Can you describe a typical scenario where your collection scheme would
be helpful? I am thinking that you want to wipe out objects that were
not properly created, as well as objects that become invalid during
their lifetime.

My thoughts on invariants in DGD is that they should be established by
the create() function and maintained by the member functions if at all
possible. This is also why I want to implement support for create()
arguments, because that makes it much easier to fully construct the
object in create() instead of doing a partial construction and expect
users to complete construction through additional member function
calls.

Functions that create objects, namely clone_object(), new_object(),
and possibly compile_object(), can be made atomic to permit an object
to raise an error in create() if it cannot establish its invariants,
causing the entire creation to be rolled back. This way, you will have
fewer partially constructed objects around. I think someone (SkotOS?)
went even further and made all execution rounds atomic.

There can be situations where the above is not enough, so a collection
scheme may be a good complement. (An invariant may depend on something
that the object cannot maintain, such as the existence of another
persistent object.) The collection scheme could also wipe out valid
but disposable objects.

Objects will be swapped in as they are scanned, so collection will
increase memory usage and I/O in addition to the CPU usage, depending
on the length of the scan cycle. Scanning one object per second on a
mud with 64K objects would take almost a day.

I have also been thinking about tracking the memory usage of
persistent objects, and treating it as a resource. This could also be
done with scanning, or possibly by masking call_out() and
call_other(). Has anyone tried this?

Regards,
Mikael



More information about the DGD mailing list