Sunday, February 8, 2009

Do less work

It's better for all involved.

All forms of optimisation involve doing less work. There is no debating this.

Quicksort is optimal. Sedgewick showed this mathematically (and his mentor, the great Knuth agreed) in terms of the amount of work done and movement of data elements required.

The rules are simple:

  • Don't poll - let the runtime / OS tell you when there is work to do
  • Respond to events, don't anticipate conditions.
  • Dispatch quickly
  • Decouple and hand off work units - seeing to completion only increases latency and reduces throughput
No number of threads and processors negate these rules. Sorry Sun - Niagra doesn't relieve us of thinking at least somewhat.

No comments: