Skip to content
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

aggregateUTxOCoinByCredential benchmarks and performance tuning #2241

Merged
merged 2 commits into from Apr 19, 2021

Conversation

nc6
Copy link
Contributor

@nc6 nc6 commented Apr 19, 2021

I took a look at this a bit on Friday morning, and given the brouhaha over the weekend, it seemed worth pushing!

This PR adds a more detailed and comprehensive benchmark for aggregateUTxOCoinByCredential, and makes some (minor) performance improvements.

nc6 added 2 commits April 19, 2021 11:19
It was only after writing this that I noticed we already had some
benchmarks for this function, in

- https://github.com/input-output-hk/cardano-ledger-specs/blob/master/shelley/chain-and-ledger/shelley-spec-ledger-test/bench/BenchUTxOAggregate.hs
and
- https://github.com/input-output-hk/cardano-ledger-specs/blob/master/shelley/chain-and-ledger/shelley-spec-ledger-test/bench/Main.hs#L221

However, upon examining that benchmark, I think it's still worth having
this one (and maybe dropping the other). The existing benchmark uses
`gen` (I believe without fixing the seed), making it hard to test the
same case each time. And whilst we can control the size of the UTxO,
this new benchmark allows explicit control over the key things important
to the UTxO aggregation calculation, namely:
- The number of base stake addresses
- The number of pointer stake addresses (which require some additional
  computation), and
- The "delegation" factor; i.e. the number of TxOuts for each stake
  address.
This makes a couple of minor improvements in the function
'aggregateUtxoCoinByCredential', as measured by the new benchmark
introduced.

I tried a few variants; see
https://drive.google.com/drive/u/1/folders/1o7r4EF0uM5gfhtf3_GoMSJdoHc_d6Xtc
for the full reports. This version seems to shave maybe 20% off of the
20K UTxO run.

Interestingly, a variant where we try to explicitly deserialise only the
stake ref (using `deserialiseAddrStakeRef`) was _considerably_ slower.
I'm not immediately sure why!
@nc6 nc6 requested a review from JaredCorduan April 19, 2021 09:54
@nc6
Copy link
Contributor Author

nc6 commented Apr 19, 2021

Some subsidiary results from this:

  • The extra cost of pointer addresses in this calculation is minimal.
  • The effect of the "delegation factor" is also minimal.

@nc6
Copy link
Contributor Author

nc6 commented Apr 19, 2021

But also: I haven't managed to actually be patient enough to get the benchmark results for a UTxO with 200,000 stake addresses yet - this definitely gets very expensive quickly.

Copy link
Contributor

@JaredCorduan JaredCorduan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @nc6 !

@nc6 nc6 merged commit 3ffb903 into master Apr 19, 2021
@iohk-bors iohk-bors bot deleted the nc/aggregate-utxo-bench branch April 19, 2021 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants