2 ms·
And from that, at some point you realize that the corollary to your #2 says that such hacks do apply to certain data types in certain environments. And then you
by TeMPOraL 9y ago
And from that, at some point you realize that the corollary to your #2 says that such hacks do apply to certain data types in certain environments. And then you've gained a very powerful tool to be used in specific circumstances.
There's a reason a lot of these potentially non-portable tricks show up in high-performance computing (particularly in videogames) and in the embedded space.
- zyx321 9y agoThat reason being that sometimes spending a 10+ hours on a tweak that gives +0.1% performance improvement is worth it. Otherwise, remember the first rule of code optimization for beginners: "Don't." EDIT: And by "they don't apply", I mean they can crash your program or even silently corrupt your data.
- kaslai 9y agoSometimes tweaks like these might only save 10-20 cycles, which in a vacuum doesn't sound like much, until you consider that before the tweak, it started at 26 cycles and is now 6 cycles, and it's called 50 million times every second, which is a savings of 100 million cycles per second. For games, this can mean a higher frame rate. For data processing, it can mean the data gets processed significantly faster. It's especially important for things like video encoders, where even a 1% savings in CPU time can translate directly to 1% more potential revenue for the same operating cost at a company that relies heavily on video encoding. Yeah, saving those cycles doesn't really mean anything to a beginner, but they can be a huge savings for high performance computation applications.