on master help sign in
Add Fuse annotations to improve benchmarks
6d16a0cHarendra Kumar
src/Streamly/Internal/Data/Stream/StreamD.hs+3
@@ -2368,6 +2368,7 @@ splitOnSuffixSeq withSep patArr (Fold fstep initial done) (Stream step state) =
2368 let next = SplitOnSuffixSeqKRDone (n - 1) fs1 rb rh1
2368 let next = SplitOnSuffixSeqKRDone (n - 1) fs1 rb rh1
2369 skip $ SplitOnSuffixSeqYield r next
2369 skip $ SplitOnSuffixSeqYield r next
2370
2370
2371+{-# ANN type SplitState Fuse #-}
2371data SplitState s arr
2372data SplitState s arr
2372 = SplitInitial s
2373 = SplitInitial s
2373 | SplitBuffering s arr
2374 | SplitBuffering s arr
@@ -3004,6 +3005,7 @@ gintercalateSuffix
3004 step _ (ICUSecondOnly _s2) = undefined
3005 step _ (ICUSecondOnly _s2) = undefined
3005 step _ (ICUSecondOnlyInner _s2 _i2) = undefined
3006 step _ (ICUSecondOnlyInner _s2 _i2) = undefined
3006
3007
3008+{-# ANN type InterposeSuffixState Fuse #-}
3007data InterposeSuffixState s1 i1 =
3009data InterposeSuffixState s1 i1 =
3008 InterposeSuffixFirst s1
3010 InterposeSuffixFirst s1
3009 -- | InterposeSuffixFirstYield s1 i1
3011 -- | InterposeSuffixFirstYield s1 i1
@@ -3186,6 +3188,7 @@ gintercalate
3186 return $ Yield x (ICALFirstInner s1 s2 i1 i2)
3188 return $ Yield x (ICALFirstInner s1 s2 i1 i2)
3187 -}
3189 -}
3188
3190
3191+{-# ANN type InterposeState Fuse #-}
3189data InterposeState s1 i1 a =
3192data InterposeState s1 i1 a =
3190 InterposeFirst s1
3193 InterposeFirst s1
3191 -- | InterposeFirstYield s1 i1
3194 -- | InterposeFirstYield s1 i1
src/Streamly/Internal/Unicode/Stream.hs+4
@@ -74,6 +74,7 @@ import Data.Word (Word8)
74import Foreign.ForeignPtr (touchForeignPtr)
74import Foreign.ForeignPtr (touchForeignPtr)
75import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
75import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
76import Foreign.Storable (Storable(..))
76import Foreign.Storable (Storable(..))
77+import Fusion.Plugin.Types (Fuse(..))
77import GHC.Base (assert, unsafeChr)
78import GHC.Base (assert, unsafeChr)
78import GHC.ForeignPtr (ForeignPtr (..))
79import GHC.ForeignPtr (ForeignPtr (..))
79import GHC.IO.Encoding.Failure (isSurrogate)
80import GHC.IO.Encoding.Failure (isSurrogate)
@@ -248,6 +249,7 @@ decode1 table state codep byte =
248--
249--
249data DecodeError = DecodeError !DecodeState !CodePoint deriving Show
250data DecodeError = DecodeError !DecodeState !CodePoint deriving Show
250
251
252+{-# ANN type FreshPoint Fuse #-}
251data FreshPoint s a
253data FreshPoint s a
252 = FreshPointDecodeInit s
254 = FreshPointDecodeInit s
253 | FreshPointDecodeInit1 s Word8
255 | FreshPointDecodeInit1 s Word8
@@ -441,6 +443,7 @@ decodeUtf8EitherD :: Monad m
441 => Stream m Word8 -> Stream m (Either DecodeError Char)
443 => Stream m Word8 -> Stream m (Either DecodeError Char)
442decodeUtf8EitherD = resumeDecodeUtf8EitherD 0 0
444decodeUtf8EitherD = resumeDecodeUtf8EitherD 0 0
443
445
446+{-# ANN type FlattenState Fuse #-}
444data FlattenState s a
447data FlattenState s a
445 = OuterLoop s !(Maybe (DecodeState, CodePoint))
448 = OuterLoop s !(Maybe (DecodeState, CodePoint))
446 | InnerLoopDecodeInit s (ForeignPtr a) !(Ptr a) !(Ptr a)
449 | InnerLoopDecodeInit s (ForeignPtr a) !(Ptr a) !(Ptr a)
@@ -579,6 +582,7 @@ decodeUtf8ArraysD_ ::
579 -> Stream m Char
582 -> Stream m Char
580decodeUtf8ArraysD_ = decodeUtf8ArraysWithD DropOnCodingFailure
583decodeUtf8ArraysD_ = decodeUtf8ArraysWithD DropOnCodingFailure
581
584
585+{-# ANN type EncodeState Fuse #-}
582data EncodeState s = EncodeState s !WList
586data EncodeState s = EncodeState s !WList
583
587
584-- More yield points improve performance, but I am not sure if they can cause
588-- More yield points improve performance, but I am not sure if they can cause