[MUD-Dev] Re: TECH: Distributed Muds

J C Lawrence claw at 2wire.com
Thu Apr 26 19:00:06 New Zealand Standard Time 2001

On Wed, 25 Apr 2001 18:37:02 -0700 
Brian Hook <bwh at wksoftware.com> wrote:
> At 05:07 PM 4/25/01 -0700, J C Lawrence wrote:

>> Simple traversal is not really the problem.  The underlieing
>> problem is fragmentation and resultant thrashing of the OS page
>> cache.

> Simple traversal at the limit is still going to cause a whole
> bunch of swapping irrespective of page cache thrashing.

It especially hurts if your system has a two level page cache
outside of swap.

> But that actually leads to another really gnarly problem, which I
> assume that MUD developers have a bunch of experience with, and
> that's dealing with memory fragmentation in general.  Obviously a
> bunch of calls to new/delete during the run time of a server (or a
> client if someone stays logged in for days at a time) isn't going
> to be particularly feasible.

Custom heap managers.  Yup.  Old technique.  

> I'm curious how that's handled in the real world.  The obvious
> mechanism is to have fixed allocation pools for different object
> types and to manage your own memory using handles that allow
> compaction.

Its an easy problem to over optimise at design time (resulting in
slower code).  The best approaches I've seen have taken one of two

  a) Pre-allocation of pools of blocks of predefined sizes, which
  are then doled out and recycled arbitrarily on a best-size-fit
  basis to all requests.

  b) Predictive/adpative allocation of pre-sized blocks all
  dedicated to a given data type, with distinct and differently
  optimised heap managers for all the different major data

I like the first approach.  Its simple, its easy to profile and
monitor, and its even easier to maintain.  The second approach
potentially gives more rewards as you can tune each heap to the
access patterns of its data type, but that comes at the expense of
complexity and lack of central oversight.

J C Lawrence                                       claw at kanga.nu
---------(*)                          http://www.kanga.nu/~claw/
--=| A man is as sane as he is dangerous to his environment |=--
MUD-Dev mailing list
MUD-Dev at kanga.nu

More information about the MUD-Dev mailing list