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 [1]

I'm probably belaboring the inanimate equus pleonastically, but this isn't the first time [2] I've done so, so why stop now?

As was pointed out to me [3], I missed an obvious optimization in the map-generation program [4]. That small change drastically changed the runtime of the C version of the program:

Table: Latest timings to generate a map file
Version	New Time	Previous Time
------------------------------
Lua [5]	15.50s	16.25s
LuaJIT [6]	0.65s	1.25s
C	0.22s	2.60s

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 [7], I was able to run this latest code on a nearly identical SGI [8] machine that I used twenty-some years ago—a 33MHz (megaHertz) R3000 [9] 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.

Head. Desk.

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.

[1] http://www.amazon.com/exec/obidos/ASIN/1883577039/conmanlaborat-20

[2] /boston/2008/01/05.1

[3] http://www.reddit.com/r/programming/comments/1jvtkq/hello_jit_world_the_joy_of_simple_jits/cbjald1

[4] /boston/2013/08/06.1

[5] http://www.lua.org/

[6] http://luajit.org/

[7] http://www.classiccmp.org/cctalk.html

[8] http://en.wikipedia.org/wiki/Silicon_Graphics

[9] http://en.wikipedia.org/wiki/R3000

Gemini Mention this post

Contact the author