<div dir="ltr">my apologies, sorry for the terrible bug report<br><br><div class="gmail_quote"><div dir="ltr">On Sun, Dec 11, 2016 at 11:05 AM GHC <<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">#876: Length is not a good consumer<br class="gmail_msg">
-------------------------------------+-------------------------------------<br class="gmail_msg">
Reporter: ariep@… | Owner:<br class="gmail_msg">
Type: bug | Status: new<br class="gmail_msg">
Priority: lowest | Milestone: 7.6.2<br class="gmail_msg">
Component: libraries/base | Version: 6.5<br class="gmail_msg">
Resolution: | Keywords: length<br class="gmail_msg">
Operating System: Linux | Architecture:<br class="gmail_msg">
| Unknown/Multiple<br class="gmail_msg">
Type of failure: Runtime | Test Case:<br class="gmail_msg">
performance bug | perf/should_run/T876<br class="gmail_msg">
Blocked By: | Blocking:<br class="gmail_msg">
Related Tickets: | Differential Rev(s):<br class="gmail_msg">
Wiki Page: |<br class="gmail_msg">
-------------------------------------+-------------------------------------<br class="gmail_msg">
<br class="gmail_msg">
Comment (by nomeata):<br class="gmail_msg">
<br class="gmail_msg">
This code, compiled with `-O, does fuse, and allocates nothing (or<br class="gmail_msg">
constant amounts)<br class="gmail_msg">
{{{#!hs<br class="gmail_msg">
<br class="gmail_msg">
module Foo where<br class="gmail_msg">
x :: Int -> Int<br class="gmail_msg">
x n = length [0..(10^n)::Int]<br class="gmail_msg">
}}}<br class="gmail_msg">
<br class="gmail_msg">
{{{<br class="gmail_msg">
$ ghci -fobject-code -O Foo<br class="gmail_msg">
GHCi, version 7.10.3: <a href="http://www.haskell.org/ghc/" rel="noreferrer" class="gmail_msg" target="_blank">http://www.haskell.org/ghc/</a> :? for help<br class="gmail_msg">
[1 of 1] Compiling Foo ( Foo.hs, Foo.o )<br class="gmail_msg">
Ok, modules loaded: Foo.<br class="gmail_msg">
Prelude Foo> :set +s<br class="gmail_msg">
Prelude Foo> x 1<br class="gmail_msg">
11<br class="gmail_msg">
(0.03 secs, 14,976,744 bytes)<br class="gmail_msg">
Prelude Foo> x 7<br class="gmail_msg">
10000001<br class="gmail_msg">
(0.02 secs, 0 bytes)<br class="gmail_msg">
Prelude Foo> x 8<br class="gmail_msg">
100000001<br class="gmail_msg">
(0.04 secs, 0 bytes)<br class="gmail_msg">
}}}<br class="gmail_msg">
<br class="gmail_msg">
(almost) HEAD:<br class="gmail_msg">
{{{<br class="gmail_msg">
GHCi, version 8.1.20161117: <a href="http://www.haskell.org/ghc/" rel="noreferrer" class="gmail_msg" target="_blank">http://www.haskell.org/ghc/</a> :? for help<br class="gmail_msg">
[1 of 1] Compiling Foo (.hs -> .o)<br class="gmail_msg">
WARNING: file compiler/simplCore/SimplCore.hs, line 663<br class="gmail_msg">
Simplifier bailing out after 4 iterations [58, 14, 2, 2]<br class="gmail_msg">
Size = {terms: 96, types: 32, coercions: 0}<br class="gmail_msg">
Ok, modules loaded: Foo (Foo.o).<br class="gmail_msg">
Prelude Foo> :set +s<br class="gmail_msg">
Prelude Foo> x 1<br class="gmail_msg">
11<br class="gmail_msg">
(0.19 secs, 94,792 bytes)<br class="gmail_msg">
Prelude Foo> x 2<br class="gmail_msg">
101<br class="gmail_msg">
(0.01 secs, 94,648 bytes)<br class="gmail_msg">
Prelude Foo> x 7<br class="gmail_msg">
10000001<br class="gmail_msg">
(0.01 secs, 98,568 bytes)<br class="gmail_msg">
Prelude Foo> x 8<br class="gmail_msg">
100000001<br class="gmail_msg">
(0.05 secs, 98,448 bytes)<br class="gmail_msg">
}}}<br class="gmail_msg">
<br class="gmail_msg">
Testing this in with interpreted code is not sufficient, as the optimizer<br class="gmail_msg">
does less in that case. So so far, everything seems as expected to me.<br class="gmail_msg">
<br class="gmail_msg">
--<br class="gmail_msg">
Ticket URL: <<a href="http://ghc.haskell.org/trac/ghc/ticket/876#comment:30" rel="noreferrer" class="gmail_msg" target="_blank">http://ghc.haskell.org/trac/ghc/ticket/876#comment:30</a>><br class="gmail_msg">
GHC <<a href="http://www.haskell.org/ghc/" rel="noreferrer" class="gmail_msg" target="_blank">http://www.haskell.org/ghc/</a>><br class="gmail_msg">
The Glasgow Haskell Compiler<br class="gmail_msg">
</blockquote></div></div>