Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#7954 closed bug (fixed)

Strictness analysis regression

Reported by: chad.scherrer Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.6.2
Keywords: Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Runtime performance bug Test Case: perf/should_run/T7954
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

The sum function from the Prelude relies on GHC's strictness analysis.

Here's a run on GHC 7.6.2 where I kill it partway through - max resident memory is over 6 GB. Everything works perfectly if I replace sum with foldl' (+) 0.0.

Chris Done also tested this on 7.4.2; in that case the memory leak is not present and the code runs fine.

    ---------------------------
    chad@chad-desktop:~$ cat norm.hs
    norm ::  [Double] -> Double
    norm = sqrt . sum . map (\x -> x*x)
    
    main :: IO ()
    main = print . norm $ enumFromTo 0 100000000
    
    ---------------------------
    chad@chad-desktop:~$ ghc -V
    The Glorious Glasgow Haskell Compilation System, version 7.6.2
    
    ---------------------------
    chad@chad-desktop:~$ ghc -O2 norm.hs
    [1 of 1] Compiling Main             ( norm.hs, norm.o )
    Linking norm ...
    
    ---------------------------
    chad@chad-desktop:~$ /usr/bin/time ./norm
    ^CCommand terminated by signal 2
    21.68user 2.72system 0:24.51elapsed 99%CPU (0avgtext+0avgdata 6370516maxresident)k
    0inputs+0outputs (0major+1592762minor)pagefaults 0swaps
    
    ---------------------------

Change History (3)

comment:1 Changed 6 years ago by chad.scherrer

Operating System: Unknown/MultipleLinux

comment:2 Changed 6 years ago by simonpj

difficulty: Unknown
Resolution: fixed
Status: newclosed
Test Case: perf/should_run/T7954

Thanks. I believe it's fine in HEAD. I agree that it is wrong in 7.6.2.

Please yell if you don't think it's fixed in HEAD. I've added a regression test.

Simon

comment:3 Changed 6 years ago by Joachim Breitner <mail@…>

In 393ea739567206d848f53e9ca75f532a49218694/ghc:

Update test cases due to call arity

Some nice improvements on already succeeding test cases (#876, #7954
and #4267)

Test #149 needed a little change, lest call arity causes a allocation
change that we do not want to test here.
Note: See TracTickets for help on using tickets.