In today's world of OOP programmers, of graduates with lots of Java knowledge and very little theory of computer science, the focus is on code re-use, and the attitude is one that little code tweaks are not worth the effort. A professor of mine once lectured: "I don't want to know how the phone works, I just want to use it." Unfortunately, that attitude doesn't lead to sustainable business practice. In my opinion, to be a good programmer, you need to be a little nutty for optimization. It's not a coincidence that some of the best coders in the world are in algorithmics, and many have great mathematical backgrounds.
I recently had to pick up after someone who had bloated a web based tool until it took 19 seconds to just load the main view. This was running off an 8x Core2 Xeon 2.4GHz server with 16GB of ram and 4x 30GB 15K RPM SCSIs in RAID10!
To give an example, on a summary page, he was re-using a function, that ran half a dozen queries, as a black box, applying it to every element in a list. For one element, this was a reasonable computation. It spat out the results in a little under a second. Naturally, when he took applied this to 20 list elements, the load time ballooned to 19 seconds. Multiply that by an average of 10 concurrent users, and you have pure CPU deadlock. (And a lot of angry customers!)
His method had significant computational overhead; table joins were performed repeatedly for each set of queries and, at each step, aggregated data (that would have been useful to other stages of computation) was discarded. So, I threw together a custom solution in a few hours and ran the same tests. My version ran in 0.7s (~93% faster).
I think it's an education problem. "Hold off the tough stuff until they've learned OOP; it's what business wants. With recent advancements in computing, the days of manually optimizing code are over. Relentlessly pursue code re-use and portability." That mentality doesn't always work. At some point, the control you lose when you layer: template over markup, over script, over server daemon, over virtual machine, alongside persistence layer, results in an army of programmers who can only tell you that they're finished coding, and it's too slow.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment