What I did on my Summer Holidays

I “just got back” (actually, last week) from a week at the Alders Beach Resort, a lovely place about 200km north up Vancouver Island. The Alders isn’t so much a “resort” in the conventional sense (well, in the conventional sense of 50 years ago), but rather a collection of mildly run-down cabins, full of families and kids, located on a tidal beach, tucked into the woods, comfortably far from pretty much anything stressful.

I had lots of time on my hands, and one can only watch children play with sand for so long, before the mood strikes, so what I did with my holiday was try to figure out how to build sand sculptures.

The Alders has been around for 50 years, and there were people at the resort last week who had been going to 15 years straight, whose kids grew up there. It is going to be a family holiday staple for us, for many years to come.

More Mapping Insights

From Andrew Turner, the Urban Spoon spatial-temporal map of restaurant seeking. Among the insights you can glean from this data presentation:

  • People look for restaurants in cities full of people, not in the wilderness.
  • People don’t look for restaurants when they are asleep.

Perhaps a zoomed in view of San Francisco would be more interesting.

The Geography of Manufacturing

It’s a shame I’m not a geographer, because there are probably some interesting sociological nuggets hiding in the way manufacturing has dispersed across the USA over the past 40 years. This weakly reasoned article in Salon includes the point that auto manufacturers are locating their US plants in the South. Why so?

Union avoidance probably has something to do with it. But the price efficiency of a dependent labour force has to balanced against the inefficiency of being separated from a concentrated nexus of talent. Jane Jacobs, in the “Economy of Cities”, talks about the self-reinforcing nature of the skills networks that develop in cities, and you don’t have to look far to see them in action. Silicon Valley, Hollywood, the Research Triangle, etc, etc.

Oddly, the USA has some world class geographic nexuses of intellectual talent, while the manufacturing base has dispersed. Intellectual work is highly portable (I’m writing in a coffee shop, linked into a client’s VPN, and compiling a library on their machine) and virtual. Manufacturing work is heavy, with physical objects to move around. Why aren’t all the auto parts manufacturers, secondary assembly plants and final auto assembly still located in Michigan?

Clearly the cost of moving things around has fallen so much in recent years that factory sites can be chosen on other bases (prevailing wages, tax holidays) instead. I would also guess that the automation of parts of the assembly line has lowered the required skill specialization of line workers, so that having access to a pool of qualified talent in a factory hub has become less important too.

I wonder if increases in the cost of transport will cause some manufacturing to geographically re-integrate, so Boeing (for example) will stop shipping wings around the world, and their parts suppliers will find it more economical to set up satellite production closer to final assembly in Seattle.

Maybe if I beg, FortiusOne will dig up some cool maps on this topic. Please? Pretty please?

Valgrinding PostGIS

So, you want to be a super-hero? How about tracking down memory leaks and otherwise using valgrind to make PostGIS a cleaner and better system? However, getting PostGIS into valgrind can be a bit tricky.

First of all, what is valgrind? It’s a tool for finding memory leaks and other memory issues in C/C++ code. It only runs under Linux, so you do need to have sufficiently portable code to run it there. Many memory checking tools rely on “static code analysis”, basically looks at what your code says it does and seeing if you have made any mistakes.

These kinds of tools have to be very clever, since they not only need to understand the language, they have to understand the structure of your code. Valgrind takes the opposite tack – rather than inspect your code for what it says it does, it runs your code inside an emulator, and sees what it actually does. Running inside valgrind, every memory allocation and deallocation can be tracked and associated with a particular code block, making valgrind a very effective memory debugger.

In order to get the most useful reports, you have to compile your code with minimal optimization flags, and with debugging turned on. To grind both GEOS and PostGIS simultaneously, compile GEOS and PostGIS with the correct flags:

# Make GEOS:
CXXFLAGS="-g -O0" ./configure
make clean
make install

# Make PostGIS:
CFLAGS="-g -O0" ./configure --with-pgconfig=/usr/local/pgsql/bin/pg_config
make clean
make install

Once you have your debug-enabled code in place, you are ready to run valgrind. Here things get interesting! Usually, PostgreSQL is run in multi-user mode, with each back-end process spawned automatically as connections come in. But, in order to use valgrind, we have to run our process inside the valgrind emulator. How to do this?

Fortunately, PostgreSQL supports a “single user mode”. Shut down your database instance (pg_ctl -D /path/to/database stop) first. Then invoke a postgres backend in single-user mode:

echo "select * from a, b where st_intersects(a.the_geom, b.the_geom)" | \
  valgrind \
    --leak-check=yes \
    --log-file=valgrindlog \
    /usr/local/pgsql/bin/postgres --single -D /usr/local/pgdata postgis

So, here we are echoing the SQL statement we want tested, and piping it into a valgrind-wrapped instance of single-user PostgreSQL. Everything will run much slower than usual, and valgrind will output a report to the valgrindlog file detailing where memory blocks are orphaned by the code.

Google SLA Quest

I host my @cleverelephant.ca email using Google Apps, and I even go so far as to pay the $50/year for “Premier” service to have no ads on my account. Having self-hosted infrastructure for 10 years at Refractions (I was President, CEO, and sysadmin for too many years), it has been pretty pleasant to have zero maintenance issues keeping my email online, my spam well filtered, my web pages up.

However, he who lives by the cloud, dies by the cloud.

Yesterday, my web mail access was unavailable for about one hour, exceeding the 99.9% availability per month guaranteed in the Google Apps SLA. For those doing the math, 99.9% availability means that 45 minutes per month of downtime is considered acceptable.

So, I am going to try and get my account credit of three free days of service (retail value, 3 * $50 / 365 = $0.41) from Google. (Does anyone else think that’s a pitiful SLA credit? If they go below 95% uptime (37 hours of downtime) they will credit you a whole 15 days of service – $2.05.)

Step one, who the heck do I contact? Unfortunately, the SLA is completely silent on the matter. Presumably someone in “support”, so I go hunting through the support pages. There we find a reference to 24x7 support for Premier customers (my $50 in action!). And at the bottom of that page, the answer:

You can submit a priority email request as follows:

  • Log in to your Google Apps control panel.
  • Click on ‘Domain Settings,’ then on ‘Account Information.’
  • Click ‘Contact us online.’

So, I submit my request for account credit, and wait. I get an auto-response right away saying they have created a ticket. So the clock is running on Google support, started at 4:30pm, Monday August 11. How long to a response? Updates will follow.

Update (Aug 12, 11:40pm): Received a human response from the Google collective. No answer on the SLA credit yet.

Hello Paul,

Thanks for your message.

I’ve reviewed your report and have forwarded the information you provided to the appropriate team for additional investigation. I appreciate your patience and apologize for any inconvenience this may have caused.


The Google Apps Team

Update (Aug 15, 5:46pm): More signs of life at the GooglePlex:

Hello Paul,

Thanks for your response.

Our billing team is currently reviewing this case. We will let you know when we’ve processed your service credit request.

You can continue to contact the support team, who can advocate on behalf of your domain in situations such as these.

Thank you for your continued support and patience.


The Google Apps Team

Update (Aug 27): The big G has decided that the August down-times warrant a big Mea Culpa. Clearly committed to keeping faith in the cloud high, they are extending a larger credit that strictly required to all us Premiere customers (not just whiners like me):

Given the production incidents that occurred in August, we’ll be extending the full SLA credit to all Google Apps Premier customers for the month of August, which represents a 15-day extension of your service. SLA credits will be applied to the new service term for accounts with a renewal order pending. This credit will be applied to your account automatically so there’s no action needed on your part.

Top marks to the big G, way to not be Evil!