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

Follow up work on TransactionExtension - fix weights and clean up UncheckedExtrinsic #6418

Merged
merged 25 commits into from
Nov 14, 2024

Conversation

georgepisaltu
Copy link
Contributor

@georgepisaltu georgepisaltu commented Nov 8, 2024

Follow up to #3685
Partially fixes #6403

The main PR introduced bare support for the new extension version byte as well as extension weights and benchmarking.

This PR:

  • Removes the redundant extension version byte from the signed v4 extrinsic, previously unused and defaulted to 0.
  • Adds the extension version byte to the inherited implication passed to General transactions.
  • Whitelists the pallet_authorship::Author, frame_system::Digest and pallet_transaction_payment::NextFeeMultiplier storage items as they are read multiple times by extensions for each transaction, but are hot in memory and currently overestimate the weight.
  • Whitelists the benchmark caller for CheckEra and CheckGenesis as the reads are performed for every transaction and overestimate the weight.
  • Updates the umbrella frame weight template to work with the system extension changes.
  • Plans on re-running the benchmarks at least for the frame_system extensions.

@georgepisaltu georgepisaltu added the T1-FRAME This PR/Issue is related to core FRAME, the framework. label Nov 8, 2024
@georgepisaltu georgepisaltu self-assigned this Nov 8, 2024
@georgepisaltu georgepisaltu requested a review from a team as a code owner November 8, 2024 15:18
@georgepisaltu
Copy link
Contributor Author

bot bench-all substrate -v PIPELINE_SCRIPTS_REF=george/substrate-ext

@command-bot
Copy link

command-bot bot commented Nov 8, 2024

@georgepisaltu https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7726182 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/bench-all/bench-all.sh" --target_dir=substrate. Check out https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 67-8250ce9d-3053-4ab9-bb93-914cdeaedc3a to cancel this command or bot cancel to cancel all commands in this pull request.

@command-bot
Copy link

command-bot bot commented Nov 8, 2024

@georgepisaltu Command "$PIPELINE_SCRIPTS_DIR/commands/bench-all/bench-all.sh" --target_dir=substrate has finished. Result: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7726182 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7726182/artifacts/download.

Copy link
Contributor

@gui1117 gui1117 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 to me, but one comment

//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024`

// Executed Command:
// ./target/debug/substrate-node
Copy link
Member

Choose a reason for hiding this comment

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

Lol these weights were def wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it's a new and currently unused extension introduced in #3685 and those weights were generated on my machine just to make sure the benchmarks work.

.saturating_add(Weight::from_parts(155_577_516, 0).saturating_mul(v.into()))
.saturating_add(T::DbWeight::get().reads(9010_u64))
.saturating_add(T::DbWeight::get().reads((9_u64).saturating_mul(v.into())))
.saturating_add(T::DbWeight::get().writes(7008_u64))
Copy link
Member

@ggwpez ggwpez Nov 13, 2024

Choose a reason for hiding this comment

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

9000 READs and 7000 WRITEs per iteration is a lot. Not sure if this is expected. @Ank4n @gpestana

Copy link
Contributor

@gui1117 gui1117 Nov 13, 2024

Choose a reason for hiding this comment

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

good find. this is indeed an error: https://github.com/paritytech/polkadot-sdk/pull/6025/files#r1839635371

I didn't review the weight carefully I will do another review.

a PR is opened: #6463

Copy link
Member

@ggwpez ggwpez Nov 13, 2024

Choose a reason for hiding this comment

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

I normally use this tool when comparing weights (have to run it locally when using forks).
It has a CLI and web version. Outputs for proof-size.pdf and ref-time.pdf. Url would be this for the self-hosted version.

// Minimum execution time: 229_000 picoseconds.
Weight::from_parts(268_000, 0)
// Minimum execution time: 0_000 picoseconds.
Weight::from_parts(0, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

enable_auto_renew went from quite a lot to zero.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was reading into Authorship::Author and System::Digest, which are now both whitelisted, but that shouldn't have anything to do with this result.

Copy link
Member

Choose a reason for hiding this comment

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

Possibly one of the origins is set to NeverEnsure and triggers the Weightless path here:

.map_err(|_| BenchmarkError::Weightless)?;

/// Storage: `Broker::Workplan` (r:0 w:1)
/// Proof: `Broker::Workplan` (`max_values`: None, `max_size`: Some(1216), added: 3691, mode: `MaxEncodedLen`)
fn enable_auto_renew() -> Weight {
fn disable_auto_renew() -> Weight {
Copy link
Contributor

Choose a reason for hiding this comment

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

disable_auto_renew went from little to zero.

// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_846_000 picoseconds.
Weight::from_parts(3_058_000, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

a bit surprising that this call do 0 read and writes.

there is a call apply_slash that allows a reporter to apply a pending slash to a member account. It is quite unexpected that the operation doesn't read and write anything considering it seems possible the reporter is unrelated to the slashed account.

// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_858_000 picoseconds.
Weight::from_parts(3_010_000, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Also surprising that applying a slash doesn't read any storage.

// Minimum execution time: 759_000 picoseconds.
Weight::from_parts(819_000, 0)
// Minimum execution time: 2_719_000 picoseconds.
Weight::from_parts(2_828_000, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Also surprising that this operation doesn't read or write anything.
The caller is not related to the operation.

// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_776_000 picoseconds.
Weight::from_parts(2_987_000, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Also surprising that this operation doesn't read or write anything.
The caller is not related to the operation.

Copy link
Contributor

@serban300 serban300 left a comment

Choose a reason for hiding this comment

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

The bridge modifications look good

@georgepisaltu georgepisaltu added this pull request to the merge queue Nov 14, 2024
github-merge-queue bot pushed a commit that referenced this pull request Nov 14, 2024
…UncheckedExtrinsic` (#6418)

Follow up to #3685
Partially fixes #6403

The main PR introduced bare support for the new extension version byte
as well as extension weights and benchmarking.

This PR:
- Removes the redundant extension version byte from the signed v4
extrinsic, previously unused and defaulted to 0.
- Adds the extension version byte to the inherited implication passed to
`General` transactions.
- Whitelists the `pallet_authorship::Author`, `frame_system::Digest` and
`pallet_transaction_payment::NextFeeMultiplier` storage items as they
are read multiple times by extensions for each transaction, but are hot
in memory and currently overestimate the weight.
- Whitelists the benchmark caller for `CheckEra` and `CheckGenesis` as
the reads are performed for every transaction and overestimate the
weight.
- Updates the umbrella frame weight template to work with the system
extension changes.
- Plans on re-running the benchmarks at least for the `frame_system`
extensions.

---------

Signed-off-by: georgepisaltu <[email protected]>
Co-authored-by: command-bot <>
Co-authored-by: gui <[email protected]>
Merged via the queue into paritytech:master with commit ae4b68b Nov 14, 2024
191 of 199 checks passed
@georgepisaltu georgepisaltu deleted the second-tx-ext-fix branch November 14, 2024 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T1-FRAME This PR/Issue is related to core FRAME, the framework.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transaction weight bloated by 2.5x in the latest release
7 participants