The hierarchy of resource costs
I saw a post over at Jeremy Millers blog where he recounts a WTF system he worked on.
Towards the end he lists some lessons learned.
Network round trips are evil. At lunch today we were laughing atdevelopers who obsess about optimizing string concatenation whilewriting systems that are chatty to the database
One trick I use to determine where I should start optimizing a legacy system during my forensic development phase is a resource auction. I look at what resources the code is using and assign points based on how big a drag on the system the resource is. For Example, network resources get 5 points, network resources that hit the filesystem (e.g. a database connection) get 7 points. Loops get 1 point. Code that hits the local filesystem gets 3 points. Web services outside of the firewall get 10 points, Etc…
The idea isn’t to scientifically determine the point value any particular resource gets, just to place them into a hierarchy. Worrying about how much reflecting over a small object will cost you doesn’t mean so much if you have to make 5 database round trips for each object.
This isn’t to say that you should write code willy-nilly or inefficiently if you have to access a web service. But having a system like this makes it easy to see where the slowdowns are without having to install and run a bunch of profiling software.



Pingback: Gaidar's Blog