Archive for December, 2008

The Grand Theft Auto Debacle

Thursday, December 25th, 2008

Honestly, sometimes I wonder what the fuck is wrong with people.

At this point, I’d like to share a little gem of a quote regarding stupidity: “I say we just take the warning labels off of everything and let the problem solve itself.”

With that out of the way, I was reading an article about some or the other group getting all flustered about the upcoming Grand Theft Auto DS game, because it contains a mini-game which basically amounts to a version of Dope Wars. The inclusion of this now causes the glamourisation of drugs.

Right.

So, considering the games I played and the music I listened to when I was younger, I should’ve committed suicide (Marilyn Manson), blown out the brains of my classmates before offing myself (Doom), stolen cars and indiscriminately murdered innocents (GTA1), slept with, robbed, and murdered prostitutes (GTA3), killed a number of policemen (well, fuck, pretty much all of the GTA games), et cetera.

It’s retarded. Just because some people have problems distinguishing between fantasy and reality, and the concept of actions having consequences, doesn’t necessarily mean that all people are going to go out and have a GTA-inspired crime spree.

But, lest we forget, in the apologetic society we live in, we always have to cater for the lowest common denominator, and good grief, is that denominator ever so low, and ever so common.

Nyak.

Fallout 3

Thursday, December 18th, 2008

I’ve been spending quite some time now playing Fallout 3, so I thought I’d drop some remarks about the game here.

A lot of people on the Tubes are complaining bitterly about Fallout 3: my guess is that it’s partly due to (a) the “hardcore” Fallout fans who will deride any sequel that isn’t exactly like Fallout 1 and 2, and (b) the fact that Bethesda made it, instantly fixating it as Morrowind/Oblivion With Guns in most people’s minds.

(As an aside, there was a particularly humorous Fallout 3 screenshot floating around a while ago, consisting of the starting cell of Oblivion with the Fallout 1/2 status bar tacked onto the bottom.)

I’ve been playing FO3 quite regularly the past few weeks, and while it has its problems, the game is really quite enjoyable. The quests don’t feel quite too Fed-Exy the way Morrowind and Oblivion’s were, and there’s plenty of interesting things to see in the Wasteland (wait, what?).

One problem I ran into which I cannot fathom is a throw-back from Oblivion, which entailed me falling into the inside of a boulder, forcing me to load from an earlier save. This has only happened once, fortunately. Why Bethesda didn’t bother fixing this problem is beyond me, though.

The hyped-up V.A.T.S. system isn’t all it’s cracked up to be, either. I perform head-shots more consistently shooting at single pixels than bothering to aim with V.A.T.S. Mostly I use V.A.T.S. in conjunction with my scoped .44 Magnum or sniper rifle to figure out exactly what the hell that little blob moving in the distance is.

Mostly, though, I’m ignoring the bulk of the more long-winded quests, including the main quest, settling for wandering the Wasteland, searching for Interesting Things To Look At and Fun Things To Shoot At.

Yeah, that’s about it for now.

Gears of War 2: Retrospect

Wednesday, December 17th, 2008

I finished Gears of War 2 last night with my girlfriend (we started playing the campaign in split-screen co-op mode a while ago). Now, having completed the game, I’m undecided as to which is actually the better game. Gears of War 2 is absolutely stunning visually, and the storyline is much more detailed and polished than its predecessor. On the other hand, the ending left me feeling vaguely disappointed. In Gears of War 1, taking down RAAM was ultimately a much more satisfying experience for me than its sequel’s ending, which basically consists of mowing down a horde of stock-standard Locust, culminating in you and Dom hijacking a Brumak and mowing down more Locust with the daft amount of firepower mounted on the beast. The final “boss battle” (and I surround that phrase in double quotes because it didn’t really feel like much of one) consists of you blasting the everliving shit out of the now-Lambent Brumak with the Hammer of Dawn. A couple of satellite beam blasts and you nuke Brumak, cutting to the ending cinematic.

Wait, what?

So yeah, while I did enjoy the game, the ending left me feeling a bit of a “okay, what’s next?” vibe.

Oh well, now to carry on with Fallout 3.

Google Reader

Sunday, December 14th, 2008

I’ve been using RSS feeds to track updates for a few years now, and my reader of choice has been Liferea for most of that time. With the advent of me starting work, and not working on my laptop at the office, I moved over to Google Reader to share my feeds across all the computers I work on.

For some reason, I initially had an aversion to using Google Reader, probably because I wouldn’t have been able to read the summaries in any offline time I might have had. Now, though, that’s not so much of an issue anymore, since anywhere I have time to read feeds I have an Internet connection anyway.

Silly, really, because Google Reader is a top-notch feed-reading interface.

HP-UX SHM: initial results

Tuesday, December 2nd, 2008

This post is part two of my previous post, HP-UX, shared memory, and you.

I spent today implementing a shared library to override the C runtime library’s memory management routines: malloc, realloc and free, which passes the memory management requests along to the manager to allocate from the pool of shared memory. To test it, I wrote a small program that randomly performs allocations, reallocations, and deallocations for a set number of iterations to verify the correct operation of the shared library and the manager. For allocations and reallocations, the program also randomises the length of the memory block requested, with the upper limit to this random length set to 128MB. The results, surprisingly enough, showed that my shared memory implementation serviced the allocations significantly faster than using the base CRT methods. I’m not sure why this is yet.

