Internet on the South Pole

August 17, 2006

I’ve occasionally wondered how they manage to get Internet to research bases at the North or South pole. You migth think they’d use satellites, but to communicate with a satellite you need direct line of sight; communications satellites in geostationary orbits, due to the curvaceous nature of our planet, are under the horizon and cannot be seen from the poles.

So how do they do it? Cable? Pretty unthinkable, I thought. However, according to this article that’s exactly what they’re planning to do: lay a cable nearly 2000 km across the polar ice to the South Pole. It also, more interestingly, explained how they currently manage to get Internet access: by exploiting ageing communications satellites that have drifted out of their geostationary orbits and can therefore be just seen part of the day…

On Comments and Akismet

August 16, 2006

Since I allowed people to comment without being logged in less than 48 hours ago, Akismet has caught 47 spam comments. If that was all I might have turned off comments again, but I’ve actually had one helpful comment. So comments are staying on for the time being. Thank you Akismet.

Comments

August 14, 2006

Having installed the Akismet spam plugin some time ago I have now turned off the setting that requires visitors to be logged in to leave a comment. Frankly, I didn’t know that this setting was on, but it turned out it was. That explains why I’ve not had any spam at all lately.

Hippies

August 13, 2006

Nadia and I are turning into hippies. I bake bread for our breakfast and Nadia cook most other meals from first principles. We save plastic by reusing bags when we go to the shop, and generally refuse a bag when we only buy one or two items. We don’t have a TV.

It started getting out of hand, however, when we moved to Islington a couple of months ago. I now walk to work, we got rid of the car and hung Nadia’s bike in the communal bikeshed. There’s the wonderful Islington Farmer’s market every Sunday where we can pick up seasonal fish, meat and veg; and we can get organic meat and veg delivered straight to the door (somewhat ironically, we lived too far away from the city centre earlier).

Before we knew it the detergents became eco friendly, the soap turned organic (it has oats in it, fercryingoutloud) and we’re eating new grains like guinoa and millet. The fruit and veg we eat varies with the season; Nadia wants a small herd of goats; and flocks of ducks, chickens, pigeons & quails; not to mention a fjord horse or two.

GGTL and SL in Debian

August 13, 2006

My GGTL and SL libraries are now available in Debian unstable, curtesy of a finnish hacker. Here’s links to the source packages for GGTL and SL.

This post is not an SVK tutorial; it simply describes how I use SVK to keep multiple blogs up to date whilst very conveniently keeping track of individual local changes to each site. The approach is essentially vendor branches with a twist.

Initial setup

I’ll pretend that you have an SVK depot already.

  1. Download a version of wordpress and unpack it
  2. cd ~/wordpress
  3. svk import //vendor/wordpress -m ‘importing wordpress vendor version’
  4. svk cp //vendor/wordpress //template -m ‘create template’
  5. import desired themes to //vendor/themes
  6. svk cp //vendor/themes/ //template/wp-content/themes -m ‘added themes to template’
  7. import desired plugins to //vendor/plugins
  8. svk cp //vendor/plugins/ //template/wp-content/plugins -m ‘added plugins to template’
  9. svk cp //template //yoursite.com -m ‘my site’
  10. svk co //yoursite.com /web/yoursite.com (assuming this is where your webserver expects it)
  11. cd /web/yoursite.com
  12. svk mv wp-config-sample.php wp-config.php [*]
  13. edit wp-config.php to point to your database
  14. svk ci -m ‘know where to find my db now’

If you want a second site, repeat the last five steps above.

[*] If you want, you can do this step on //template, before you copy it to //yoursite.com, instead.

Updating to a new version

Whenever you want to update your blogs (say, when 2.0.5 comes out) you just import that version over the current vendor version and merge it into your template:

  1. cd ~/wordpress-2.0.5
  2. svk ci –import //vendor/wordpress -m ‘upgrade to 2.0.5′
  3. svk smerge //vendor/wordpress //vendor/example.com/ -m ‘upgrade to 2.0.5′

Then, for each site, perform the following two steps:

  1. svk smerge -t //yoursite.com -m ‘upgrade to 2.0.5′
  2. svk up /web/yoursite.com

Making local changes that persist across upgrades

Making local changes is a doodle. In fact, you’ve already done this. Whenever you upgrade, the changes to wp-config.php will keep the changes you made to it. Let’s pretend, however, that you’ve made a change to a theme or a plugin, or to wordpress itself, that you want available in all your sites. Here’s how you do that:

  1. run svk log //yoursite.com and note the revision number of the changeset you want
  2. svk merge -c $REV //yoursite.com //template -m ‘propagate good change’

Then, update each site from the template as shown above under Updating to a new version.

In-sewer ants

August 12, 2006

