Thursday, August 08, 2013
Programs from the past, Part IV: There Ain't No Such Thing As the Fastest Code
The point I want to make, though, is that the biggest optimization barrier that Terje faced was that he thought he had the fastest code possible. Once he opened up the possibility that there were faster approaches, and looked beyond the specific approach that he had so carefully optimized, he was able to come up with code that was a lot faster. Consider the incongruity of Terje's willingness to consider a 5 percent speedup significant in the light of his later near-doubling of performance.
Michael Abrash, Zen of Code Optimization
I'm probably belaboring the inanimate equus pleonastically, but this isn't the first time I've done so, so why stop now?
As was pointed out to me, I missed an obvious optimization in the map-generation program. That small change drastically changed the runtime of the C version of the program:
|Version||New Time||Previous Time|
Some other testing revealed that I can now generate in 37 seconds (remember, four cores running a stupidly parallel problem) that twenty-some years ago took a year to do—generate 500 map files.
And speaking of 37 seconds … thanks to the Classic Computers Talk Mailing List, I was able to run this latest code on a nearly identical SGI machine that I used twenty-some years ago—a 33MHz R3000 running IRIX 4.0.5.
Back then, the generation of one map took around ten hours, but I had missed a few optimizations that could have help speed up the program. And yes, it's true—the optimizations I've since added, plus using a high optimization setting on the C compiler, resulted in a map file being generated in 37 seconds.
On a twenty-some year old 33MHz machine.
The entire program run, which took a year, could have been done in less than 5¼ hours!
I think it's time to stop belaboring this inanimate equus.