116 points · by signa11 · 10y ago · 45 comments
I especially love the way he explored how social interactions could change in a society made up of people who are really immortal computer simulations. A leader changing their apparent age during parts a speech to suit the tone, the same way someone today would shift between a large smile or stern expression based on what they're delivering. Or the couple having an argument, visibly presenting themselves as standing face-to-face, yet neither of them is able to really look at each other with their actual "viewport" (and neither of them is aware if the other is doing this).
I just might have to re-read it this weekend :) Or Axiomatic, as wyager suggests, I haven't read any of those stories yet.
You don't have to print the result within the body of code that you are timing (which would skew the result), but you must have some confidence that the benchmarking setup is sufficiently close to real-world usage conditions. This usually involves the computation now knowing how its result is going to be used.
(In a similar vein, I am also very skeptical about benchmark programs that hard-code their input, rather than read it at runtime.)
Yes, which is why the volatile qualifier exists: It makes modifying specific variables a side-effect, which then cannot be optimized away.
Yes, modifying is a form of access, but too is a read. Which means one can READ hardware register in a loop and expect it to change without compiler optimizing that out.
Please check the very definition of assert() macro.
https://en.wikipedia.org/wiki/The_Power_of_10:_Rules_for_Dev...
safety first
I'm very amazed by the simplicity of this example. Are there more serious optimization that can be seen with simple code?
http://stackoverflow.com/questions/11227809/why-is-processin...
Have a look at the "Update" to the top answer, specifically what the intel compiler does.
I've run into this problem several times. Something like a for loop that doesn't do anything but is supposed to eat up time will easily be eliminated, making your attempts at measuring the time taken a bit meaningless.
It's probably not that Microsoft's compiler is optimizing through the function pointer, but rather that it thinks that now() doesn't have to be sequenced. And its return value is just assigned to local variables, which have no interaction with the function being called. So if now() doesn't have to be sequenced, the initializations of those variables can be reordered.
This is definitely a bug somewhere between now this now() function is implemented, and how the compiler treats its definition or declaration. A clock-sampling function simply must be properly sequenced with regard to surrounding code.
It was self-hosting, and I made it insert the funky code on compile. I also made it do precomputation on most loops.
The benchmarks at the end of the year had very un-even time distribution, and everybody knew that we had done something funny (especially since our recursive slow fibonacci was the fastest by a factor of 8).
We knew we would get caught, but it was funny anyway. Someone else won because their compiler was actually good, but we got a new special "underhanded sneakyness" prize