I remember laughing very hard at a comic-book joke as a kid. A red indian with horrific injuries goes to visit his doctor:

—What brought this on?
—I was out hunting when an eagle attacked me, but luckily it dropped me in front of a flock of runaway buffallo!
—Luckily?
—Yes, it’s the only thing my medical insurance covers!

I used to find it hilarious back then, but having now started looking into insurance I realize that the joke’s on me, and I don’t find it so funny anymore. Here’s an exerpt from the exclusion clause in Abbey’s accident cover:

We will not pay benefits for an accident that is directly or indirectly the result of:

  • war, invasion, acts of foreign enemies, civil war, rebellion, or being on naval, military or air force duty, service or operations;
  • riding a motorcycle or moped as a driver or passenger;
  • scuba-diving, rock climbing or mountaineering of any type, potholing or parachuting;
  • competing in any race other than on foot or whilst swimming;
  • exposure to exceptional danger (except in an attempt to save human life);
  • the manufacture or use of explosives;
  • flying except as a fare paying passenger;
  • your suicide, your own illegal acts, your intentional self-inflicted injury, whether you are sane or insane;
  • being under the influence of or being affected by alcohol or drugs unless under the advice of a doctor for a conditon other than alcohol or drug addiction;
  • radiaton or contamination or the effects of radiation;
  • HIV, AIDS or any related condition or disease
  • you having any sickness, disease, naturally occurring condition, injury or degenerative process.

If the poor red indian in the joke above had had this insurance, I’m pretty sure the cretins would have managed to weazel their way out of paying for his claim.

Rise of the Machine

August 12, 2006

Last week Norman Nunley got me interested in the ICFP challenge 2006, despite it being over. It involved implementing a Universal Machine following a (hilarious) spec. This was needed to run a program that you were given; this program would then give you instructions on what to do from there.

I had never written a virtual machine before: I always imagined it too hard to even try. I was wrong. It took me around 7-8 hours; spread over an evening, the following morning and a couple of hours at work (sorry boss, it was too addictive—I blame Norman); to get a working machine. I did most of the work alone, but I needed Norman’s help to clarify parts of the spec and in some debugging.

I was amazed when it turned out this “huge scary thing”, which I’d imagined a VM to be, clocked in at less than 300 lines of C. It wasn’t fast though. A self-test and benchmarking program for the UM was available from the ICFP website. Norman’s UM ran this benchmark in minutes but mine, distressingly, took over 10 hours.

Last Saturday, after eliminating a few variables and assignments in the hotpath and using macroes instead, I managed to get the time for the benchmark program down to just over two hours. A whole lot better, but still way slower than others’ VMs. From basic instrumentation I knew that the benchmark program does a lot of memory allocation and deallocation, and I surmised that this the cause of my performance problems. During the course of the weekend I tried various things to speed my VM up further by caching previously allocated arrays in various ways. Whatever I tried, however, simply made it slower. It was a humbelling experience that reminded me that I should have faith in the library implementors; they’re most likely smarter than me.

The performance of my VM continued to bug me and Monday morning. My VM has an array of pointers to unsigned integer arrays, which the benchmark program required a whole bunch of. Indexes into the parent array are used to identify which leaf array it required and therefore I could not change the index of a leaf array and when a leaf is freed up I end up with a sparse parent array. My fallacy was to use a sequential scan to find the first free location in the parent array, when allocating a new leaf; as it turned out, this was really expensive. When I tried to just allocate new leaf arrays at the end of the parent array and simply allowing the parent array to be very sparse at the front, my VM suddenly ran the benchmark in just over three minutes. A considerable speedup, but it didn’t come for free. As I didn’t reuse any of the slots in the parent array the memory usage grew steeply to about 140 MB, up from around 3 MB throughout the entire run previously.

The morale is clear: Find your bottlenecks, then eliminate them; don’t try to eliminate imagined bottlenecks (I already knew this, but it doesn’t hurt to be reminded once in a while). I originally assumed that my performance issues was related to memory allocation. I was partly right, but it was not due to malloc() or free() being slow, as I had assumed. It was down to my stupid algorithm for finding somewhere to stash the newly allocated array.

Update: By making use of C99’s flexible array member and introducing an extremely simple free list I’ve now managed to get the memory usage for my VM down to 2.16 MB (as reported by top on my Powerbook) for the benchmark run, at a cost of adding about 40–50 seconds to the run time. The flexible array member feature allows me to do only one allocation instead of two when allocating an array wrapped in a struct; this can yield large memory savings if you’re allocating a lot of structs containing short arrays. The free list simply holds indices to free slots in the parent array.

Update, 2007/09/03: Here’s my Virtual machine, should you wish to take a look.

Girls Read Comics

August 11, 2006

And they’re pissed. An awsome blog.