on master help sign in
Use explicit buckets in classifySessions benchmarks
ba05f93Harendra Kumar
benchmark/Streamly/Benchmark/Prelude/Serial/NestedFold.hs+22−14
@@ -10,7 +10,6 @@
10{-# LANGUAGE DeriveAnyClass #-}
10{-# LANGUAGE DeriveAnyClass #-}
11{-# LANGUAGE DeriveGeneric #-}
11{-# LANGUAGE DeriveGeneric #-}
12{-# LANGUAGE RankNTypes #-}
12{-# LANGUAGE RankNTypes #-}
13−{-# LANGUAGE TupleSections #-}
14
13
15module Serial.NestedFold (benchmarks) where
14module Serial.NestedFold (benchmarks) where
16
15
@@ -214,35 +213,44 @@ o_n_heap_buffering value =
214-------------------------------------------------------------------------------
213-------------------------------------------------------------------------------
215
214
216{-# INLINE classifySessionsOf #-}
215{-# INLINE classifySessionsOf #-}
217−classifySessionsOf :: (S.MonadAsync m) => SerialT m Int -> m ()
216+classifySessionsOf :: S.MonadAsync m => (Int -> Int) -> SerialT m Int -> m ()
218−classifySessionsOf =
217+classifySessionsOf getKey =
219 S.drain
218 S.drain
220− . Internal.classifySessionsOf (const (return False)) 3 FL.drain
219+ . Internal.classifySessionsOf
220+ (const (return False)) 3 (FL.take 10 FL.sum)
221 . Internal.timestamped
221 . Internal.timestamped
222− . S.concatMap (\x -> S.map (x,) (S.enumerateFromTo 1 (10 :: Int)))
222+ . S.map (\x -> (getKey x, x))
223
223
224{-# INLINE classifySessionsOfHash #-}
224{-# INLINE classifySessionsOfHash #-}
225−classifySessionsOfHash :: (S.MonadAsync m) => SerialT m Int -> m ()
225+classifySessionsOfHash :: S.MonadAsync m =>
226+ (Int -> Int) -> SerialT m Int -> m ()
226−classifySessionsOfHash =
227+classifySessionsOfHash getKey =
227 S.drain
228 S.drain
228 . Internal.classifySessionsByGeneric
229 . Internal.classifySessionsByGeneric
229 (Proxy :: Proxy (HashMap k))
230 (Proxy :: Proxy (HashMap k))
230− 1 False (const (return False)) 3 FL.drain
231+ 1 False (const (return False)) 3 (FL.take 10 FL.sum)
231 . Internal.timestamped
232 . Internal.timestamped
232− . S.concatMap (\x -> S.map (x,) (S.enumerateFromTo 1 (10 :: Int)))
233+ . S.map (\x -> (getKey x, x))
233
234
234o_n_space_grouping :: Int -> [Benchmark]
235o_n_space_grouping :: Int -> [Benchmark]
235o_n_space_grouping value =
236o_n_space_grouping value =
236 -- Buffering operations using heap proportional to group/window sizes.
237 -- Buffering operations using heap proportional to group/window sizes.
237 [ bgroup "grouping"
238 [ bgroup "grouping"
238− -- We use 10 element stream per input, so div by 10 here
239+ [ benchIOSink value "classifySessionsOf (10000 buckets)"
240+ (classifySessionsOf (getKey 10000))
239− [ benchIOSink (value `div` 10) "classifySessionsOf"
241+ , benchIOSink value "classifySessionsOf (64 buckets)"
240− classifySessionsOf
242+ (classifySessionsOf (getKey 64))
243+ , benchIOSink value "classifySessionsOfHash (10000 buckets)"
244+ (classifySessionsOfHash (getKey 10000))
241− , benchIOSink (value `div` 10) "classifySessionsOfHash"
245+ , benchIOSink value "classifySessionsOfHash (64 buckets)"
242− classifySessionsOfHash
246+ (classifySessionsOfHash (getKey 64))
243 ]
247 ]
244 ]
248 ]
245
249
250+ where
251+
252+ getKey n = (`mod` n)
253+
246-------------------------------------------------------------------------------
254-------------------------------------------------------------------------------
247-- Mixed Transformation
255-- Mixed Transformation
248-------------------------------------------------------------------------------
256-------------------------------------------------------------------------------
bin/bench-config.sh+1−1
@@ -68,7 +68,7 @@ bench_rts_options () {
68 Prelude.Serial/o-1-space/mixed/sum-product-fold) echo -n "-K64M" ;;
68 Prelude.Serial/o-1-space/mixed/sum-product-fold) echo -n "-K64M" ;;
69
69
70 # XXX These should be moved to o-n-space?
70 # XXX These should be moved to o-n-space?
71− Prelude.Serial/o-n-heap/grouping/classifySessionsOf*) echo -n "-K1M -M32M" ;;
71+ Prelude.Serial/o-n-heap/grouping/classifySessionsOf*) echo -n "-K4M -M32M" ;;
72 Prelude.Serial/o-n-heap/Functor/*) echo -n "-K4M -M32M" ;;
72 Prelude.Serial/o-n-heap/Functor/*) echo -n "-K4M -M32M" ;;
73 Prelude.Serial/o-n-heap/transformer/*) echo -n "-K8M -M64M" ;;
73 Prelude.Serial/o-n-heap/transformer/*) echo -n "-K8M -M64M" ;;
74
74