on master help sign in
Add INLINE phase annotations on some functions
0d58675Harendra Kumar
benchmark/Streamly/Benchmark/FileSystem/Handle.hs+10−3
@@ -485,18 +485,25 @@ inspect $ 'readSumBytes `hasNoType` ''AT.FlattenState
485inspect $ 'readSumBytes `hasNoType` ''D.ConcatMapUState
485inspect $ 'readSumBytes `hasNoType` ''D.ConcatMapUState
486#endif
486#endif
487
487
488+-- XXX If we have two benchmarks using S.drain in one benchmark group then
489+-- somehow GHC ends up delaying the inlining of readDrain. since S.drain has an
490+-- INLINE[2] for proper rule firing, that does not work well because of delyaed
491+-- inlining and the code does not fuse. We need some way of propagating the
492+-- inline phase information up so that we can expedite inlining of the callers
493+-- too automatically. The minimal example for the problem can be created by
494+-- using just two benchmarks in a bench group both using "readDrain".
488−{-# INLINE readDrain #-}
495+{-# INLINE[2] readDrain #-}
489readDrain :: Handle -> IO ()
496readDrain :: Handle -> IO ()
490readDrain inh = S.drain $ S.unfold FH.read inh
497readDrain inh = S.drain $ S.unfold FH.read inh
491
498
492−{-# INLINE readDecodeLatin1 #-}
499+{-# INLINE[2] readDecodeLatin1 #-}
493readDecodeLatin1 :: Handle -> IO ()
500readDecodeLatin1 :: Handle -> IO ()
494readDecodeLatin1 inh =
501readDecodeLatin1 inh =
495 S.drain
502 S.drain
496 $ SS.decodeLatin1
503 $ SS.decodeLatin1
497 $ S.unfold FH.read inh
504 $ S.unfold FH.read inh
498
505
499−{-# INLINE readDecodeUtf8Lax #-}
506+{-# INLINE[2] readDecodeUtf8Lax #-}
500readDecodeUtf8Lax :: Handle -> IO ()
507readDecodeUtf8Lax :: Handle -> IO ()
501readDecodeUtf8Lax inh =
508readDecodeUtf8Lax inh =
502 S.drain
509 S.drain