Re: [GHC] #7411: Exceptions are optimized away in certain situations

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #7411: Exceptions are optimized away in certain situations

GHC - devs mailing list
#7411: Exceptions are optimized away in certain situations
-------------------------------------+-------------------------------------
        Reporter:  SimonHengel       |                Owner:  tdammers
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  7.6.1
      Resolution:                    |             Keywords:  seq, deepseq,
                                     |  evaluate, exceptions
Operating System:  Linux             |         Architecture:  x86_64
                                     |  (amd64)
 Type of failure:  Incorrect result  |            Test Case:
  at runtime                         |  simplCore/should_fail/T7411
      Blocked By:                    |             Blocking:
 Related Tickets:  #5129 #15225      |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by tdammers):

 * related:  #5129 => #5129 #15225


--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7411#comment:38>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #7411: Exceptions are optimized away in certain situations

GHC - devs mailing list
#7411: Exceptions are optimized away in certain situations
-------------------------------------+-------------------------------------
        Reporter:  SimonHengel       |                Owner:  tdammers
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.8.1
       Component:  Compiler          |              Version:  7.6.1
      Resolution:                    |             Keywords:  seq, deepseq,
                                     |  evaluate, exceptions
Operating System:  Linux             |         Architecture:  x86_64
                                     |  (amd64)
 Type of failure:  Incorrect result  |            Test Case:
  at runtime                         |  simplCore/should_fail/T7411
      Blocked By:                    |             Blocking:
 Related Tickets:  #5129 #15225      |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by tdammers):

 To do:

 - turn on core linter
 - see if it still crashes when compiling with the stage1 compiler
 - compile nofib with -fno-state-hack, but with the "clean" compiler
 (compiled with state hack)

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7411#comment:40>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #7411: Exceptions are optimized away in certain situations

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#7411: Exceptions are optimized away in certain situations
-------------------------------------+-------------------------------------
        Reporter:  SimonHengel       |                Owner:  tdammers
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.8.1
       Component:  Compiler          |              Version:  7.6.1
      Resolution:                    |             Keywords:  seq, deepseq,
                                     |  evaluate, exceptions
