Simplifer non-determinism leading to 8 fold difference in run time performance
I've been chasing a weird performance bug for about a week now. I've reduced the testcase to the following git repo:
The Readme.md file in that repo contains an explanation of how to reproduce the issue.
The benchmark program in the repo uses Criterion to test the performance of one particular function. Running the program in a particular way results into two significanlty different results.
The commands are:
make clean bench-integer.html cp -f bench-integer.html bench-integer-slow.html touch New3/GHC/Integer/Natural.hs && make bench-integer.html
The results for one function in the file
New3/GHC/Integer/Natural.hs is 8 times slower in the first test that the second while the other test function always executes at about the speed.
I haven't been able to test this with ghc-7.6.3 because the code uses
isTrue# which isn't available in 7.6.3.
Compiling the whole project results in the function under test running 4 times slower than the comparison. Touching the file containing the function under test and rebuilding the benchmark program results in the function under test runing 2 times faster than the comparison function.
Dumping intermediate files showed that the output of the simplifier was different enough to create this 8 fold difference in performance.
The simplifier should be deterministic. Same input file should result in the same simplifier output, preferably the output that results in 8 fold better performance.