** This is a plea to release ghc 6.8.2 soon, since the SpecConstr
breakage in ghc 6.8.1 is killing the stream-fusion library **
I was handed some code by Eric Mertens used in a competition, and he
wondered if it would go any faster with some stream fusion. It is quite
list heavy, so I was hopeful.
http://hpaste.org/99#a3
With normal ghc 6.8, and the ghc stable branch since the SpecConstr fix
landed, we get the following rules firing:
1 SC:go0
3 fold/build
2 foldr/augment
and roughly the same performance with each:
./C 8.67s user 0.11s system 99% cpu 8.835 total
Switching over to use stream-fusion,
import Prelude hiding (map,replicate,take,zipWith,drop,splitAt,(++))
import Data.List.Stream
we get some good speeds 5-10% with ghc stable, spec-constr fixed:
142 RuleFired
2 ++ -> fused (1)
1 ++ -> fused on 1st arg
1 ++ -> fused on 2nd arg
3 SC:$j_s1hn0
3 SC:$j_s1hn1
1 SC:$j_s1hp0
4 SC:$j_s1hp1
4 SC:$j_s1hp2
1 SC:$j_s1hp3
1 SC:$w$j0
1 SC:$w$j1
1 SC:$w$j2
2 SC:$wloop_foldl'0
3 SC:$wloop_foldl'1
19 SC:$wloop_foldl'2
22 SC:$wloop_foldl'3
22 SC:$wloop_foldl'4
3 SC:unfold_unstream0
1 SC:unfold_unstream1
1 SC:unfold_unstream2
2 SC:unfold_unstream3
4 SC:unfold_unstream4
1 SC:unfold_unstream5
4 SC:unfold_unstream6
1 SC:unfold_unstream7
3 STREAM stream/unstream fusion
Sweet, that's a lot of SpecConstr. GHC cleaning up our streams nicely.
./C 8.11s user 0.10s system 99% cpu 8.229 total
YAY! That's what we like to see -- faster code.
However, if we use out-of-the box ghc 6.8.1, the one with broken
SpecConstr, the stream-fusion library falls over miserably:
50 RuleFired
1 SC:$w$j0
1 SC:$w$j1
1 SC:$w$j2
1 SC:$wloop_foldl'2
1 SC:unfold_unstream0
1 SC:unfold_unstream7
3 STREAM stream/unstream fusion
SO very little fix up of the Stream structures the library translated
the list code into.. probably not good...and running this we find it has
a space leak, and takes 5 times as long:
./C 27.58s user 1.11s system 99% cpu 28.878 total
Well, at least it computes the right result..
Lesson 1: stream-fusion relies on SpecConstr, as we know :)
Lesson 2: GHC 6.8.1 breaks the stream-fusion library
Lesson 3: But with ghc patched, stream-fusion is a 5-10% win, as in the
original paper
So, hurry up and release ghc 6.8.2!
Also, its nice to see stream-fusion working as a library , without base
being modified (with the proviso that some built in desugaring won't
work, and there'll be missed fusion opportunities in the base library.
-- Don
_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc