5 ms·
Currently for game development optimizing compilers are useful but hardly free you from worrying about optimizations. At least when you are using C++: a) Opti
by jstelly 11y ago
Currently for game development optimizing compilers are useful but hardly free you from worrying about optimizations.
At least when you are using C++:
a) Optimizing compilers can't organize your data to be cache friendly.
b) optimizing compilers can't re-organize your code to prefer sequential access to that data so the HW prefetch can prevent cache misses
c) optimizing compilers can't separate out the parallelizable parts of an algorithm and push those into threaded jobs
d) optimizing compilers can't find most cases of work you are doing that doesn't need to be done. They find some trivial/local cases of this but not any of the deep or difficult cases.
e) compilers can't rewrite your code or data to not need features or to use simpler features that can be optimized
f) compilers can't generate caches (as in the simple example in the article) and find and handle all of the cases where they need to be updated.
If you are working on an application where performance is one of the most important features (like many games) you will find yourself working on performance problems like these often. In even higher level languages compilers have more flexibility around some of the fundamental constraints in the C++ world, but there are still few cases where those compilers produce faster code than humans do with C++. Of course the optimized C++ usually requires vastly more effort and returns to that effort are diminishing over time with faster hardware.
- vitalyd 11y agoOptimizers are mostly about stripping away abstraction costs of the language. If anyone is asking for more, they're disillusioned :).
- roel_v 11y agoThat's very generous of you, but I think that "delusional" isn't an exaggeration in this case...
- Athas 11y ago> At least when you are using C++: This is a very important caveat! It probably doesn't mean much for the pragmatic programmer today, and probably tomorrow, but there are research languages and compilers that try to tackle some of these issues. I myself am working on a compiler for a functional language, that already solves (a) and (b) in some cases, and (c) is doable by using an inherently parallel language. Issues (d)-(f) are about deeper algorithmic changes, and beyond even the frontiers of current research (although you can probably do (d) with a supercompiler if you have enough time).