@@ -41,7 +41,7 @@ import Data.Int (Int64)
41
41
import Data.List (intercalate )
42
42
import qualified Data.Map.Strict as Map
43
43
import Data.Singletons
44
- import Data.Word (Word16 , Word64 )
44
+ import Data.Word (Word16 , Word32 , Word64 )
45
45
import qualified Debug.Trace as Debug
46
46
import qualified GHC.Stats as GC
47
47
import NoThunks.Class (noThunks )
@@ -182,11 +182,12 @@ data TraceEvent blk =
182
182
| CountedBlocksEvent Int
183
183
-- ^ triggered once during CountBLocks analysis,
184
184
-- when blocks were counted
185
- | HeaderSizeEvent BlockNo SlotNo Word16
185
+ | HeaderSizeEvent BlockNo SlotNo Word16 Word32
186
186
-- ^ triggered when header size has been measured
187
187
-- * block's number
188
188
-- * slot number when the block was forged
189
189
-- * block's header size
190
+ -- * block's size
190
191
| MaxHeaderSizeEvent Word16
191
192
-- ^ triggered once during ShowBlockTxsSize analysis,
192
193
-- holding maximum encountered header size
@@ -238,10 +239,11 @@ instance (HasAnalysis blk, LedgerSupportsProtocol blk) => Show (TraceEvent blk)
238
239
, " Known: " <> show known
239
240
]
240
241
show (CountedBlocksEvent counted) = " Counted " <> show counted <> " blocks."
241
- show (HeaderSizeEvent bn sn headerSize) = intercalate " \t " $ [
242
+ show (HeaderSizeEvent bn sn hSz bSz) = intercalate " \t " $ [
242
243
show bn
243
244
, show sn
244
- , " header size: " <> show headerSize
245
+ , " header size: " <> show hSz
246
+ , " block size: " <> show bSz
245
247
]
246
248
show (MaxHeaderSizeEvent size) =
247
249
" Maximum encountered header size = " <> show size
@@ -312,15 +314,16 @@ countTxOutputs AnalysisEnv { db, registry, startFrom, limit, tracer } = do
312
314
showHeaderSize :: forall blk . HasAnalysis blk => Analysis blk StartFromPoint
313
315
showHeaderSize AnalysisEnv { db, registry, startFrom, limit, tracer } = do
314
316
maxHeaderSize <-
315
- processAll db registry ((,) <$> GetHeader <*> GetHeaderSize ) startFrom limit 0 process
317
+ processAll db registry ((,, ) <$> GetHeader <*> GetHeaderSize <*> GetBlockSize ) startFrom limit 0 process
316
318
traceWith tracer $ MaxHeaderSizeEvent maxHeaderSize
317
319
pure $ Just $ ResultMaxHeaderSize maxHeaderSize
318
320
where
319
- process :: Word16 -> (Header blk , Word16 ) -> IO Word16
320
- process maxHeaderSize (hdr, headerSize) = do
321
+ process :: Word16 -> (Header blk , Word16 , SizeInBytes ) -> IO Word16
322
+ process maxHeaderSize (hdr, headerSize, blockSize ) = do
321
323
let event = HeaderSizeEvent (blockNo hdr)
322
324
(blockSlot hdr)
323
325
headerSize
326
+ (getSizeInBytes blockSize)
324
327
traceWith tracer event
325
328
return $ maxHeaderSize `max` headerSize
326
329
@@ -548,7 +551,14 @@ benchmarkLedgerOps mOutfile ledgerAppMode AnalysisEnv {db, registry, startFrom,
548
551
F. writeMetadata outFileHandle outFormat ledgerAppMode
549
552
F. writeHeader outFileHandle outFormat
550
553
551
- void $ processAll db registry GetBlock startFrom limit initLedger (process outFileHandle outFormat)
554
+ void $ processAll
555
+ db
556
+ registry
557
+ ((,) <$> GetBlock <*> GetBlockSize )
558
+ startFrom
559
+ limit
560
+ initLedger
561
+ (process outFileHandle outFormat)
552
562
pure Nothing
553
563
where
554
564
ccfg = topLevelConfigProtocol cfg
@@ -560,9 +570,9 @@ benchmarkLedgerOps mOutfile ledgerAppMode AnalysisEnv {db, registry, startFrom,
560
570
IO. Handle
561
571
-> F. OutputFormat
562
572
-> ExtLedgerState blk
563
- -> blk
573
+ -> ( blk , SizeInBytes )
564
574
-> IO (ExtLedgerState blk )
565
- process outFileHandle outFormat prevLedgerState blk = do
575
+ process outFileHandle outFormat prevLedgerState ( blk, sz) = do
566
576
prevRtsStats <- GC. getRTSStats
567
577
let
568
578
-- Compute how many nanoseconds the mutator used from the last
@@ -604,6 +614,7 @@ benchmarkLedgerOps mOutfile ledgerAppMode AnalysisEnv {db, registry, startFrom,
604
614
, DP. mut_headerApply = tHdrApp `div` 1000
605
615
, DP. mut_blockTick = tBlkTick `div` 1000
606
616
, DP. mut_blockApply = tBlkApp `div` 1000
617
+ , DP. blockByteSize = getSizeInBytes sz
607
618
, DP. blockStats = DP. BlockStats $ HasAnalysis. blockStats blk
608
619
}
609
620
0 commit comments