[GHC] #9646: Strange performance bug

#9646: Strange performance bug -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Unknown | Type of failure: Runtime Blocked By: | performance bug Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- I've been chasing a weird performance bug for about a week now. I've reduced the testcase to the following git repo: https://github.com/erikd/ghc-perfbug-test 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. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Strange performance bug -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Runtime | Blocked By: performance bug | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by jstolarek): `isTrue#` is an alias to `tagToEnum#`, so you can convert your code to GHC 7.6. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Strange performance bug -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Runtime | Blocked By: performance bug | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by dfeuer): I don't know what's going on, but I'm curious whether there might be some sort of interference from `make` or associated OS or CPU stuff. Have you tried running the benchmarks separately from the compilation process? Another thing to experiment with is reversing the order of the Criterion benchmarks to see if the slowness follows the position in the benchmark list. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Strange performance bug -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime | Difficulty: Unknown performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by erikd): * os: Unknown/Multiple => Linux * architecture: Unknown/Multiple => x86_64 (amd64) Comment: @jstolarek : It looks you you do not have the criterion library installed. @dferuer : * Changing the order of the benchmarks makes no difference, the New3* runs still exhibit the same behaviour. * The `make` program is not a factor. I can take the commands printed using `make -n` and put them in a shell script for the same result. * Running the benchmarking program separately from the compile process gives almost identical results. I've also assured myself that the ghc command: {{{ ghc -Wall -Werror -fwarn-tabs -fPIC -ddump-to-file -ddump-prep -ddump-cmm -ddump-opt-cmm -ddump-stg -ddump-asm -O3 -XCPP -XMagicHash -XUnboxedTuples -XUnliftedFFITypes --make bench-integer.hs -o bench-integer }}} is the same in both cases. This is to be expected as `make` really just calls this `ghc --make` command. Behaviour is also the same with `-O2` and `-O1`. I tried compiling with `-O0` which gave radically different results but there were no interesting conclusions to be drawn. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

