Sunday, March 26, 2006

You call that Democracy?

Glenn Greenwald does an excellent job of summarizing some of the recent opinions published by our President's administration. While our President is on a tour about the country try to convince us all that Iraq is actually progressing just fine, telling us that 'Democracy' is the One True Way, he is slowly perverting our own version of democracy here at home. Forget that we aren't a Democracy at the national level (we are a Republic). Forget that a Democracy just electing a 'terrorist' group to power in Palestine. If you were to believe our President, Democracy in Iraq will solve everything! Ignore the fact that we still haven't succeed in establishing a strong democratic government in Afghanistan and that the Taliban is regaining power there. Instead be proud that we restored public utilities to a small city somewhere in Iraq.

The US has had troops and contractors rebuilding Iraq for 3 years now. We don't have the oil wells back to their pre-war levels. We apparently can't even restore basic utilities to the pre-war levels either. This is what it means to be 'liberated'?

I do sympathize with our President on one thing. Having gotten where we are, what do you do? It is interesting to see how differently our President handles these repeated failures versus what happens in the corporate world. Microsoft has had a string of failures, delays, and setbacks over the last few years. What does it do? A significant shake-up at the top, is what they do! What has our administration done? As far as I can tell, they haven't significantly changed anything except their talking points. If our government was a publicly held company (which is kind of like a Democracy of it's shareholders... if you squint and tilt your head awkwardly) the shareholders and board would be demanding change.

We the people should demand change. Either the administration needs to demonstrate that it really takes it's failures seriously and is doing something about them, or there should be action in the streets. This is larger than pro-life vs pro-choice. This is about the future of our nation. The President uses the US as an exemplar of democracy, so we should demonstrate what it really means to be a democracy and what we expect of our democratically elected leaders.

Friday, March 17, 2006

The JIT that was too smart...

I spent quite a few hours this week tracking down a subtle performance drop that happened when I rewrote some code. This code is just a wrapper around the real code, yet I was seeing a 10-20% performance drop! I popped up the profiler and took a peek. I then scratched my head, looked at the code. Repeat a few dozen times.

The code basically looked like this:

main() {
run-a-few-seconds {
run-a-bit-longer {;

class Driver {
Test _test;

public void warmup() { warmup(_test); }
public void run() { run(_test); }

public abstract void warmup(Test test);
public abstract void run(Test test);

class MyDriver extends Driver {
public void warmup(Test test) { run(test); }
public void run(Test test) { do-something-hard(); }

You want to know what change regained that 10-20%? The above code is really all that matters... Let me tell you what the profiler showed me first.

I ran a profiler over both the old code and the new code and compared the results. The only noticable change was that warmup() was called dramatically less times on the old code, and took up more of the profile. Everything else was just noise. I've looked at a lot of profile traces and this one baffled me. Lucky for me, I only figuratively 'scratch my head' when pondering such problems, or else this one would have seriously left my poor noggin rather raw. I've never seen anything like this. The code was almost identical!

So I started iterating over all the ways that the code was different. There was also lots of setup code and other framework code that I don't show above (because it turns out not to matter).

After thinking about it out loud (lucky for me Rich was willing to sit and listen to me rant about this a few times) I came to the conclusion that the issue was the JIT. The setup was Java code and Sun's latest 1.5 jvm. To test this, I removed the warmup look, and sure enough, the older, faster times, fell back to the new, slower levels! So what could possibly be different between the two code bases to account for this?

class MyDriver extends Driver {
public void warmup(Test test) { run(test); }
public void run(Test test) { do-something-hard(); }

replace that with the below and that 10-20% regression went away.

public void warmup(Test test) { run(); }

I'll admit that I tried that change in a fit of despiration. A minor change like that couldn't have that kind of impact, could it? But it did.

My theory? The main loop, and the Driver class are in one jar, while MyDriver is from a different jar (that was loaded by a custom class loader). It might be that because of inlining the call to do-something-hard() seemed to occur in a different context, which forced a reJIT.

Either way, fancy HotSpot(tm) JIT 'intelligence' cost me a few hours for something that just doesn't seem like it should matter. It makes me miss good old-fashion compilers.

Monday, March 13, 2006


I just got back (last night) from a week in Switzerland. mmmm cheese.... An amazing trip, made extra intersting by staying with my better-half's family there. Nothing like the local experience to really get a feeling for the culture. Not that I understood a word of what people said. I do get to take pride in knowing that there are some other tourists taking home pictures of the Fastnacht parades with me wearing a terrifying looking clown costume. That is truely priceless.

But... when did alcohol stop being free for international flights? When will they have power plugs in economy? How did Delta manage to loose both my baggage (coming home) as well as my better-half's sister's luggage going there?

Now I have about 2gb of pictures and movies to wade through. That should be fine since it will give me a good excuse to sit and eat some of the chocolate we brought back.