[Twisted-Python] Reality and global Thing tables

exarkun at meson.dyndns.org exarkun at meson.dyndns.org
Thu May 23 18:33:32 EDT 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


 This is mostly addressed to Glyph, but any feedback is appreciated :)

 From what brief conversations we've had on the topic, my understanding of
the situation is this:  I like to have large global tables, each for a
certain "type" of Thing, that references every instance in the game; an
alternative approach favored by others is for references to only those
objects that will be useful to be kept around locally (locally with
respect to the objects that will find them useful).

 The main argument I've heard against global tables is they use
resources unnecessarily.  A game with a billion Widgets will have an
unreasonably large table, which must apparently be kept entirely in memory
(whereas, with a bit of cleverness, the Widgets themselves can be tossed
onto disk when not needed).  Are there other arguments against using
global tables?

 I don't find this to be convincing for a few reasons.  Firstly (and least
importantly), hardware is cheap and expanding a server to meet the needs
of a game isn't all that unreasonable.  Besides, I'll never have to worry
about it because my game will never become that large or popular ;)
Second, distributing references locally gives us a large performance hit
for certain operations.

Consider the common case of game-wide communication.  This can either be
an inherent ability (think "tell" from most MUDs) or something granted by
a device (the commlinks of SWR).  Either way brings essentially the same
programmatic challenges.  Determine who the message is addressed to and
deliver it.  Using global tables, we can look up a player name (in linear
time) and deliver the message or look up a "device address"  (cellphone
number, frequency ID, whatever floats your boat) and deliver the message
to anyone in close proximity to the Thing.

Contrast this with a system lacking global tables.  To determine who the
message is addressed to, one essentially has to walk through the graph of
the entire game.  Start with your highest level organizational unit
("areas" on most MUDs) and work down to rooms, then room contents
(including players and containers, and containers in containers, etc).  A
very expensive operation that could end up costing many levels of
recursion along with numerous unneeded levels of indirection in the form
of rooms and containers.  Of course, after the first lookup you can cache
the result (and hope it doesn't change in the mean time) obviating the
need for further lookups, but this comes with the problem of eventually
costing as much memory as the global solution (if not more) unless you do
cache management and culling and all sorts of other complexities.  Fun?
No.

 So, am I just missing some clever way to operate without global tables,
or some other disadvantage to keeping them around?  I am as an empty pot,
fill me up.

  Jp (exarkun)


        "I quite agree with you," said the Duchess; "and the moral of
that is -- Be what you would seem to be' -- or, if you'd like it put
more simply -- Never imagine yourself not to be otherwise than what it
might appear to others that what you were or might have been was not
otherwise than what you had been would have appeared to them to be
otherwise.'"       -- Lewis Carrol, "Alice in Wonderland"
- --
 5:58pm up 2 days, 18:37, 0 users, load average: 0.06, 0.07, 0.02
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE87W4/edcO2BJA+4YRAk6UAJ4g7/zFzd6l0rWE05rGI1QZMRhe2QCgzSIO
zElP/O5c7F4d9LJ++3gvpJc=
=HegD
-----END PGP SIGNATURE-----





More information about the Twisted-Python mailing list