6 ms·
There is a side effect like cpu temperature increase If I put my leg on my desktop tower then I may feel enjoyably warm or if I put some chocolate on my laptop
by hardware2win 2y ago
There is a side effect like cpu temperature increase
If I put my leg on my desktop tower then I may feel enjoyably warm or if I put some chocolate on my laptop then it may start melting
Also fans will be louder
- thfuran 2y agoNone of that is behavior according to the java (or any sane) language specification, so it can be optimized out of existence.
- hardware2win 2y agoIt is written in other, more general "specification" called physics Computers arent purely abstract, they exist in real world and are affected by it, so lets do not try to pretend otherwise
- lpapez 2y agoYet the compiler writers care only about the language spec, and you can bet that failing to optimize this as dead code would be considered a compiler bug. This goes not only for Java compiler, but many other languages as well.
- hardware2win 2y agoSometimes compiler engineers try to be too smart and they end up creating a mess :) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=8537 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=8537 >When optimizing code for "dead store removal" the optimizing compiler may remove code necessary for security.
- guappa 2y agoI'm going to point out that the bug is marked " RESOLVED INVALID "
- hardware2win 2y agoPolitical thing, but bug created by removal is real :)
- thfuran 2y agoWhat exactly do you expect an optimizing compiler to do?
- hardware2win 2y agoLeave code without obvious side effects alone (this is different from dead code)
- thfuran 2y agoBut this is code obviously without side effect.
- hardware2win 2y agoThere are side effects, but in real world, not abstract
- dkersten 2y agoSo non-obvious side effects? You can say that about any code at all, so no optimising would ever be possible. The program running faster is a side effect after all.
- thfuran 2y agoNo, that code has no side effects. The implementation is free to produce whatever side effects it wants or needs as part of execution, but that is absolutely none of the compiler's business.
- dzaima 2y agoWhat would "leave alone" even be? There's no "default" state of performance of Java code; it would be ridiculously stupid for there to be something saying that, say, "a+b" for int type values has to take at least 1 nanosecond or something. And you can't use big O complexity here either - the int type has a maximum of 2 billion, and thus a loop over it is trivially O(1), just with a potentially-big constant factor. (or, alternatively, the loop was sped up by a constant factor of 2 billion, and optimizing compilers should extremely obviously be allowed to optimize code by a constant factor)
- funcDropShadow 2y agoSo according to that "specification" no optimization is allowed. Since that would almost always change the "heating behavior" of code. Therefore, it is absurd.
- thfuran 2y agoNone at all, even out of order execution. For that matter, executing the same code on different hardware is right out. Every program must be implemented on single-purpose hardware, and you can't even manufacture two of them.
- The_Colonel 2y agoNot sure if being facetious, but FWIW you can't really rely on these. Next year you'll get a much faster CPU and memory and the timing will be all different. Or, tomorrow you run it while encoding video on the CPU which eats 99% of CPU, and it's hundred times slower.
- funcDropShadow 2y agoObviously, there is an xkcd for that: https://xkcd.com/1172/ https://xkcd.com/1172/