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

Exchange pallet benchmarks #158

Merged
merged 6 commits into from
Jul 16, 2020
Merged

Exchange pallet benchmarks #158

merged 6 commits into from
Jul 16, 2020

Conversation

svyatonik
Copy link
Contributor

@svyatonik svyatonik commented Jul 1, 2020

WIP: should be rebased on master once #155 is reviewed + merged
part of #78

The main difficulty with benchmarking this pallet is that it is too generic && I was unable to write any runtime specific code there. So there's extended Trait and fn Trait::make_proof(), which asks runtime to prepare environment+proof for executing import extrinsic.

There are now 5 benchmarks there:

  1. import_peer_transaction_best_case - imports minimal proof (transaction itself), transaction has minimal size (see below) and recipient account exists;
  2. import_peer_transaction_when_recipient_does_not_exists - the same as (1), but recipient account is created during import;
  3. import_peer_transaction_when_transaction_size_increases - test runtime only accepts transactions of minimal size (where data field is 32-bytes pub key of Substrate' recipient), so this is the same as (1);
  4. import_peer_transaction_when_proof_size_increases - the same as (1), but proof size changes from 1 to 1000. Proof size here = number of transactions in PoA block. So worst case is 1000 txs/block. If you think we should have another value for that - please share your thoughts;
  5. import_peer_transaction_worst_case - recipient account does not exists, proof size is 1000 transactions, every transaction has maximal size (though in test runtime it it the same minimal size).

Copy link
Contributor

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

lgtm! The make_proof trait is a good way to handle runtime-specific stuff afaict.

@svyatonik
Copy link
Contributor Author

(rebased on master. will leave it open until monday)

@svyatonik svyatonik marked this pull request as ready for review July 3, 2020 13:28
@svyatonik svyatonik changed the title Exchange pallet benchmarks (WIP) Exchange pallet benchmarks Jul 3, 2020
@HCastano HCastano self-requested a review July 3, 2020 14:45
@@ -206,6 +223,20 @@ where
custom_header.sign_by(author)
}

/// Insert unverified header into storage.
pub fn insert_header<S: Storage>(storage: &mut S, header: Header) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I made the same move in my PR, lol

@@ -117,9 +117,9 @@ pub struct UnsignedTransaction {
pub gas: U256,
/// Transaction destination address. None if it is contract creation transaction.
pub to: Option<Address>,
/// Transaction value.
/// Value.
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't really add much value in terms of describing what "value" is. I'd beef up the description a bit

pub value: U256,
/// Transaction payload.
/// Associated data.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

add_benchmark!(params, batches, b"bridge-eth-poa", BridgeEthPoA);
add_benchmark!(params, batches, b"bridge-currency-exchange", BridgeCurrencyExchangeBench::<Runtime>);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not relevant for this PR, but there was recently a change introduced in Substrate that changed the arguments to this macro. We'll need to update that next time we bump Substrate


const SEED: u32 = 0;
const WORST_TX_SIZE_FACTOR: u32 = 1000;
const WORST_PROOF_SIZE_FACTOR: u32 = 1000;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think 1000 is fine, we just need to see how the time to run the extrinsic scales as this increases anyways

Copy link
Contributor

@HCastano HCastano left a comment

Choose a reason for hiding this comment

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

Looks good!

@HCastano
Copy link
Contributor

HCastano commented Jul 5, 2020

There do seem to be some problems with the CI (it doesn't look like they're caused by this PR). Should we wait until those are addressed to merge this?

Copy link
Contributor

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

Looks good modulo Hernando's grumbles.

// * Transaction has large size.
// * Recipient account does not exists.
import_peer_transaction_worst_case {
let i in 1..100;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we name the one-letter variables to something more descriptive? The code now is pretty small, but if it grows over time it might get harder to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Responded here

@tomusdrw tomusdrw merged commit fc22769 into master Jul 16, 2020
@tomusdrw tomusdrw deleted the exchange-benchmarks branch July 16, 2020 09:58
svyatonik pushed a commit that referenced this pull request Jul 17, 2023
serban300 pushed a commit to serban300/parity-bridges-common that referenced this pull request Mar 27, 2024
* exchange benchmarks: framework

* updated comment about tx size

Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
serban300 pushed a commit to serban300/parity-bridges-common that referenced this pull request Apr 8, 2024
* exchange benchmarks: framework

* updated comment about tx size

Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
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.

3 participants