on master help sign in
Use -funfolding-use-threshold=150 in fileio benchmark
4a367b8Harendra Kumar
docs/Build.md+5−3
@@ -13,9 +13,11 @@ the `SpecConstr` optimization in more cases.
13In some cases, you may need to use `-funfolding-use-threshold` to make sure
13In some cases, you may need to use `-funfolding-use-threshold` to make sure
14that the combinators fuse. The default value of this option is `60`. Increasing
14that the combinators fuse. The default value of this option is `60`. Increasing
15this default value can be detrimental in general, therefore, increase only if
15this default value can be detrimental in general, therefore, increase only if
16−you suspect an issue. As an example, a value of `75` is necessary and
17−sufficient to fuse `S.chunksOf n (A.writeN n)`. Hopefully GHC will fix this so
18−that it is not needed in future.
16+you suspect an issue. Hopefully GHC will fix this so that it is not needed in
17+future. Some known examples:
18+
19+* use a value of `75` to fuse `S.chunksOf n (A.writeN n)`.
20+* use a value of `150` to fully fuse `S.splitSuffixOn`.
19
21
20At the very least `-O` compilation option is required. In some cases, the
22At the very least `-O` compilation option is required. In some cases, the
21program may exhibit memory hog with default optimization options. For example,
23program may exhibit memory hog with default optimization options. For example,
src/Streamly/Benchmark/FileIO/Stream.hs+3−1
@@ -59,6 +59,7 @@ import qualified Streamly.Internal as Internal
59import qualified Streamly.Streams.StreamD as D
59import qualified Streamly.Streams.StreamD as D
60
60
61#ifdef INSPECTION
61#ifdef INSPECTION
62+import Foreign.Storable (Storable)
62import Streamly.Streams.StreamD.Type (Step(..), GroupState)
63import Streamly.Streams.StreamD.Type (Step(..), GroupState)
63import Test.Inspection
64import Test.Inspection
64#endif
65#endif
@@ -233,6 +234,7 @@ inspect $ 'chunksOfD `hasNoType` ''AT.FlattenState
233inspect $ 'chunksOfD `hasNoType` ''D.ConcatMapUState
234inspect $ 'chunksOfD `hasNoType` ''D.ConcatMapUState
234#endif
235#endif
235
236
237+-- XXX splitSuffixOn requires -funfolding-use-threshold=150 for better fusion
236-- | Lines and unlines
238-- | Lines and unlines
237{-# INLINE linesUnlinesCopy #-}
239{-# INLINE linesUnlinesCopy #-}
238linesUnlinesCopy :: Handle -> Handle -> IO ()
240linesUnlinesCopy :: Handle -> Handle -> IO ()
@@ -245,7 +247,7 @@ linesUnlinesCopy inh outh =
245 $ FH.read inh
247 $ FH.read inh
246
248
247#ifdef INSPECTION
249#ifdef INSPECTION
248−-- inspect $ hasNoTypeClasses 'linesUnlinesCopy
250+inspect $ hasNoTypeClassesExcept 'linesUnlinesCopy [''Storable]
249-- inspect $ 'linesUnlinesCopy `hasNoType` ''Step
251-- inspect $ 'linesUnlinesCopy `hasNoType` ''Step
250-- inspect $ 'linesUnlinesCopy `hasNoType` ''AT.FlattenState
252-- inspect $ 'linesUnlinesCopy `hasNoType` ''AT.FlattenState
251-- inspect $ 'linesUnlinesCopy `hasNoType` ''D.ConcatMapUState
253-- inspect $ 'linesUnlinesCopy `hasNoType` ''D.ConcatMapUState
src/Streamly/Streams/StreamD.hs+1
@@ -1085,6 +1085,7 @@ splitBy predicate f (Stream step state) = Stream (step' f) (Just state)
1085
1085
1086 step' _ _ Nothing = return Stop
1086 step' _ _ Nothing = return Stop
1087
1087
1088+-- XXX requires -funfolding-use-threshold=150 in lines-unlines benchmark
1088{-# INLINE_NORMAL splitSuffixBy #-}
1089{-# INLINE_NORMAL splitSuffixBy #-}
1089splitSuffixBy :: Monad m
1090splitSuffixBy :: Monad m
1090 => (a -> Bool) -> Fold m a b -> Stream m a -> Stream m b
1091 => (a -> Bool) -> Fold m a b -> Stream m a -> Stream m b
streamly.cabal+1
@@ -598,6 +598,7 @@ benchmark array
598benchmark fileio
598benchmark fileio
599 import: bench-options
599 import: bench-options
600 type: exitcode-stdio-1.0
600 type: exitcode-stdio-1.0
601+ ghc-options: -funfolding-use-threshold=150
601 hs-source-dirs: benchmark
602 hs-source-dirs: benchmark
602 main-is: FileIO.hs
603 main-is: FileIO.hs
603 if flag(benchmark)
604 if flag(benchmark)