From 2ce3831cb6656b007db87e4ce8eda234b2991a7f Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Fri, 8 May 2026 13:28:44 +0530 Subject: [PATCH 1/7] Make small fixes to the eventlog doc --- docs/eventlog-performance-analysis.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/eventlog-performance-analysis.md b/docs/eventlog-performance-analysis.md index f5b690e..57bf8bd 100644 --- a/docs/eventlog-performance-analysis.md +++ b/docs/eventlog-performance-analysis.md @@ -21,6 +21,10 @@ TBD: document the exact limitations and differences. ## Generating the eventlog +IMPORTANT: The `hperf` eventlog analysis program works only with the patched +`ghc` executable, if you use it with stock ghc it will not understand the +eventlog format and will generate errors. + To generate the event log, we need to enable event log at compile time (on modern GHCs it is always enabled) and the run the program with eventlog enabled at run-time, we use the `-l` rts option to do that. @@ -28,11 +32,9 @@ eventlog enabled at run-time, we use the `-l` rts option to do that. There are multiple ways of running your program with eventlog enabled at run-time: -__GHC Command Line__: - Compiling: ``` -ghc Main.hs -rtsopts +ghc Main.hs -eventlog -rtsopts ``` Running: @@ -42,7 +44,7 @@ Running: You can bake in the rts options during compilation itself: ``` -ghc Main.hs -with-rtsopts=-l +ghc Main.hs -eventlog -with-rtsopts=-l ``` Now you can run without any explicit RTS options: @@ -62,7 +64,7 @@ to use the `-N1` rts option. ## Measurement instrumentation -See the example in [examples/traceEventIO.hs](examples/traceEventIO.hs) . +See the example in [examples/traceEventIO.hs](../examples/traceEventIO.hs) . Use the `traceEventIO` function to log events. Add an event before and after the code block you want to measure. The event message before the block From 7edb71b45a88f6c30067d523b821082cdbcea677 Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Fri, 8 May 2026 13:29:10 +0530 Subject: [PATCH 2/7] Make minor comments, refactor fixes --- src/Aggregator.hs | 14 +++++++------- src/Main.hs | 14 +++++++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Aggregator.hs b/src/Aggregator.hs index a06f657..59830f7 100644 --- a/src/Aggregator.hs +++ b/src/Aggregator.hs @@ -26,15 +26,15 @@ import qualified Data.Set as Set -- All counter events are recorded against a unique key (tid, window, counter). -- --- A user defined window is prefixed with the thread-id of the thread which --- started it. Therefore, if the window code is entered by multiple threads, --- each thread is assigned a different window name. +-- A user defined measurement window name is prefixed with the thread-id of the +-- thread which started it. Therefore, if the window is entered by multiple +-- threads, each thread is assigned a different window name. -- --- Each window accounts all threads active at the time when the window is --- active. Therefore, any thread start/stop events are broadcast to all the --- currently active windows. +-- Each window performs accounting for all threads active at the time when the +-- window is active. Therefore, any thread start/stop events are broadcast to +-- all the currently active windows. -- --- When a window starts, many threads may already be existing in the system. +-- When a measurement window starts, many threads may already be existing in the system. -- After the window is entered, events of all threads are broadcast to the -- window. If a thread was already active when the window was entered, then we -- may get a suspend event without first getting a resume event. Similar, diff --git a/src/Main.hs b/src/Main.hs index cf05499..28eb3c3 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -28,6 +28,7 @@ import Streamly.Data.Array (Array) import Streamly.Data.Stream (Stream) import Streamly.Data.StreamK (StreamK) import Streamly.Internal.Data.Fold (Fold (..), postscanlMaybe) +import Streamly.Data.Scanl (Scanl) import qualified Streamly.Data.Scanl as Scanl import qualified Streamly.Internal.Data.Scanl as Scanl (scanlMany, cumulativeScan) import qualified Streamly.Statistics.Scanl as Stats @@ -74,7 +75,10 @@ secondMaybe f = fmap f1 (Fold.unzip (fmap fromJust Fold.the) f) double :: Int -> Double double = fromIntegral -untilLeft :: Monad m => Scanl.Scanl m b1 b2 -> Scanl.Scanl m (Either (Maybe b1) b1) b2 +-- | Modify the input of a scan to accept an "Either" input, the modified scan +-- keeps consuming right inputs until a left input arrives, which terminates +-- the scan. +untilLeft :: Monad m => Scanl m b1 b2 -> Scanl m (Either (Maybe b1) b1) b2 untilLeft f = Scanl.takeEndBy isLeft $ Scanl.lmap (either id Just) @@ -110,7 +114,7 @@ combineWindowStats = Fold.kvToMap combineStats -- Statistics collection for each counter {-# INLINE stats #-} -stats :: Scanl.Scanl IO Int64 [(String, Int)] +stats :: Scanl IO Int64 [(String, Int)] stats = Scanl.lmap (fromIntegral :: Int64 -> Int) $ Scanl.distribute @@ -124,11 +128,11 @@ stats = ] {-# INLINE threadStats #-} -threadStats :: Scanl.Scanl IO (Either (Maybe Int64) Int64) [(String, Int)] +threadStats :: Scanl IO (Either (Maybe Int64) Int64) [(String, Int)] threadStats = untilLeft stats {-# INLINE windowStats #-} -windowStats :: Scanl.Scanl IO (Either (Maybe Int64) Int64) [(String, Int)] +windowStats :: Scanl IO (Either (Maybe Int64) Int64) [(String, Int)] windowStats = Scanl.scanlMany (untilLeft Scanl.sum) stats {-# INLINE toStats #-} @@ -139,7 +143,7 @@ toStats :: ((Word32, String, Counter), (Location, Int64)) -- Map (tid, window tag, counter) (Maybe [(stat name, value)]) (Map (Word32, String, Counter) (Maybe [(String, Int)])) -toStats = Fold.demuxKvToMap (\k -> pure (Just (f1 k))) +toStats = Fold.demuxKvToMap (pure . Just . f1) where From 07562a9d7a40123663e189be4d3bd7055da1e8e4 Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Fri, 8 May 2026 14:06:50 +0530 Subject: [PATCH 3/7] Move eventlog aggregator and parsing modules to lib --- haskell-perf.cabal | 5 ++++- {src => lib/Eventlog}/Aggregator.hs | 4 ++-- {src => lib/Eventlog}/EventParser.hs | 2 +- src/Main.hs | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) rename {src => lib/Eventlog}/Aggregator.hs (99%) rename {src => lib/Eventlog}/EventParser.hs (99%) diff --git a/haskell-perf.cabal b/haskell-perf.cabal index 4949102..60a0081 100644 --- a/haskell-perf.cabal +++ b/haskell-perf.cabal @@ -144,6 +144,8 @@ library , Streamly.Metrics.Measure -- , Streamly.Metrics.File -- , Streamly.Metrics.Console + , Eventlog.EventParser + , Eventlog.Aggregator if !os(windows) exposed-modules: @@ -151,6 +153,7 @@ library build-depends: base >= 4.9 && < 5 + , containers < 0.9 , pretty-show >= 1.10 && < 1.11 , stm >= 2.5.3 && < 2.6 , streamly >= 0.11.0 && < 0.12 @@ -164,11 +167,11 @@ executable hperf import: compile-options, optimization-options hs-source-dirs: src main-is: Main.hs - other-modules: Aggregator, EventParser build-depends: base >= 4.9 && < 5 , containers < 0.9 , format-numbers < 0.2 + , haskell-perf , optparse-applicative < 0.20 , streamly-core >= 0.3.0 && < 0.4 , streamly-statistics < 0.3 diff --git a/src/Aggregator.hs b/lib/Eventlog/Aggregator.hs similarity index 99% rename from src/Aggregator.hs rename to lib/Eventlog/Aggregator.hs index 59830f7..f832f12 100644 --- a/src/Aggregator.hs +++ b/lib/Eventlog/Aggregator.hs @@ -1,5 +1,5 @@ {-# LANGUAGE CPP #-} -module Aggregator +module Eventlog.Aggregator ( translateThreadEvents , collectThreadCounter ) @@ -8,7 +8,7 @@ where import Data.Int (Int64) import Data.Set (Set) import Data.Word (Word32) -import EventParser (Event (..), Counter(..), Location(..)) +import Eventlog.EventParser (Event (..), Counter(..), Location(..)) import Streamly.Internal.Data.Fold (Step(..)) import Streamly.Internal.Data.Scanl (Scanl(..)) import Streamly.Internal.Data.Tuple.Strict (Tuple'(..)) diff --git a/src/EventParser.hs b/lib/Eventlog/EventParser.hs similarity index 99% rename from src/EventParser.hs rename to lib/Eventlog/EventParser.hs index 5033e5f..d7ccbfd 100644 --- a/src/EventParser.hs +++ b/lib/Eventlog/EventParser.hs @@ -1,5 +1,5 @@ {-# LANGUAGE CPP #-} -module EventParser +module Eventlog.EventParser ( parseLogHeader , parseDataHeader diff --git a/src/Main.hs b/src/Main.hs index 28eb3c3..7625c28 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -3,7 +3,7 @@ module Main (main) where -import Aggregator +import Eventlog.Aggregator ( collectThreadCounter, translateThreadEvents, ) @@ -16,7 +16,7 @@ import Data.Map (Map) import Data.Maybe (fromJust, isJust) import Data.Text.Format.Numbers (prettyI) import Data.Word (Word32, Word8) -import EventParser +import Eventlog.EventParser ( Counter (..), Location (..), Event (..), From 1050892a9df54af4ef5e2757672a26c055026634 Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Fri, 8 May 2026 14:21:44 +0530 Subject: [PATCH 4/7] Change the namespace to Perf --- haskell-perf.cabal | 4 ++-- lib/{Eventlog/Aggregator.hs => Perf/Eventlog/Aggregate.hs} | 4 ++-- lib/{Eventlog/EventParser.hs => Perf/Eventlog/Parser.hs} | 2 +- src/Main.hs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) rename lib/{Eventlog/Aggregator.hs => Perf/Eventlog/Aggregate.hs} (99%) rename lib/{Eventlog/EventParser.hs => Perf/Eventlog/Parser.hs} (99%) diff --git a/haskell-perf.cabal b/haskell-perf.cabal index 60a0081..02baf63 100644 --- a/haskell-perf.cabal +++ b/haskell-perf.cabal @@ -144,8 +144,8 @@ library , Streamly.Metrics.Measure -- , Streamly.Metrics.File -- , Streamly.Metrics.Console - , Eventlog.EventParser - , Eventlog.Aggregator + , Perf.Eventlog.Parser + , Perf.Eventlog.Aggregate if !os(windows) exposed-modules: diff --git a/lib/Eventlog/Aggregator.hs b/lib/Perf/Eventlog/Aggregate.hs similarity index 99% rename from lib/Eventlog/Aggregator.hs rename to lib/Perf/Eventlog/Aggregate.hs index f832f12..3e3ce6b 100644 --- a/lib/Eventlog/Aggregator.hs +++ b/lib/Perf/Eventlog/Aggregate.hs @@ -1,5 +1,5 @@ {-# LANGUAGE CPP #-} -module Eventlog.Aggregator +module Perf.Eventlog.Aggregate ( translateThreadEvents , collectThreadCounter ) @@ -8,7 +8,7 @@ where import Data.Int (Int64) import Data.Set (Set) import Data.Word (Word32) -import Eventlog.EventParser (Event (..), Counter(..), Location(..)) +import Perf.Eventlog.Parser (Event (..), Counter(..), Location(..)) import Streamly.Internal.Data.Fold (Step(..)) import Streamly.Internal.Data.Scanl (Scanl(..)) import Streamly.Internal.Data.Tuple.Strict (Tuple'(..)) diff --git a/lib/Eventlog/EventParser.hs b/lib/Perf/Eventlog/Parser.hs similarity index 99% rename from lib/Eventlog/EventParser.hs rename to lib/Perf/Eventlog/Parser.hs index d7ccbfd..2488465 100644 --- a/lib/Eventlog/EventParser.hs +++ b/lib/Perf/Eventlog/Parser.hs @@ -1,5 +1,5 @@ {-# LANGUAGE CPP #-} -module Eventlog.EventParser +module Perf.Eventlog.Parser ( parseLogHeader , parseDataHeader diff --git a/src/Main.hs b/src/Main.hs index 7625c28..1fc5284 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -3,7 +3,7 @@ module Main (main) where -import Eventlog.Aggregator +import Perf.Eventlog.Aggregate ( collectThreadCounter, translateThreadEvents, ) @@ -16,7 +16,7 @@ import Data.Map (Map) import Data.Maybe (fromJust, isJust) import Data.Text.Format.Numbers (prettyI) import Data.Word (Word32, Word8) -import Eventlog.EventParser +import Perf.Eventlog.Parser ( Counter (..), Location (..), Event (..), From a9058f3dbfafe0307aefc2446019e0b6759d8e12 Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Fri, 8 May 2026 15:39:05 +0530 Subject: [PATCH 5/7] Restructure the project, module names --- examples/getRTSStats.hs | 6 +++--- haskell-perf.cabal | 20 +++++++++---------- .../Internal/Measure/Bracket.hs} | 2 +- .../Perf => Perf/Internal/Measure}/RUsage.hsc | 6 +++--- .../Internal/Measure/Types.hs} | 4 ++-- .../Common.hs => Perf/Internal/Sink.hs} | 4 ++-- .../Metrics/Perf.hs => Perf/Measure.hs} | 8 ++++---- .../Type.hs => Perf/Metric/KeyValue.hs} | 4 ++-- lib/{Streamly/Metrics => Perf/Metric}/Type.hs | 4 ++-- .../Channel.hs => Perf/Sink/Console.hs} | 10 +++++----- .../Sink/Console}/Unbounded.hs | 10 +++++----- 11 files changed, 38 insertions(+), 40 deletions(-) rename lib/{Streamly/Metrics/Measure.hs => Perf/Internal/Measure/Bracket.hs} (98%) rename lib/{Streamly/Metrics/Perf => Perf/Internal/Measure}/RUsage.hsc (98%) rename lib/{Streamly/Metrics/Perf/Type.hs => Perf/Internal/Measure/Types.hs} (99%) rename lib/{Streamly/Metrics/Channel/Common.hs => Perf/Internal/Sink.hs} (95%) rename lib/{Streamly/Metrics/Perf.hs => Perf/Measure.hs} (95%) rename lib/{Streamly/KeyValue/Type.hs => Perf/Metric/KeyValue.hs} (96%) rename lib/{Streamly/Metrics => Perf/Metric}/Type.hs (99%) rename lib/{Streamly/Metrics/Channel.hs => Perf/Sink/Console.hs} (92%) rename lib/{Streamly/Metrics/Channel => Perf/Sink/Console}/Unbounded.hs (92%) diff --git a/examples/getRTSStats.hs b/examples/getRTSStats.hs index 56cbadd..043672f 100644 --- a/examples/getRTSStats.hs +++ b/examples/getRTSStats.hs @@ -1,8 +1,8 @@ import Control.Concurrent(threadDelay) -import Streamly.Metrics.Channel +import Perf.Sink.Console (Channel, newChannel, forkChannelPrinter, benchOnWith) --- import Streamly.Metrics.Channel (printChannel) -import Streamly.Metrics.Perf.Type (PerfMetrics) +-- import Perf.Sink.Console (printChannel) +import Perf.Internal.Measure.Types (PerfMetrics) import qualified Streamly.Data.Fold as Fold import qualified Streamly.Data.Stream as Stream diff --git a/haskell-perf.cabal b/haskell-perf.cabal index 02baf63..aa0a9d9 100644 --- a/haskell-perf.cabal +++ b/haskell-perf.cabal @@ -134,22 +134,20 @@ library hs-source-dirs: lib exposed-modules: - Streamly.KeyValue.Type - , Streamly.Metrics.Type - , Streamly.Metrics.Perf - , Streamly.Metrics.Perf.Type - , Streamly.Metrics.Channel - , Streamly.Metrics.Channel.Unbounded - , Streamly.Metrics.Channel.Common - , Streamly.Metrics.Measure - -- , Streamly.Metrics.File - -- , Streamly.Metrics.Console + Perf.Metric.KeyValue + , Perf.Metric.Type + , Perf.Measure + , Perf.Internal.Measure.Types + , Perf.Internal.Measure.Bracket + , Perf.Sink.Console + , Perf.Sink.Console.Unbounded + , Perf.Internal.Sink , Perf.Eventlog.Parser , Perf.Eventlog.Aggregate if !os(windows) exposed-modules: - Streamly.Metrics.Perf.RUsage + Perf.Internal.Measure.RUsage build-depends: base >= 4.9 && < 5 diff --git a/lib/Streamly/Metrics/Measure.hs b/lib/Perf/Internal/Measure/Bracket.hs similarity index 98% rename from lib/Streamly/Metrics/Measure.hs rename to lib/Perf/Internal/Measure/Bracket.hs index 4b6e38f..153c5fa 100644 --- a/lib/Streamly/Metrics/Measure.hs +++ b/lib/Perf/Internal/Measure/Bracket.hs @@ -1,4 +1,4 @@ -module Streamly.Metrics.Measure +module Perf.Internal.Measure.Bracket ( measureWith , measure diff --git a/lib/Streamly/Metrics/Perf/RUsage.hsc b/lib/Perf/Internal/Measure/RUsage.hsc similarity index 98% rename from lib/Streamly/Metrics/Perf/RUsage.hsc rename to lib/Perf/Internal/Measure/RUsage.hsc index 4925bc3..b23218b 100644 --- a/lib/Streamly/Metrics/Perf/RUsage.hsc +++ b/lib/Perf/Internal/Measure/RUsage.hsc @@ -1,4 +1,4 @@ -module Streamly.Metrics.Perf.RUsage +module Perf.Internal.Measure.RUsage ( pattern RUsageSelf , pattern RUsageChildren @@ -16,8 +16,8 @@ import Foreign.C.Types (CInt(..), CLong) import Foreign.Marshal.Alloc (alloca) import Foreign.Ptr (Ptr) import Foreign.Storable (Storable(..)) -import Streamly.Metrics.Perf.Type (PerfMetrics(..)) -import Streamly.Metrics.Type (GaugeMax(..), Seconds(..), Bytes(..)) +import Perf.Internal.Measure.Types (PerfMetrics(..)) +import Perf.Metric.Type (GaugeMax(..), Seconds(..), Bytes(..)) #include #include diff --git a/lib/Streamly/Metrics/Perf/Type.hs b/lib/Perf/Internal/Measure/Types.hs similarity index 99% rename from lib/Streamly/Metrics/Perf/Type.hs rename to lib/Perf/Internal/Measure/Types.hs index 6524086..18b1482 100644 --- a/lib/Streamly/Metrics/Perf/Type.hs +++ b/lib/Perf/Internal/Measure/Types.hs @@ -1,4 +1,4 @@ -module Streamly.Metrics.Perf.Type +module Perf.Internal.Measure.Types ( PerfMetrics (..) , checkMonotony @@ -6,7 +6,7 @@ module Streamly.Metrics.Perf.Type where import Data.Word (Word64) -import Streamly.Metrics.Type +import Perf.Metric.Type (GaugeMax(..), Seconds(..), Bytes(..), Indexable(..)) -- Use Counter/Gauge as the outer constructor and Bytes/Seconds as the inner diff --git a/lib/Streamly/Metrics/Channel/Common.hs b/lib/Perf/Internal/Sink.hs similarity index 95% rename from lib/Streamly/Metrics/Channel/Common.hs rename to lib/Perf/Internal/Sink.hs index 9d66b8d..8fe0663 100644 --- a/lib/Streamly/Metrics/Channel/Common.hs +++ b/lib/Perf/Internal/Sink.hs @@ -1,4 +1,4 @@ -module Streamly.Metrics.Channel.Common +module Perf.Internal.Sink ( aggregateListBy , printKV @@ -9,7 +9,7 @@ import Control.Monad.IO.Class (liftIO, MonadIO) import Data.Bifunctor (second) import Data.Maybe (fromJust, isJust) import Streamly.Internal.Data.Time.Units (AbsTime) -import Streamly.Metrics.Type (showList, Indexable) +import Perf.Metric.Type (showList, Indexable) import Streamly.Data.Stream (Stream) import Streamly.Data.Stream.Prelude (MonadAsync) diff --git a/lib/Streamly/Metrics/Perf.hs b/lib/Perf/Measure.hs similarity index 95% rename from lib/Streamly/Metrics/Perf.hs rename to lib/Perf/Measure.hs index a21a56e..5950a18 100644 --- a/lib/Streamly/Metrics/Perf.hs +++ b/lib/Perf/Measure.hs @@ -1,4 +1,4 @@ -module Streamly.Metrics.Perf +module Perf.Measure ( PerfMetrics(..) , benchWith @@ -12,10 +12,10 @@ import Control.Monad (unless) import Data.Maybe (catMaybes) import GHC.Stats (getRTSStats, getRTSStatsEnabled, RTSStats(..)) import Streamly.Internal.Data.Time.Units (NanoSecond64, fromAbsTime) -import Streamly.Metrics.Measure (measureWith) -import Streamly.Metrics.Perf.Type (PerfMetrics(..), checkMonotony) +import Perf.Internal.Measure.Bracket (measureWith) +import Perf.Internal.Measure.Types (PerfMetrics(..), checkMonotony) #if !defined(mingw32_HOST_OS) -import Streamly.Metrics.Perf.RUsage (getRuMetrics, pattern RUsageSelf) +import Perf.Internal.Measure.RUsage (getRuMetrics, pattern RUsageSelf) #endif import Text.Show.Pretty (ppShow) diff --git a/lib/Streamly/KeyValue/Type.hs b/lib/Perf/Metric/KeyValue.hs similarity index 96% rename from lib/Streamly/KeyValue/Type.hs rename to lib/Perf/Metric/KeyValue.hs index 18d90e9..226d291 100644 --- a/lib/Streamly/KeyValue/Type.hs +++ b/lib/Perf/Metric/KeyValue.hs @@ -1,12 +1,12 @@ -- | --- Module : Streamly.KeyValue.Type +-- Module : Perf.Metric.KeyValue -- Copyright : (c) 2021 Composewell Technologies -- License : Apache-2.0 -- Maintainer : streamly@composewell.com -- Stability : experimental -- Portability : GHC -- -module Streamly.KeyValue.Type +module Perf.Metric.KeyValue ( -- * KeyValue KeyValue (..) diff --git a/lib/Streamly/Metrics/Type.hs b/lib/Perf/Metric/Type.hs similarity index 99% rename from lib/Streamly/Metrics/Type.hs rename to lib/Perf/Metric/Type.hs index 39fe9ff..418a5f0 100644 --- a/lib/Streamly/Metrics/Type.hs +++ b/lib/Perf/Metric/Type.hs @@ -1,6 +1,6 @@ {-# LANGUAGE DerivingVia #-} -- | --- Module : Streamly.Metrics.Type +-- Module : Perf.Metric.Type -- Copyright : (c) 2021 Composewell Technologies -- License : Apache-2.0 -- Maintainer : streamly@composewell.com @@ -12,7 +12,7 @@ -- respect to time e.g. 'Sequence' or 'Time'. Metrics may have different -- semantics e.g. 'Counter' or 'Gauge'. -- -module Streamly.Metrics.Type +module Perf.Metric.Type ( -- * Semantics -- | A counter counts how many events of a type have occurred whereas a diff --git a/lib/Streamly/Metrics/Channel.hs b/lib/Perf/Sink/Console.hs similarity index 92% rename from lib/Streamly/Metrics/Channel.hs rename to lib/Perf/Sink/Console.hs index b9a10ec..a257e0b 100644 --- a/lib/Streamly/Metrics/Channel.hs +++ b/lib/Perf/Sink/Console.hs @@ -1,4 +1,4 @@ -module Streamly.Metrics.Channel +module Perf.Sink.Console ( Channel , newChannel @@ -19,10 +19,10 @@ import Data.Function ((&)) import Streamly.Data.Stream (Stream) import Streamly.Internal.Data.Time.Clock (getTime, Clock (Monotonic)) import Streamly.Internal.Data.Time.Units (AbsTime) -import Streamly.Metrics.Channel.Common (aggregateListBy, printKV) -import Streamly.Metrics.Perf.Type (PerfMetrics(..)) -import Streamly.Metrics.Perf (benchWith) -import Streamly.Metrics.Type (Indexable) +import Perf.Internal.Sink (aggregateListBy, printKV) +import Perf.Internal.Measure.Types (PerfMetrics(..)) +import Perf.Measure (benchWith) +import Perf.Metric.Type (Indexable) import Streamly.Data.Stream.Prelude (MonadAsync) import qualified Streamly.Data.Stream as Stream diff --git a/lib/Streamly/Metrics/Channel/Unbounded.hs b/lib/Perf/Sink/Console/Unbounded.hs similarity index 92% rename from lib/Streamly/Metrics/Channel/Unbounded.hs rename to lib/Perf/Sink/Console/Unbounded.hs index 1df3fa8..4876f3d 100644 --- a/lib/Streamly/Metrics/Channel/Unbounded.hs +++ b/lib/Perf/Sink/Console/Unbounded.hs @@ -1,4 +1,4 @@ -module Streamly.Metrics.Channel.Unbounded +module Perf.Sink.Console.Unbounded ( Channel , newChannel @@ -16,16 +16,16 @@ import Control.Monad.IO.Class (liftIO, MonadIO) import Data.Function ((&)) import Streamly.Internal.Data.Time.Clock (getTime, Clock (Monotonic)) import Streamly.Internal.Data.Time.Units (AbsTime) -import Streamly.Metrics.Perf.Type (PerfMetrics(..)) -import Streamly.Metrics.Perf (benchWith) -import Streamly.Metrics.Type (Indexable) +import Perf.Internal.Measure.Types (PerfMetrics(..)) +import Perf.Measure (benchWith) +import Perf.Metric.Type (Indexable) import Streamly.Data.Stream (Stream) import Streamly.Data.Stream.Prelude (MonadAsync) import qualified Streamly.Data.Stream as Stream import Prelude hiding (showList) -import Streamly.Metrics.Channel.Common +import Perf.Internal.Sink ------------------------------------------------------------------------------- -- Event processing From 68bd91283b3b4577445cf4287ac4b0f37fc2e655 Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Fri, 8 May 2026 15:53:18 +0530 Subject: [PATCH 6/7] Add note about "eventlog" and "metrics" commands --- src/Main.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Main.hs b/src/Main.hs index 1fc5284..ffd41ae 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -466,6 +466,9 @@ optsInfo = info (configParser <**> helper) -- Entry point ------------------------------------------------------------------------------- +-- XXX Add two different commands "hperf eventlog" and "hperf metrics", one for +-- eventlog analysis and the other for metrics collected by other methods. +-- -- XXX Are the events for a particular thread guaranteed to come in order. What -- if a thread logged events to a particular capability buffer and then got -- scheduled on another capability before its eventlog could be flushed from From 0834a73e0391fdc01434a67dd0b3ae92b2074eb8 Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Fri, 8 May 2026 16:07:19 +0530 Subject: [PATCH 7/7] Rename the "hperf" app directory --- haskell-perf.cabal | 2 +- {src => hperf}/Main.hs | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename {src => hperf}/Main.hs (100%) diff --git a/haskell-perf.cabal b/haskell-perf.cabal index aa0a9d9..ad3109b 100644 --- a/haskell-perf.cabal +++ b/haskell-perf.cabal @@ -163,7 +163,7 @@ library executable hperf import: compile-options, optimization-options - hs-source-dirs: src + hs-source-dirs: hperf main-is: Main.hs build-depends: base >= 4.9 && < 5 diff --git a/src/Main.hs b/hperf/Main.hs similarity index 100% rename from src/Main.hs rename to hperf/Main.hs