3 ms·
If the intent of those code optimizations are so damn hard to understand and there are such subtle bugs they avoid in very specific ways, why isn't there a comm
by brazzy 14y ago
If the intent of those code optimizations are so damn hard to understand and there are such subtle bugs they avoid in very specific ways, why isn't there a comment to explain the intent and a unit test to ensure it's not broken?
Sounds like it's not those other engineer's fault that this kind of thing keeps happening to your code...
- jandrewrogers 14y agoThe code is perfectly clear and well-documented. In most of the cases, the problem is that most software engineers have no clue how the hardware (or operating system) their software runs on actually works. Consequently, they are oblivious to potential side-effects of innocuous-looking code changes that the original author accounted for. There is always documentation explaining the optimization and intent but many engineers do not have the background knowledge to understand how that is achieved. The code optimizations are easy to understand if you know how to optimize code. The problem is that most software engineers do not, nor do they know what optimizations look like even when the code itself is easy to understand. So the best we can do is annotate that code with the fact that some important optimizations were made there and to understand the nature of those optimizations. Also, it is difficult to impossible to unit test many optimizations. Many of them are about minimizing interactions between concurrent but unrelated processes or minimizing the latency of some code path. The functionality can be correct and fast in unit tests and the run-time behavior in operational environments still be pathological because of potential interactions that are nearly impossible to replicate in the unit test environment. You can run simulated workloads but those are much more expensive to do and for any kind of non-trivial system the coverage will be poor relative to the kinds of problems you may have.