Skip to content

Commit

Permalink
WIP estimating validation bit rate
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrisby committed Sep 13, 2024
1 parent bc67236 commit 352870e
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
70 changes: 70 additions & 0 deletions scripts/estimating-validation-bitrate/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
- `db-analyser --benchmark-ledger-ops` lists the fixed stats, and then for Byron and Shelley it currently also lists the number of txs and the total size of the txs.

- `db-analyser --show-block-header-size` lists the size of the block's header.
I ran a patched version that also simply includes the block size.

- `MsgBlock` has an overhead of 2 bytes (ie the list length and the word tag, since both are <24).

- I _think_ `network-mux`'s SDU overhead is 8 bytes, from https://github.com/IntersectMBO/ouroboros-network/blob/db61131c2f375842f0930a8a9cf7f83b0cb80992/network-mux/src/Network/Mux/Codec.hs#L28-L40.
However, I don't know how many SDUs each byte requires.
So I'll omit this.

Thus the number of bytes in each block that are carried by the `network-mux` is: 2 + 1 + hdrSize + txSize.

-----

The basic idea of this simple script is to divide real-world time up into non-overlapping 10 second chunks.
We use only mutator time, essentially assuming that GC is instantaneous; this conservatively _over_-estimates the effective bit rate.
Map each chunk to the set of blocks whose validation began during that chunk.
Then divide the sum of the validation mutator duration for each block by the sum of the on-the-wire size of each.

First, a sanity check.

```
$ cat show-block-header-size.txt | awk '($4 != "SlotNo") {print $0} ($6 != "header") {print $0}'
[0.834136s] Started ShowBlockHeaderSize
[0.834136s] Started ShowBlockHeaderSize
[1926.666379s] Maximum encountered header size = 1012
[1926.666379s] Maximum encountered header size = 1012
[1926.666504s] Done
[1926.666504s] Done
ImmutableDB tip: At (Block {blockPointSlot = SlotNo 133220620, blockPointHash = 8b0597e7cf5c65b9d00af8a162d30eaae6647f868224004b02d7bd30e1d3f93f})
ImmutableDB tip: At (Block {blockPointSlot = SlotNo 133220620, blockPointHash = 8b0597e7cf5c65b9d00af8a162d30eaae6647f868224004b02d7bd30e1d3f93f})
```

Then, the real plot as well as another sanity check of the number of blocks mapped to each 10 second chunk of mutator time.

The assumed inputs are benchmark-ledger-ops.csv and patched-show-block-header-sizes.txt, where the latter used a patched `db-analyser` to include an additional column for `GetBlockSize`.
(The sum of the `txSizes` in the `..era-specific stats` is a slight underestimate.)

```
$ cat benchmark-ledger-ops.csv | cut -d' ' -f1,12,13 | tail -n+2 >SlotNo-BodyTickDur-BodyAppDur.txt
$ paste SlotNo-BodyTickDur-BodyAppDur.txt <(tail -n+2 patched-show-block-header-sizes.txt) | gawk 'BEGIN {CONVFMT="%.18g" } ($1 != $8) { exit} {x = x + $2 + $3; y = y + 2 + $14; print $1, x, y}' > SlotNo-CumuDur-CumuSize.txt
$ cat SlotNo-CumuDur-CumuSize.txt | gawk 'BEGIN {w = 10; CONVFMT="%.18g"; prevX = -1; prevY = 0; prevZ = 0} {x = int($2 / (1000 * 1000 * w)); y = $3} (x != prevX) {print $1, (y - prevY) / w * 8 / (1000*1000), NR - prevZ; prevY = y; prevZ = NR} {prevX = x}' >catch
$ tail -n1 SlotNo-CumuDur-CumuSize.txt
133075481 140291882237 190610147733
$ head -n1000 gp.scr*
==> gp.scr <==
set multiplot layout 2,1

set title 'Validation Bit Rate (on an AMD EPYC 7702P)'

set xlabel 'slot number of the last block in each 10 second chunk (millions of slots)'
set ylabel 'bytes validated per 10 second chunk of mutator time (megabits per second)'

plot 'catch' using 1:2 notitle

set yrange [0:25]

unset title
set xlabel 'same'
set ylabel 'same, clamped to 25'

plot 'catch' using 1:($2 > 25 ? 25 : $2) notitle

==> gp.scr2 <==
set xlabel 'slot number of the last block in each 10 second chunk (millions of slots)'
set ylabel 'blocks per 10 second chunk of mutator time, clamped to 1000'

plot 'catch' using 1:(1000 < $3 ? 1000 : $3) notitle
```
16 changes: 16 additions & 0 deletions scripts/estimating-validation-bitrate/gp.scr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
set multiplot layout 2,1

set title 'Validation Bit Rate'

set xlabel 'slot number of the last block in each 10 second chunk (millions of slots)'
set ylabel 'bytes validated per 10 second chunk of mutator time (megabits per second)'

plot 'catch' using ($1 / 1000000):2 notitle

set yrange [0:25]

unset title
set xlabel 'same'
set ylabel 'same, clamped to 25'

plot 'catch' using ($1 / 1000000):($2 > 25 ? 25 : $2) notitle
4 changes: 4 additions & 0 deletions scripts/estimating-validation-bitrate/gp.scr2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set xlabel 'slot number (at end of each 10 second chunk)'
set ylabel 'blocks per 10 second chunk of mutator time, clamped to 1000'

plot 'catch' using 1:(1000 < $3 ? 1000 : $3) notitle

0 comments on commit 352870e

Please sign in to comment.