Re-inventing the wheel. Sure, I could have used the
ip2c library from FireStats, or the geoip code from MaxMind,
but the former doesn't support shared memory and the latter
is just fugly looking code.

So, I just coded/tested/benchmarked a new
IP-to-country plugin for Active Analytics --
it'll be an optional, third-party plugin for Piwik. It can
search the database in either a flat file or shared
memory. (The difference is in the 10ths of a millisecond
per query on my antiquated test box.)

In hindsight, I wasted a lot of time over-3ngin33ring the
solution. I thought it would be safer to sign and check the
integrity of the shared memory segment for users in a shared
web hosting environment. I later realized this was a
non-problem because shared web hosting
doesn't offer access to shared memory (due to security and
resource concerns). This came as a relief because signing
and verifying killed the performance benefit of using shared
memory.