@jstolarek : It looks you you do not have the criterion library installed. I have `criterion-1.0.1.0` installed in a cabal sandbox. Perhaps your make
#9646: Strange performance bug -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime | Difficulty: Unknown performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by jstolarek): Replying to [comment:3 erikd]: script does not recognize sandboxes? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Strange performance bug -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime | Difficulty: Unknown performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by erikd): @jstolarek : No, my Makefile does not recognize cabal sandboxes. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Strange performance bug -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime | Difficulty: Unknown performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by erikd): I added a a number of -ddump-* flags and reduced the `New3/GHC/InteterNatural.hs` file to contain nothing but the `timeNatural` function that we're interested in. What I found was: * Desugar stage output (file Natural.dump-ds) output is identical. * Simplifier stage ( (file Natural.dump-simpl) is different. I've added the fast and slow versions of the .dump-simpl outputs. The slow version of the code seems to have a lot more let bindings that the fast version. The fast version is more like to use case expressions. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Simplifer non-determinism leading to 8 fold difference in run time performance -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime | Difficulty: Unknown performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Simplifer non-determinism leading to 8 fold difference in run time performance -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime | Difficulty: Unknown performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Description changed by erikd: Old description:
I've been chasing a weird performance bug for about a week now. I've reduced the testcase to the following git repo:
https://github.com/erikd/ghc-perfbug-test
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.
New description: I've been chasing a weird performance bug for about a week now. I've reduced the testcase to the following git repo: https://github.com/erikd/ghc-perfbug-test 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. Updated explanation: 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. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Simplifer non-determinism leading to 8 fold difference in run time performance -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime | Difficulty: Unknown performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by erikd): Amos Robinson has helped make some progress on this. The problem is with the `StrictPrim` monad (defined in the file `Common/GHC/Ineteger/StrictPrim.hs` of the ghc-perfbug-test project) which basically an ST monad with a bunch of explicit bang patterns to force strict evaluation. The big difference between the slow and the fast version is that in the slow version of the .dump-simpl output of these inner loops have an extra lambda eg on line 39 of `slow-Natural.dump-simpl`: {{{ (\ eta -> (# eta, vx #)) `cast` ...; }}} The `eta` variable in this case is the state token for the `StrictPrim` monad. Furthermore, Amos Robinson was able to re-write the inner loop from: {{{#!hs innerLoop2 !xi !yi !carryhi !carrylo !sum | yi < n2 = do x <- indexWordArrayM arr1 xi y <- indexWordArrayM arr2 yi let (# !cry0, !prod #) = timesWord2 x y (# !cry1, !sum1 #) = plusWord2 prod sum (# !tcryhi, !crylo #) = plusWord2C carrylo cry0 cry1 !cryhi = plusWord carryhi tcryhi innerLoop2 (xi - 1) (yi + 1) cryhi crylo sum1 | otherwise = do return $! (carryhi, carrylo, sum) }}} to {{{#!hs innerLoop2 !xi !yi !carryhi !carrylo !sum = StrictPrim $ \s -> if yi < n2 then let StrictPrim go = do x <- indexWordArrayM arr1 xi y <- indexWordArrayM arr2 yi let (# !cry0, !prod #) = timesWord2 x y (# !cry1, !sum1 #) = plusWord2 prod sum (# !tcryhi, !crylo #) = plusWord2C carrylo cry0 cry1 !cryhi = plusWord carryhi tcryhi innerLoop2 (xi - 1) (yi + 1) cryhi crylo sum1 in go s else (# s, (carryhi, carrylo, sum) #) }}} and this new formulation *always* compiles to run fast. After some discussion with Amos, we came to the following conclusions: 1. The simplifier should be deterministic. The same input file, with the same compiler flags should result in the same output (preferably the output that performs better). 2. It is not un-reasonable to expect the compiler to apply the transformation that Amos appied manually. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Simplifer non-determinism leading to 8 fold difference in run time performance -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime | Difficulty: Unknown performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): I spent a few minutes earlier today, and indeed I'm sure that difference in eta expansion is the cause of the trouble. What I do not understand is why it happens. Would you be prepared to cut down the example still more? Dump the Criterion wrapping. Just leave enough to reproduce the strange difference in Core generated in the wot different ways. Strip away everything else; eg we don't actually need to run the program any more. Thanks Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Simplifer non-determinism leading to 8 fold difference in run time performance -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime | Difficulty: Unknown performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by gidyn): * cc: gidyn (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Simplifer non-determinism leading to 8 fold difference in run time performance -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime | Difficulty: Unknown performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by erikd): The repo at https://github.com/erikd/ghc-perfbug-test has been stripped back as far as possible and no longer needs either criterion or hspec. The code has been tested with ghc-7.8.3 and ghc-7.9.20140929 and both display the same problem. Cloning the repo, cd-ing into it and running `make` will build the code and then print out: {{{ Fast version etas : 0 Slow version etas : 18 }}} which is simply the count of the occurence of the identifier `eta` in the twp -ddump-simpl outputs generated from the same file. When this bug is fixed, both values should be zero. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Simplifer non-determinism leading to 8 fold difference in run time performance -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: closed Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.8.3 Resolution: fixed | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime | Difficulty: Unknown performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by thomie): * status: new => closed * resolution: => fixed * milestone: => 7.10.1 Comment: I just ran `make` in a clone of the testrepo from comment:12, after installing `primitive-0.5.4` in a cabal sandbox. Results with GHC 7.8.3: {{{ Fast version etas : 0 Slow version etas : 18 }}} Results with GHC 7.9.20141108: {{{ Fast version etas : 0 Slow version etas : 0 }}} So this bug must have been fixed somewhere along the way, although I don't know in which commit. Feel free to reopen if you think this answer is unsatisfactory, or hang tight till the 7.10 release. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Simplifer non-determinism leading to 8 fold difference in run time performance -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: closed Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.8.3 Resolution: fixed | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime | Difficulty: Unknown performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by jstolarek): It would be great if we could have a test for this so we're sure this does not regress again. I looked at the repo and the code to reproduce this is pretty big. I wonder if it could be reduced further to include it in the testsuite. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

It would be great if we could have a test for this so we're sure this does not regress again. I looked at the repo and the code to reproduce
#9646: Simplifer non-determinism leading to 8 fold difference in run time performance -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thomie): * status: closed => new * resolution: fixed => Comment: Replying to [comment:14 jstolarek]: this is pretty big. I wonder if it could be reduced further to include it in the testsuite. Good idea. Reopening. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Simplifer non-determinism leading to 8 fold difference in run time performance -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.3 Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thoughtpolice): * milestone: 7.10.1 => 7.10.3 Comment: Moving to 7.10.3 - would be nice to fix. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Simplifer non-determinism leading to 8 fold difference in run time performance -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.3 Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by simonpj):
Moving to 7.10.3 - would be nice to fix.
I don't understand. It's apparently fixed in 7.9 and so should be fixed in 7.10.2, right? What we need is a test case so we will know if it regresses. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Simplifer non-determinism leading to 8 fold difference in run time performance -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Test Suite | Version: 7.8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 7.10.3 => 8.0.1 Comment: Still needs a test but this won't happen for 7.10.3. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:19 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Simplifer non-determinism leading to 8 fold difference in run time performance -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Test Suite | Version: 7.8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): Really close to having this pared down enough to add to the test suite. Since this issue was actually fixed before the 7.10.2 release its not a problem that the test doesn't get added to 7.10.3. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:20 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Simplifer non-determinism leading to 8 fold difference in run time performance -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Test Suite | Version: 7.8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2009 Wiki Page: | -------------------------------------+------------------------------------- Changes (by erikd): * status: new => patch * differential: => Phab:D2009 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:22 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Simplifer non-determinism leading to 8 fold difference in run time
performance
-------------------------------------+-------------------------------------
Reporter: erikd | Owner:
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Test Suite | Version: 7.8.3
Resolution: | Keywords:
Operating System: Linux | Architecture: x86_64
Type of failure: Runtime | (amd64)
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2009
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Erik de Castro Lopo

