on master help sign in
Add INLINE pragmas on TH instance methods
commit3a0562a6921bdfc40d84515f658c320e1b99770d authorHarendra Kumar <harendra@composewell.com> dateSun 13 Aug 2023, 02:10 (3 years ago) parent52ddfee
2 files changed+12−2
core/src/Streamly/Internal/Data/Serialize/TH.hs+6−1 core/src/Streamly/Internal/Data/Unbox/TH.hs+6−1
core/src/Streamly/Internal/Data/Serialize/TH.hs+6−1
@@ -326,7 +326,11 @@ deriveSerializeInternal preds headTy cons = do
326326 peekMethod <- mkDeserializeExpr headTy cons
327327 pokeMethod <- mkSerializeExpr headTy cons
328328 let methods =
329− [ FunD 'size [Clause [] (NormalB sizeOfMethod) []]
329+ -- INLINE on sizeOf actually worsens some benchmarks, and improves
330+ -- none
331+ [ -- PragmaD (InlineP 'size Inline FunLike AllPhases)
332+ FunD 'size [Clause [] (NormalB sizeOfMethod) []]
333+ , PragmaD (InlineP 'deserialize Inline FunLike AllPhases)
330334 , FunD
331335 'deserialize
332336 [ Clause
@@ -336,6 +340,7 @@ deriveSerializeInternal preds headTy cons = do
336340 (NormalB peekMethod)
337341 []
338342 ]
343+ , PragmaD (InlineP 'serialize Inline FunLike AllPhases)
339344 , FunD
340345 'serialize
341346 [ Clause
core/src/Streamly/Internal/Data/Unbox/TH.hs+6−1
@@ -412,7 +412,11 @@ deriveUnboxInternal preds headTy cons = do
412412 peekMethod <- mkPeekExpr headTy cons
413413 pokeMethod <- mkPokeExpr headTy cons
414414 let methods =
415− [ FunD 'sizeOf [Clause [WildP] (NormalB sizeOfMethod) []]
415+ -- INLINE on sizeOf actually worsens some benchmarks, and improves
416+ -- none
417+ [ -- PragmaD (InlineP 'sizeOf Inline FunLike AllPhases)
418+ FunD 'sizeOf [Clause [WildP] (NormalB sizeOfMethod) []]
419+ , PragmaD (InlineP 'peekByteIndex Inline FunLike AllPhases)
416420 , FunD
417421 'peekByteIndex
418422 [ Clause
@@ -422,6 +426,7 @@ deriveUnboxInternal preds headTy cons = do
422426 (NormalB peekMethod)
423427 []
424428 ]
429+ , PragmaD (InlineP 'pokeByteIndex Inline FunLike AllPhases)
425430 , FunD
426431 'pokeByteIndex
427432 [ Clause