The Fastest Possible Version of a Tenth of Your Program Buys You Eleven Per Cent
Last timeThe Cost You Did Not Write
One fraction sets the ceiling on every optimisation before you start it. Computing it first tells you which change is worth making and when to stop making them.
The share you can touch
Every change you could make affects some part of the run time and leaves the
rest alone. The part it leaves alone sets a limit on what it can achieve, and
the limit is usually the thing nobody computed.
- the overall speedup you end up with
- share of the run time the change can affect
- how much faster that part becomes
Three words in the definition of p do the work. It is a share of the time,
measured, not a share of the lines of code and not a share of the operations.
It is the share this particular change can affect, which is narrower than the
share of time the function takes. And it comes from measurement rather than
from reading, because every lesson in this course has been an example of the
source being a poor guide to where the time goes.
| share, per cent | ceiling if that part bec | ceiling if it becomes tw | |
|---|---|---|---|
| a tenth of the time | 10.00 | 1.11 | 1.05 |
| a fifth | 20.00 | 1.25 | 1.11 |
| under a third | 30.00 | 1.43 | 1.18 |
| half | 50.00 | 2.00 | 1.33 |
| most of it | 70.00 | 3.33 | 1.54 |
| nearly all of it | 90.00 | 10.00 | 1.82 |
The practical use is as a filter applied before the work. Somebody proposes
rewriting a component in a faster language, or widening a loop, or replacing a
data structure. Ask what share of measured time that component holds. If the
answer is six per cent, the proposal is capped at six per cent, and it does not
matter how good the rewrite is.
The lesson stops here
5 more paragraphs to go
You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.
The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.
See the planThe contentsThis is the reading half
Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.
The contents