I'm a great Cary Milsap fan. He recently released a book called Faster: How to Optimize a System. Although I'm not done, I'm impressed with the content. It provides a well-thought-out framework for the system optimization. Here, I would like to elaborate on one such optimization model that Cary calls. Fix it vs. Feed It decisions.
In the world of performance tuning, the big question we all ask ourselves is "How do we improve response time?"
The reflexive answer is to improve one of these elements.
CPU
Network
Storage
Although the above answer is true, if we ask what is the common phenomenon which we do through these three elements are.
Reduce the quantity (of CPU/Network/Storage)
Reduce the price for the unit of work
At a macro level, a program/job can be decomposed into sets of events (i.e., read, write, wait). Events are the fundamental building block to observe the programs’ efficiency. There are two approaches in speeding up the execution of a piece of code.
To reduce the total duration of a program, there are a couple of levers which we can pull.
Reduce the number of events.
Reduce the per event duration.
Let’s take an example here, A SQL query which needs to process 100 GB of data to give an output of 1 GB. During the execution, the query would have to eliminate 99% of its input data to give the required output. If we have to optimize the runtime further, there are two high level approaches we can take.
Approach # 1). Add a powerful hardware, so that the read, write and execute time would improve.
Approach # 2). Fundamentally change the way the query runs.
Cary calls the former (#1) “Feed it” and the latter (#2) being “Fix it” approach.
By feeding extra hardware, you may be able to get the required gain, however the clean approach is to see if there is any way to change the data access patterns so that the number of events itself can be reduced.
Taking a SQL query as an example, “Fix it” directs us to ask the below question,
“How can I eliminate the majority of the rows in the first few steps of the execution plan?”
With Cloud service at play, “Feed it” is becoming very easy to implement. However, the incentives are more for “Fix it” decision as your every CPU cycles are metered.