#9646: Simplifer non-determinism leading to 8 fold difference in run time performance -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Test Suite | Version: 7.8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 | (amd64) Type of failure: Runtime | Test Case: performance bug | testsuite/tests/simplCore/T9646 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2009 Wiki Page: | -------------------------------------+------------------------------------- Changes (by erikd): * testcase: => testsuite/tests/simplCore/T9646 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:24 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Simplifer non-determinism leading to 8 fold difference in run time performance -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Test Suite | Version: 7.8.3 Resolution: fixed | Keywords: Operating System: Linux | Architecture: x86_64 | (amd64) Type of failure: Runtime | Test Case: performance bug | testsuite/tests/simplCore/T9646 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2009 Wiki Page: | -------------------------------------+------------------------------------- Changes (by erikd): * status: patch => closed * resolution: => fixed Comment: Since the test has new been commited to master, this can be closed. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:25 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Simplifer non-determinism leading to 8 fold difference in run time
performance
-------------------------------------+-------------------------------------
Reporter: erikd | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Test Suite | Version: 7.8.3
Resolution: fixed | Keywords:
Operating System: Linux | Architecture: x86_64
| (amd64)
Type of failure: Runtime | Test Case:
performance bug | testsuite/tests/simplCore/T9646
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2009
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#9646: Simplifer non-determinism leading to 8 fold difference in run time performance -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Test Suite | Version: 7.8.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 | (amd64) Type of failure: Runtime | Test Case: performance bug | testsuite/tests/simplCore/T9646 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2009 Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * status: closed => new * resolution: fixed => Comment: This test is failing for `WAY=ghci`. This is the output, after adding `-fobject-code` (because of the use of unboxed tuples): {{{ --- ./T9646.run/T9646.stdout.normalised 2016-06-19 16:49:06.204443094 +0200 +++ ./T9646.run/T9646.run.stdout.normalised 2016-06-19 16:49:06.204443094 +0200 @@ -1,3 +1,96 @@ + +==================== Desugared ==================== +bindIO + ((\ @ a -> + let { + $dGHCiSandboxIO + $dGHCiSandboxIO = $fGHCiSandboxIOIO } in + ghciStepIO $dGHCiSandboxIO) + (hSetBuffering stdout LineBuffering)) + (\ it -> returnIO (build (\ @ a c n -> c (unsafeCoerce# it) n))) + + + +==================== Simplifier statistics ==================== +Total ticks: 12 + +2 PreInlineUnconditionally + 1 tpl + 1 $dGHCiSandboxIO +1 UnfoldingDone 1 unsafeCoerce# +1 RuleFired 1 Class op ghciStepIO +1 EtaExpansion 1 it +7 BetaReduction + 1 k0 + 1 k1 + 1 a + 1 b + 1 tpl + 1 a + 1 a + + + +==================== Simplified expression ==================== +bindIO + (id (hSetBuffering stdout LineBuffering)) + ((\ it eta -> + ((returnIO (build (\ @ a c n -> c it n))) `cast` ...) eta) + `cast` ...) + + + +==================== Desugared ==================== +let { + $dMonad + $dMonad = $fMonadIO } in +let { + $dMonad + $dMonad = $dMonad } in +bindIO + ((\ @ a -> + let { + $dGHCiSandboxIO + $dGHCiSandboxIO = $fGHCiSandboxIOIO } in + ghciStepIO $dGHCiSandboxIO) + (>> $dMonad (runIOFastExit main) (return $dMonad ()))) + (\ it -> returnIO (build (\ @ a c n -> c (unsafeCoerce# it) n))) + + + +==================== Simplifier statistics ==================== +Total ticks: 16 + +3 PreInlineUnconditionally + 1 tpl + 1 $dGHCiSandboxIO + 1 $dMonad +1 PostInlineUnconditionally 1 $dMonad +1 UnfoldingDone 1 unsafeCoerce# +3 RuleFired + 1 Class op >> + 1 Class op ghciStepIO + 1 Class op return +1 EtaExpansion 1 it +7 BetaReduction + 1 k0 + 1 k1 + 1 a + 1 b + 1 tpl + 1 a + 1 a + + + +==================== Simplified expression ==================== +bindIO + (id (thenIO (runIOFastExit main) ($fMonadIO_$creturn ()))) + ((\ it eta -> + ((returnIO (build (\ @ a c n -> c it n))) `cast` ...) eta) + `cast` ...) + + 1234 2345 2893730 *** unexpected failure for T9646(ghci) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9646#comment:27 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9646: Simplifer non-determinism leading to 8 fold difference in run time
performance
-------------------------------------+-------------------------------------
Reporter: erikd | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Test Suite | Version: 7.8.3
Resolution: | Keywords:
Operating System: Linux | Architecture: x86_64
| (amd64)
Type of failure: Runtime | Test Case:
performance bug | testsuite/tests/simplCore/T9646
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2009
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Thomas Miedema
participants (1)
-
GHC