on master help sign in
Add Fuse annotations to improve benchmarks

Improves the following benchmarks: FileSystem.Handle/o-1-space/copy/toChunks/group-ungroup/AS.interposeSuffix . AS.splitOnSuffix FileSystem.Handle/o-1-space/copy/toChunks/decodeEncodeUtf8Lenient (1/10) FileSystem.Handle/o-1-space/copy/read/SS.encodeUtf8 . SS.decodeUtf8Lax (1/10)

commit6d16a0cdc8c607081746f7e4e7886a5e5103b827 authorHarendra Kumar <harendra@composewell.com> dateFri 27 Nov 2020, 07:16 (6 years ago) parent8358095
2 files changed+7
src/Streamly/Internal/Data/Stream/StreamD.hs+3 src/Streamly/Internal/Unicode/Stream.hs+4
src/Streamly/Internal/Data/Stream/StreamD.hs+3
@@ -2368,6 +2368,7 @@ splitOnSuffixSeq withSep patArr (Fold fstep initial done) (Stream step state) =
23682368 let next = SplitOnSuffixSeqKRDone (n - 1) fs1 rb rh1
23692369 skip $ SplitOnSuffixSeqYield r next
23702370
2371+{-# ANN type SplitState Fuse #-}
23712372data SplitState s arr
23722373 = SplitInitial s
23732374 | SplitBuffering s arr
@@ -3004,6 +3005,7 @@ gintercalateSuffix
30043005 step _ (ICUSecondOnly _s2) = undefined
30053006 step _ (ICUSecondOnlyInner _s2 _i2) = undefined
30063007
3008+{-# ANN type InterposeSuffixState Fuse #-}
30073009data InterposeSuffixState s1 i1 =
30083010 InterposeSuffixFirst s1
30093011 -- | InterposeSuffixFirstYield s1 i1
@@ -3186,6 +3188,7 @@ gintercalate
31863188 return $ Yield x (ICALFirstInner s1 s2 i1 i2)
31873189 -}
31883190
3191+{-# ANN type InterposeState Fuse #-}
31893192data InterposeState s1 i1 a =
31903193 InterposeFirst s1
31913194 -- | InterposeFirstYield s1 i1
src/Streamly/Internal/Unicode/Stream.hs+4
@@ -74,6 +74,7 @@ import Data.Word (Word8)
7474import Foreign.ForeignPtr (touchForeignPtr)
7575import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
7676import Foreign.Storable (Storable(..))
77+import Fusion.Plugin.Types (Fuse(..))
7778import GHC.Base (assert, unsafeChr)
7879import GHC.ForeignPtr (ForeignPtr (..))
7980import GHC.IO.Encoding.Failure (isSurrogate)
@@ -248,6 +249,7 @@ decode1 table state codep byte =
248249--
249250data DecodeError = DecodeError !DecodeState !CodePoint deriving Show
250251
252+{-# ANN type FreshPoint Fuse #-}
251253data FreshPoint s a
252254 = FreshPointDecodeInit s
253255 | FreshPointDecodeInit1 s Word8
@@ -441,6 +443,7 @@ decodeUtf8EitherD :: Monad m
441443 => Stream m Word8 -> Stream m (Either DecodeError Char)
442444decodeUtf8EitherD = resumeDecodeUtf8EitherD 0 0
443445
446+{-# ANN type FlattenState Fuse #-}
444447data FlattenState s a
445448 = OuterLoop s !(Maybe (DecodeState, CodePoint))
446449 | InnerLoopDecodeInit s (ForeignPtr a) !(Ptr a) !(Ptr a)
@@ -579,6 +582,7 @@ decodeUtf8ArraysD_ ::
579582 -> Stream m Char
580583decodeUtf8ArraysD_ = decodeUtf8ArraysWithD DropOnCodingFailure
581584
585+{-# ANN type EncodeState Fuse #-}
582586data EncodeState s = EncodeState s !WList
583587
584588-- More yield points improve performance, but I am not sure if they can cause