http://qs1969.pair.com?node_id=681508


in reply to CPU cycles DO NOT MATTER!

I believe that the core points of this post are very valid, even though the title is somewhat misleading. “CPU cycles,” of course, do matter ... but only in a handful of situations. I don't fault this posting for its title; nor should we. Look beyond that.

“The 80/20 rule” is a familiar maxim that applies over-and-over to our industry in all sorts of useful analogies. Furthermore, most of the things that we actually want a computer to do, do not have CPU clock-speed as their primary, ruling constraint. The speed of any system is ruled by its slowest component. Which is inevitably I/O.

“Input/Output” can appear in unexpected places, though, and it can wear many disguises. For instance, I've spent a lot of time recently working with a group that loved to use hashes: big hashes. Very Big Hashes. Sometimes those hashes were “tied” to a Berkeley DB; sometimes they were not. But they'd sit there wondering why the processes were “so damned slow,” and they'd throw cluster-bombs of computers at those processes and they were still slow. I explained that, while they were well on their way to making a hardware-salesman very happy while they were busting their budget, those algorithms were doomed to be slow forever.

I patiently taught them about virtual-memory, and thrashing, and working-sets and page-faults. Then I taught them about the strategies that were used a half-century ago to do much bigger tasks than these with punched cards (and in much less time). Slowly the mind-shift began to sink in, but I do mean, slowly. But, one by one by one, the programs sure got faster!

One of the very best books on programming I have ever read is The Elements of Programming Style. (I still have the original FORTRAN edition.) Condensed into that tiny volume, in the best tradition of Messrs. Strunk & White, is a cornucopia of practical information elegantly presented. Such as:   Don't “diddle” code to make it faster... find a better algorithm.

A fundamental book on algorithms, such as How To Solve It should also be on your library-shelf and its well-thumbed pages should be chock-full of Post-It™ notes. (Your college “Data Structures” textbook, while arguably very-good, is not the same thing.)