Use -funfolding-use-threshold=150 in fileio benchmark

The lines-unlines benchmark does not fuse well without this option.
This commit is contained in:
Harendra Kumar 2019-09-14 17:29:39 +05:30
parent d4495c3298
commit 4a367b8d99
4 changed files with 10 additions and 4 deletions

View File

@ -13,9 +13,11 @@ the `SpecConstr` optimization in more cases.
In some cases, you may need to use `-funfolding-use-threshold` to make sure
that the combinators fuse. The default value of this option is `60`. Increasing
this default value can be detrimental in general, therefore, increase only if
you suspect an issue. As an example, a value of `75` is necessary and
sufficient to fuse `S.chunksOf n (A.writeN n)`. Hopefully GHC will fix this so
that it is not needed in future.
you suspect an issue. Hopefully GHC will fix this so that it is not needed in
future. Some known examples:
* use a value of `75` to fuse `S.chunksOf n (A.writeN n)`.
* use a value of `150` to fully fuse `S.splitSuffixOn`.
At the very least `-O` compilation option is required. In some cases, the
program may exhibit memory hog with default optimization options. For example,

View File

@ -59,6 +59,7 @@ import qualified Streamly.Internal as Internal
import qualified Streamly.Streams.StreamD as D
#ifdef INSPECTION
import Foreign.Storable (Storable)
import Streamly.Streams.StreamD.Type (Step(..), GroupState)
import Test.Inspection
#endif
@ -233,6 +234,7 @@ inspect $ 'chunksOfD `hasNoType` ''AT.FlattenState
inspect $ 'chunksOfD `hasNoType` ''D.ConcatMapUState
#endif
-- XXX splitSuffixOn requires -funfolding-use-threshold=150 for better fusion
-- | Lines and unlines
{-# INLINE linesUnlinesCopy #-}
linesUnlinesCopy :: Handle -> Handle -> IO ()
@ -245,7 +247,7 @@ linesUnlinesCopy inh outh =
$ FH.read inh
#ifdef INSPECTION
-- inspect $ hasNoTypeClasses 'linesUnlinesCopy
inspect $ hasNoTypeClassesExcept 'linesUnlinesCopy [''Storable]
-- inspect $ 'linesUnlinesCopy `hasNoType` ''Step
-- inspect $ 'linesUnlinesCopy `hasNoType` ''AT.FlattenState
-- inspect $ 'linesUnlinesCopy `hasNoType` ''D.ConcatMapUState

View File

@ -1085,6 +1085,7 @@ splitBy predicate f (Stream step state) = Stream (step' f) (Just state)
step' _ _ Nothing = return Stop
-- XXX requires -funfolding-use-threshold=150 in lines-unlines benchmark
{-# INLINE_NORMAL splitSuffixBy #-}
splitSuffixBy :: Monad m
=> (a -> Bool) -> Fold m a b -> Stream m a -> Stream m b

View File

@ -598,6 +598,7 @@ benchmark array
benchmark fileio
import: bench-options
type: exitcode-stdio-1.0
ghc-options: -funfolding-use-threshold=150
hs-source-dirs: benchmark
main-is: FileIO.hs
if flag(benchmark)