Question

I think most of us strive to make our code run smoothly, read logically, and altogether function well. But for those who really enjoy taking the time to figure out how to optimize already good code (whether it's their own or someone else's), where do these individuals best find themselves in the programming world?

Whether that optimization is to improve on the current algorithm implemented in their project, take the time to make minor differences in performance, studying the run time of loops and conditionals in specific a language (for example, 3 or less if else statements are generally much quicker than 3 or less switch statements is some languages), or clean up code (useless variables, better modularize existing functions, etc.).

I imagine that a lot of these folks find themselves at home on projects critical to hardware performance, like fields related to microarchitecture. Anything else?

Was it helpful?

Solution

If they have competitors, then performance is a major criterion by which they are judged.

By the way, if you think performance is a matter of using switch vs. if, you're missing the point by an enormous margin.

You don't know what to fix in the code until you find out what takes time. That can seldom (i.e. never) be done by eyeballing the code. What I do is run it under a debugger and manually pause it at random to see what it's doing.

Here are some examples:

  • Spending more than 50% of time during application startup reading dlls in order to extract strings so they could be internationalized, but they were mostly strings the user never sees.

  • Spending a large fraction of time doing new and free, when previously allocated memory blocks could simply be re-used.

  • Spending a large fraction of time calling library routines like sin, exp, or log with the same arguments as last time. The prior results could just be remembered.

OTHER TIPS

Projects that have performance requirements.

It really doesn't matter what the hardware is. I can drive anything to 100% utilization. Same as I can fill any hard drive. The question is, can I ignore performance and still hit my performance goals. If yes, I am justified in ignoring performance.

Some projects find they have performance problems. If they wrote easy to read code while ignoring performance fixing the problem usually isn't hard.

If it is hard it might be research level hard. If you have the chops for that I'll keep you in mind if we ever run into that. Otherwise, I don't optimize for the fun of it. I'd rather it take 5% longer if that means to code is readable.

If you want reliable employment doing this seek out jobs that have pushing the hardware to it's limits as a goal. This can happen on microarchitecture, super computers, smart phones, data centers, calculators, cloud, toasters, and even the humble PC.

Embedded development.

When you're working with a tiny memory footprint and real time requirements you have to constantly be thinking about every aspect of performance, both speed and memory.

Real time embedded devices often require response times in the order of milliseconds in my experience. If a routine is off running for 10 seconds somewhere, you've just missed input from a button on your device. If you enjoy making things fast, real time can be an incredibly fun challenge.

Licensed under: CC-BY-SA with attribution
scroll top