[DGD] Clones and very large arrays
Bart van Leeuwen
bart at wotf.org
Sat Apr 3 19:48:16 CEST 2004
On Sat, 3 Apr 2004, Robert Forshaw wrote:
> I'm sorry but I still don't understand the linked list concept. I thought a
> linked list was basically a chain of objects, each object having a prev and
> next variable.
Yes, thats exactly what you do. I didn't see the reason for usign a LWO
for storing this info either, but you can do it that way.
>
> As I think about a linked list and the implied inefficiency (assuming I
> understand it right) I am also wondering what the purpose of storing a list
> of clones would be. Initially it was 'just because', I imagined I'd need the
> information stored, but really I've never been sure about what situation
> knowing what an objects' clones are would be useful.
Hmm, you obviously never had 'rogue' clones out there, ie, somethign ended
up making a zilion clones of an object due to some bug..
Basicly, when you run a persistent mud, keepign track of which objects are
loaded, and which clones they have is the only possible way to not end up
with lots and lots of junk that will never be needed again, or at least
gives you a way to find and remove such junk.
Then, it is quite nice to be able to do something like
query_clones(obj)->function(args);
>
> >Though I always considered when I got to tracking objects et al I'd use an
> >object manager objectd. and store in a mapping of arrays along what I
> >believe
> >Par Winzell mentioned as the way to avoid max_array issues:
> > ([ (clone_num % 1024) : ({ array_of_clones }) ])
> >Though that might not be exact, something along those lines.
>
> I didn't understand that, the example you gave is rather ambigious and seems
> to be suggesting that I store an array of clones referenced by a clone!
> Surely I want it referenced by a master?
The basic issue is this:
You store an array of 20000 clones in the master, which means that when
the master gets swapped out, DGD has to swap out that entire array as
well.
When the info is distributed over the clones themselves, you do not have
to swap in/out a relatively big chunk of memory ever as a result of this.
It helps in making DGD perform a bit better.
That said.. in ancient lpmuds, such a linked list was used for example for
keeping track of pieces of equipment that a player was 'wearing'. This
solution caused many bugs due to chains being broken and replacing it by
an array or mapping (in the player object) makes quite a difference in
reliability.
Basicly, the problem with chains is that they have a tendency to break and
that you are kinda lost when they do.
That is why I am using arrays instead of a linked list (besides the fact
that an array allows me to call a function in all clones easily)
Trying to increase max array size to sizeof(long)/2 doesn't sound like a
good plan to me however.. I am not sure (and Felix pls correct me if I am
wrong) but it might well be that there are places where an array might be
indexed using an int instead of a long. Makign the max size bigger then
32767 might result in some subtle and interesting bugs due to that.
Bart
_________________________________________________________________
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list