Operating System:  Linux             |         Architecture:  x86_64
                                     |  (amd64)
 Type of failure:  Incorrect result  |            Test Case:
  at runtime                         |  simplCore/should_fail/T7411
      Blocked By:                    |             Blocking:
 Related Tickets:  #5129 #15225      |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by tdammers):

 Did 4 full runs of compiling GHC from scratch and then compiling and
 running nofib, with different configurations. Here's what happened.

 1. "vanilla": compile everything normally (the `prof` build that comes
 with GHC). Everything works as expected.
 2. "nsh": compile everything with `-fno-state-hack` (GHC itself,
 libraries, nofib). Everything works as expected.
 3. "stage1": compile GHC normally, nofib with `-fno-state-hack`, but use
 stage1 compiler instead of stage2. Everything works as expected.
 4. "nofib-nsh": compile GHC normally, nofib with `-fno-state-hack`. GHC
 segfaults while compiling `Main.hs` from the bernouilli program (which
 simply happens to be the first one it encounters). Despite passing
 `-dcore-lint`, I get no linter output.

 Here's the log:

 {{{
 ------------------------------------------------------------------------
 == Recursively making `all' in runstdtest nofib-analyse imaginary spectral
 real shootout ...
 PWD = /home/tobias/well-typed/devel/ghc/HEAD/nofib
 ------------------------------------------------------------------------
 ------------------------------------------------------------------------
 == make all ;
  in /home/tobias/well-typed/devel/ghc/HEAD/nofib/runstdtest
 ------------------------------------------------------------------------
 rm -f -f runstdtest
 echo '#!/usr/bin/perl'                               >> runstdtest
 echo '$RM             = "rm -f";'             >> runstdtest
 echo '$CONTEXT_DIFF   = "diff -U 1";'   >> runstdtest
 cat runstdtest.prl                                >> runstdtest
 chmod +x runstdtest
 Finished making all in runstdtest: 0
 ------------------------------------------------------------------------
 == make all ;
  in /home/tobias/well-typed/devel/ghc/HEAD/nofib/nofib-analyse
 ------------------------------------------------------------------------
 make[1]: Nothing to be done for 'all'.
 Finished making all in nofib-analyse: 0
 ------------------------------------------------------------------------
 == make all ;
  in /home/tobias/well-typed/devel/ghc/HEAD/nofib/imaginary
 ------------------------------------------------------------------------
 ------------------------------------------------------------------------
 == Recursively making `all' in bernouilli digits-of-e1 digits-of-e2 exp3_8
 gen_regexps integrate paraffins primes queens rfib tak wheel-sieve1 wheel-
 sieve2 x2n1 kahan ...
 PWD = /home/tobias/well-typed/devel/ghc/HEAD/nofib/imaginary
 ------------------------------------------------------------------------
 ------------------------------------------------------------------------
 == make all --no-print-directory;
  in /home/tobias/well-typed/devel/ghc/HEAD/nofib/imaginary/bernouilli
 ------------------------------------------------------------------------
 HC = /home/tobias/well-typed/devel/ghc/HEAD/inplace/bin/ghc-stage2
 HC_OPTS = -O2 -Rghc-timing -H32m -hisuf hi -fno-state-hack -O2 -dcore-lint
 -rtsopts
 RUNTEST_OPTS = -ghc-timing
 ==nofib== bernouilli: time to compile Main follows...
 /home/tobias/well-typed/devel/ghc/HEAD/inplace/bin/ghc-stage2 -O2 -Rghc-
 timing -H32m -hisuf hi -fno-state-hack -O2 -dcore-lint -rtsopts -c Main.hs
 -o Main.o
 ../../mk/suffix.mk:23: recipe for target 'Main.o' failed
 make[2]: *** [Main.o] Segmentation fault (core dumped)
 Failed making all in bernouilli: 1
 ../mk/ghc-recurse.mk:65: recipe for target 'all' failed
 make[1]: *** [all] Error 1
 Failed making all in imaginary: 1
 mk/ghc-recurse.mk:65: recipe for target 'all' failed
 make: *** [all] Error 1
 }}}

 Unfortunately I hadn't done a run with GHC stage1 compiled with `-fno-
 state-hack`; I'll do that next.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7411#comment:41>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #7411: Exceptions are optimized away in certain situations

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#7411: Exceptions are optimized away in certain situations
-------------------------------------+-------------------------------------
        Reporter:  SimonHengel       |                Owner:  tdammers
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.8.1
       Component:  Compiler          |              Version:  7.6.1
      Resolution:                    |             Keywords:  seq, deepseq,
                                     |  evaluate, exceptions
Operating System:  Linux             |         Architecture:  x86_64
                                     |  (amd64)
 Type of failure:  Incorrect result  |            Test Case:
  at runtime                         |  simplCore/should_fail/T7411
      Blocked By:                    |             Blocking:
 Related Tickets:  #5129 #15225      |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by tdammers):

 Additional runs:

 - stage1 GHC without state hack and nofib without state hack -> succeeds
 - stage2 GHC without state hack and nofib with state hack -> succeeds

 So either there is something strange going on with the combination GHC +
 libs with state hack, nofib without state hack; or my testing leaves
 artifacts somehow.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7411#comment:42>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #7411: Exceptions are optimized away in certain situations

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#7411: Exceptions are optimized away in certain situations
-------------------------------------+-------------------------------------
        Reporter:  SimonHengel       |                Owner:  tdammers
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.8.1
       Component:  Compiler          |              Version:  7.6.1
      Resolution:                    |             Keywords:  seq, deepseq,
                                     |  evaluate, exceptions
Operating System:  Linux             |         Architecture:  x86_64
                                     |  (amd64)
 Type of failure:  Incorrect result  |            Test Case:
  at runtime                         |  simplCore/should_fail/T7411
      Blocked By:                    |             Blocking:
 Related Tickets:  #5129 #15225      |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by tdammers):

 * Attachment "nofib-analyse.log.gz" added.

 nofib analyse output (gzipped because of size limit)

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7411>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #7411: Exceptions are optimized away in certain situations

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#7411: Exceptions are optimized away in certain situations
-------------------------------------+-------------------------------------
        Reporter:  SimonHengel       |                Owner:  tdammers
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.8.1
       Component:  Compiler          |              Version:  7.6.1
      Resolution:                    |             Keywords:  seq, deepseq,
                                     |  evaluate, exceptions
Operating System:  Linux             |         Architecture:  x86_64
                                     |  (amd64)
 Type of failure:  Incorrect result  |            Test Case:
  at runtime                         |  simplCore/should_fail/T7411
      Blocked By:                    |             Blocking:
 Related Tickets:  #5129 #15225      |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by tdammers):

 OK, so it turns out that make clean doesn't actually clean things up
 thoroughly enough. I did another test run, building both GHC and nofib
 from a fresh checkout for each run, and now everything works just fine. So
 it seems that the core dumps I got earlier were somehow caused by
 artifacts from a previous build still being in the build tree somewhere;
 clearly if you link things together in ways they weren't meant to, strange
 behavior is to be expected.

 Now armed with that, and a fixed `fasta` implementation from #15225, I
 managed to do six nofib runs; the interesting ones are:

 - Both GHC and nofib compiled with the state hack in place - this is the
 current situation (`nofibrun-gs_ns2.log`)
 - GHC with the state hack, nofib compiled with `-fno-state-hack`
 (`nofibrun-gs-nn2.log`
 - Both GHC and nofib compiled with `-fno-state-hack` (`nofibrun-
 gn_nn2.log`)

 Results from nofib-analyse attached; key takeaway however is that the
 difference overall is small and slightly in favor of removing the state
 hack. A few interesting deviations that stand out:

 - GHC compiled with `-fno-state-hack` consistently produces larger
 binaries, by about 5%
 - Programs compiled with a GHC compiled with `-fno-state-hack` run faster
 by 3.2% on average, but there is a lot of deviation
 - Most of the above improvements seem to be from more efficient GC
 - Compile times differ drastically; vanilla GHC compiling programs with
 `-fno-state-hack` is 23.6% faster on average than the same compiler with
 the state hack; compiling GHC itself with `-fno-state-hack` and then
 compiling the nofib suite also with `-fno-state-hack` is almost 50% faster
 than compiling everything normally. The difference in allocations is even
 more whopping, with 35.5% and 58.3% respectively.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7411#comment:43>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #7411: Exceptions are optimized away in certain situations

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#7411: Exceptions are optimized away in certain situations
-------------------------------------+-------------------------------------
        Reporter:  SimonHengel       |                Owner:  tdammers
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.8.1
       Component:  Compiler          |              Version:  7.6.1
      Resolution:                    |             Keywords:  seq, deepseq,
                                     |  evaluate, exceptions
Operating System:  Linux             |         Architecture:  x86_64
                                     |  (amd64)
 Type of failure:  Incorrect result  |            Test Case:
  at runtime                         |  simplCore/should_fail/T7411
      Blocked By:                    |             Blocking:
 Related Tickets:  #5129 #15225      |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Well this is surprising news, but I think good news too.  Maybe we can
 kill off the state hack altogether!

 But before we do that, let's really understand our data.  (A minor point:
 in the nfib-analyse output, the column headings are cut off in the summary
 table; can you use shorter file names?)

 * I'm astounded by the reduction in compile time (and compiler
 allocation), in both variants.  Is that caused by (a) a faster GHC stage
 2, or (b) smaller Core sizes?  Could you pick a module with a particularly
 big reduction, and dig into why?  I confess that I am a bit suspicious.
 Compile times don't usually halve!

 * Binary sizes go up 5% when "GHC is compiled with -fno-state-hack". I
 think that the important thing is that the '''libraries''' (which are
 linked into the nofib binary) are compiled with -fno-state-hack.  I doubt
 it's caused by the fact that ghc-stage2 is compiled with -fno-state-hack.
 Can you confirm?

 * And if binary sizes go up by 5% because the libraries are getting
 bigger, is that a generic 5% increase in .o file size?  Or do a few key
 modules get a lot bigger? It's puzzling because the per-moudule "Module
 Sizes" stats in the nofib log suggest that there is an essentially-zero
 effect on nofib module sizes.

 * As I wrote above, the motivation for the state hack is functions lie
 {{{
 f :: [Int] -> IO ()
 f xs = print ys >> print xs
   where
     ys = reverse xs

 test 0 = return ()
 test n = f [1,n] >> test (n-1)
 }}}
   which I expected to be much less efficient without the state hack.
 Would it be worth trying to demonstrate a program that does get worse in
 this way?  I'm still amazed at how good the results are!

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7411#comment:44>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #7411: Exceptions are optimized away in certain situations

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#7411: Exceptions are optimized away in certain situations
-------------------------------------+-------------------------------------
        Reporter:  SimonHengel       |                Owner:  tdammers
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.8.1
       Component:  Compiler          |              Version:  7.6.1
      Resolution:                    |             Keywords:  seq, deepseq,
                                     |  evaluate, exceptions
Operating System:  Linux             |         Architecture:  x86_64
                                     |  (amd64)
 Type of failure:  Incorrect result  |            Test Case:
  at runtime                         |  simplCore/should_fail/T7411
      Blocked By:                    |             Blocking:
 Related Tickets:  #5129 #15225      |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 PS: the bad-ness of 'make clean' is also a worry.  It wasted a lot of your
 time.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7411#comment:45>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets