Thursday, April 28, 2011

Sorry Mark

A number of years ago when I first came back to Dark Risings to help run Gypsy, a little feature called Hevige Nacht (HN) was in full swing which essentially gave players a real-life hour where anyone could attack (and loot) anyone else without any IC reason other than it being HN. Considering the fact that I had left the game several years earlier in large part due to roleless PK, I saw HN as an unacceptable deviation from DR's long-held classification of being an "RP MUD with PK," and I made a big stink about it.

Part of the stink I raised involved drumming up support for my "end HN now!" campaign with some old higher-profile DR player pals of mine. One such pal was a fellow (let's call him P) who, for all intents and purposes, was no longer playing the game and would only log in once in a while to read notes and maintain appearances. Upon hearing my tales of HN horrors, he logged his main character and posted a big, two-idea-long diatribe against HN that summarized everything I'd been saying about the whole HN idea all along. Awesome, right?

Actually, the only reason I remember that big posting is because Mark's response was
[OOC] Mark: 'You know what makes me happy? [P], logging on to post a 2 part note about how horrid Hevige Nacht is, after being gone for most of its existance if not all, and then disappearing again.'
Mark did pull the plug on HN the day after P posted that two-part idea, so at the time I just thought Mark was being a sourpus because we complained loudly enough to make him back down on the issue.

Fast forwarding a few years, now I find myself in Mark's position. Players who haven't been logging, much less actually playing and keeping abreast of what's going on in the game, crawl out of the woodwork and posit these grand schemes about how aspects of Dark Risings are fundamentally broken. Forget all that business about actually experiencing the proclaimed brokenness, because Gedankenexperiments and weeks (or months) of absence grant supreme enlightenment.

Now, after having been rubbed the wrong way by a no-show player who proclaimed to have better insight into PK than those of us who actually watch and participate in it on a daily basis, I see why Mark reacted the way he did to P's idea.

So, although it's five years late, sorry Mark! I now understand.

Parviane

P.S. also, sorry to the guy who lost all his character's equipment that one night to prove my point about abusing HN. It was not nice, and rest assured, we did get yelled at for it.

Wednesday, April 13, 2011

Memories

If there's one thing science has taught me, it's that the best way to sell an idea is with pretty pictures. So, here's a pretty picture:


We've been having memory issues in the game intermittently since we came back, and the diagram offers a good illustration of the problem. When this bug first manifested, it so happened that I was trying to edit something on our game server and was rudely surprised by all manner of warnings about having insufficient memory to even open the text editor. Sure enough, somehow our game's memory footprint had blown up (seemingly overnight) to over twice its normal size, and there was very little to indicate what had happened. The solution then was to immediately reboot the MUD to flush memory and start from scratch, contact our provider and up our memory, and create a tool to keep track of our game's memory usage.

I've been checking the data dumped out by this tool daily to see if the memory blowup could be reproduced, and today was the first day I had a bite on the line. I suspected to find logs of someone doing something stupid coinciding with this big spike (like spamming haggle, exploiting some bug, etc), but there was nothing. Going back to my own personal logs of that morning though, the memory spikes happened around a time when Sidonie and I were working out some problems with a builder command. Ah-ha!

As it turns out, a very useful but not-often-used command that was put into the code many years ago had a very severe memory leak in it. The command uses the regular expression engine to parse boatloads of mobprogs iteratively, but the code wasn't cleaning up the tail end of the regex calls because the regex libraries silently malloc huge blocks of memory that aren't automatically freed when the parent routine exits.

This was a pretty easy mistake to make; while most high-level programming languages in which one would utilize regexes (like Perl, PHP, and whatever else) abstract away all of the memory management, C certainly does not. I guess the pitfall here is that the regcomp() call buried mallocs within it, so a headfirst dive into using regexes in C wouldn't directly expose the programmer to the mallocs which would raise alarms. An easy pitfall, sure, but like a wise man once said, "if you are going to write C code, you better be willing to deal with the memory management."

For what it's worth, I've gotten the game's code to be remarkably scarce on memory leaks like this despite the fact that I (nor any past coder of whom I know) has ever profiled the code with something like Valgrind or even gprof. While this case may give a pretty good argument for trying to figure out a realistic way to do this, blind dependence on tools like Valgrind to make up for incompetent coding has been known to cause serious problems. If we start running into memory leaks again though, maybe I'll try to figure out a way to set up profiling on a test port somewhere and have some of you players beat on it for a night.