-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a ledger operations benchmarking analysis to db-analyser #4014
Conversation
I invoke the tool like this:
and then feed it to this Gnuplot script
This time, I interrupted the tool after a few minutes, so the tool didn't get through very many slots. It yielded the following chart. I used the commits from the The x-axis is the slot number of the block, the y-axis is duration in microseconds. The extra-tall orange ticks demarcate the first slot of each epoch. Legend semantics:
That top chart shows both significant mutator and GC time elapsed at the first block of each epoch (these epochs were still d>0, so the first slot was always filled by an overlay schedule block). The second chart shows how that mutator time decomposes: mostly block ticking (not surprising) and header application (surprising!). I haven't checked yet, but strongly anticipate that this bang pattern isn't sufficient to force the entire forecast operation, and so significant portions of the duration of the forecast computation are instead being forced by (and so attributed to) the header application computation. (Edit: see PR #4028 -- my suspicion was correct and the plots in later comments on this PR used that patch) |
Here's my latest gnuplot script, which I invoke like this
|
Some observations from these results:
|
Possible ways to drive this PR home:
Example of a place were we could add more comments: -- why do we return this:
pure $ St rtsStats5 $ ExtLedgerState ldgrSt' headerState' We might consider adding some ASCII version of these drawings to the documentation |
FWIW, my initial reaction was the same as Arnaud's:
I've also had pleasant experiences with some JS libraries (plop your data in a JSON array, copy it in to a HTML file, and boom you have interactive plots). I would hesitate to commit to any plotting library in Haskell -- I expect it all to inevitably break 😢. But that's easy enough: just also commit the gnuplot script as a back-up? Are you liking the vega interface? |
@nfrisby one of the next steps I had in mind was to output each line as a JSON representation of a data SlotDataPoint =
SlotDataPoint
{ slot :: Int
, totalTime :: Int
, mut :: Int
, gc :: Int
-- ...
} and this is the format that the new plotting and analyzing tool will ingest. In this way, we make sure that if we change the output data in the |
Yeah, we could ultimately do that with vega-lite.
What would "breaking" mean in this case? If for instance version 4, the currently supported version of vega-lite, is not distributed anymore by the CDN? In that case this could be a problem indeed. We could then spit out a vega-lite conforming JSON directly.
Sure thing.
I am. I looked at 4 different Haskell plotting libraries, and this is by far the easiest one to learn and use, albeit not being all the type-safe one would like, but I guess that's a trade off for usability? @nfrisby how should I proceed:
|
Why do you have to do that? Can you plot them all (like my gnuplot script does) and then set the x-axis bounds explicitly to automatically crop out the "extra" epoch/era boundaries?
Why generate the gnuplot script? Can't a static script suffice? Or maybe one that takes I don't have a preference. Tangent: The JSON format is a lot of per-line overhead, so that'll slow things down for longer runs and swell file sizes. Neither of which really matters, but I personally prefer the X-separated values format for tabular data. |
Won't you end up with vertical lines outside the x-axis as we can see in some of the plots above? Is there a way to prevent this in gnuplot?
In that case I'm going to keep the vega-lite backend just because it gives us the possibility of zooming in and the plots show a tooltip with the data values when the mouse pointer hovers over the data point.
Good point. This is the problem I want to solve: I'd like to couple the plotting program with the benchmarking program in such a way that if the latter outputs the data in a different format (eg swapping the order of the columns), we can detect this discrepancy at compile time. I guess I could define a |
c6795e2
to
891d380
Compare
Related PR that removes the forecasting step in the forging logic #4099 |
ouroboros-consensus-cardano/tools/db-analyser/scripts/plot-ledger-ops-cost.gp
Outdated
Show resolved
Hide resolved
ouroboros-consensus-cardano/tools/db-analyser/scripts/plot-ledger-ops-cost.gp
Outdated
Show resolved
Hide resolved
4028: consensus: make TickHardForkLedgerView fields strict r=nfrisby a=nfrisby While preparing PR #4014, I noticed the `forecast` function for `CardanoBlock` was lazy. This small patch makes it strict. This is a Draft PR because I'm not totally sure we want it to be strict. Co-authored-by: Nicolas Frisby <nick.frisby@iohk.io>
4028: consensus: make TickHardForkLedgerView fields strict r=nfrisby a=nfrisby While preparing PR #4014, I noticed the `forecast` function for `CardanoBlock` was lazy. This small patch makes it strict. This is a Draft PR because I'm not totally sure we want it to be strict. Co-authored-by: Nicolas Frisby <nick.frisby@iohk.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing major. Looks good!
I realized something, though: this PR is not aimed at the master
branch. So, we should:
-
change the PR to target
master
(.... I'm not even sure that's possible, but I'll try) -
rebase the commits onto
master
(which will be a bit of a bother sincedb-analyser
was relocated toouroboros-consensus-cardano-tools
). -
also, the PR description is stale.
ouroboros-consensus-cardano/tools/db-analyser/Analysis/BenchmarkLedgerOps/SlotDataPoint.hs
Outdated
Show resolved
Hide resolved
ouroboros-consensus-cardano/tools/db-analyser/Analysis/BenchmarkLedgerOps/SlotDataPoint.hs
Outdated
Show resolved
Hide resolved
ouroboros-consensus-cardano/tools/db-analyser/scripts/plot-ledger-ops-cost.gp
Outdated
Show resolved
Hide resolved
ab6e540
to
3affef0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damian and had a couple calls on this. I Approve 🙌 (though he'll have to click that, since I opened the PR originally.)
In addition: - Add a gnuplot script to plot the results of ledger ops benchmarking. - This commit also creates the `script` directory in the root of the `db-analyser` directory. The plotting script is placed inside the former. - Remove stale sentence in the README - Provide examples of how to use db-analyser to store ledger db-snapshots and benchmark the ledger operations.
3aa1d9b
to
74929d4
Compare
bors r+ |
4014: Add a ledger operations benchmarking analysis to db-analyser r=dnadales a=nfrisby Add support to `db-analyser` for benchmarking the five major ledger calculations for each block: 0. Forecast. 1. Header tick. 2. Header application. 3. Block tick. 4. Block application. We focus on these 5 operations because they are involved in: - Chain syncing. - Block forging. - Block validation. Fixes #4052 Co-authored-by: Nicolas Frisby <nick.frisby@iohk.io>
Timed out. |
Add support to
db-analyser
for benchmarking the five major ledger calculations for each block:We focus on these 5 operations because they are involved in:
Fixes #4052