With real world applications (i.e., standard UNIX programs such as ls and grep), however, my shared memory implementation falls behind the CRT. When I iron out the kinks left in the code tomorrow, I’ll be evaluating the performance of the shared memory implementation using the actual services on the development environment.

Friends With Benefits

Monday, December 1st, 2008

My girlfriend and I started playing Gears of War 2 in split-screen co-op mode yesterday, and 10 hours later (with one break for supper!) we’re 6 chapters away from completing the game.

All in all, Gears of War 2 is definitely a nice improvement on the first game, although some of the sections halfway through the game are a bit annoying, especially the Centaur driving section, which caused me a quite a bit of cussin’. Besides that, I’ll definitely have more memorable moments from this installment of Gears than the first game. Co-op mode is also a really cool way of playing the game, since you don’t have to deal with the sometimes idiotic computer player behaviour in your squad!

I still have to properly get into Fallout 3, since I’ve mostly been fucking around not really doing too much except exploring the Wasteland. I’m probably going to reload an earlier save and Do Things Properly.

Fable 2 screenshot

Fable 2 screenshot

The same applies for Fable 2, but in that game it’s actually a selling point that you can fuck around all you want! Such as murdering an entire village and feeling a warm, evil glow of satisfaction as your character’s appearance becomes oh so wonderfully demonic.

The Hero of Bowerstone? I prefer the title the Demon of Bowerstone, thank you very much!

HP-UX, shared memory, and you

Monday, December 1st, 2008

My current project at work involves doing some investigation into creating a daemon to allocate memory to processes using a pool of shared memory (SHM).

The reason for this is that the implementation of the C runtime (CRT) library’s memory management routines on HP-UX does not shrink the heap of a process. This effectively means that if you were to allocate a 512MB block of memory and then release that memory again, the operating system would still report your process as using 512MB of memory. Because of this, long-lived processes (such as services) that may use large amounts of memory to do processing at some point eventually dominate the memory usage of the system, even though they are actually using only a small part of this expanded heap on average. More specifically, the OS is basically reporting that there are 20 instances of a single service each using 1GB of RAM! Shared memory, on the other hand, obviously uses memory on the system, but since SHM isn’t tied to any specific process, it won’t cause the participating processes to display a huge amount of memory usage.

The other alternative is of course to change the way the service does processing, but this involves code changes in both the front and back-end parts of the software, so a shared memory allocator would be the path of least resistance in this case.

“But wait!”, you say, “Wouldn’t that involve changing the back-end code to make use of the new allocator anyway?” The answer to this is that, yes, it could, but there’s an easier option. The dynamic loader on UNIX uses a neat little environment variable called LD_PRELOAD which causes the shared libraries specified in it to be loaded before any other shared libraries. This allows you to easily override the CRT’s memory management routines, since yours get loaded first. This means that the amount of code that needs to be changed go from every memory allocation call to, effectively, none at all.

So we can have the manager allocate a big block of shared memory, and have the services communicate their requests for memory to the manager using UNIX domain sockets. The manager then attempts to service the request by reserving a block of shared memory for that process and passing the address back to the requesting process. The service can then map the shared memory segment into it’s own address space, use the memory for whatever it needs it for, and then tells the manager to release the memory again. Easy off bang!

Not quite, though.

HP-UX has support for both 32-bit and 64-bit operation. In 32-bit mode, the maximum size of a shared memory segment is 1GB, while in 64-bit mode, a shared memory segment may be up to 4TB in size. The systems we’re working on run a 64-bit kernel, so the maximum size of a segment isn’t the problem. The problem is that the processes themselves are 32-bit executables, and to understand why, I’ll need to talk about how HP-UX defines the memory space for a 32-bit executable.

32-bit mode implies a maximum addressable range of 232 bits, or 4GB of memory. In HP-UX, this 4GB virtual address space is divided into four quadrants of 1GB each. The first two quadrants are used for the process’ text and data segments. The third and fourth quadrants are used as a global shared memory space, with the final 250MB of the fourth quadrant being reserved for system I/O (my guess is that this is used for buffers when doing I/O operations). The global adjective means that any shared memory in the system will be (potentially) visible in any other process. Since shared memory does utilise access control when a process requests to map a segment into its address space, there aren’t any security concerns regarding that, though. What this does mean, though, is that the total amount of shared memory available in 32-bit processes is limited to 1.75GB. And by “32-bit processes” I mean all 32-bit processes currently running in the system.

Luckily, HP-UX has a feature known as memory windows. To use memory windows, the process to be executed is run using a wrapper called setmemwindow, which will execute the given command in a given memory window. The effect of this is that instead of the process having the normal 1GB global Quadrant 3, it receives a separate 1GB Quadrant 3 which is then shared by all processes belonging to the same memory window.

The idea I had is to use this feature by partitioning the services that require the shared memory pool into groups, and having them and their respective shared memory manager all belong to the same memory window. This frees up the global Q3 for other processes running on the system that might also use SHM, and allows multiple shared memory managers to execute in parallel with their own set of managed services.

The current status of my investigation, barring finding out about the above technical details, is that I’ve completed a basic manager process capable of reserving and releasing blocks of the shared memory segment to requesting processes, as well as a small test program that communicates requests to the manager. The next step is to write two programs that will perform random memory allocations, one using the SHM manager and another using the standard CRT, to get an idea of what the performance impact of the additional management layer will be.

Hopefully someone will find this useful, since I had to do quite a bit of Google-trawling to find out about all of this. If anyone wants a few of the references I used, feel free to leave a comment, and I’ll see if I can set you up.