Skip to content

Conversation

@serban300
Copy link
Contributor

This PR Improves the weight metering for the enqueue_xcmp_message() method, by accounting for cached reads/writes and for the size of the enqueued messages

@serban300 serban300 added R0-no-crate-publish-required The change does not require any crates to be re-published. T6-XCM This PR/Issue is related to XCM. labels Mar 19, 2025
@serban300 serban300 self-assigned this Mar 19, 2025
@serban300 serban300 force-pushed the xcmp-weight-metering branch from 72c3dee to 3100f6e Compare March 19, 2025 07:13
@serban300 serban300 force-pushed the xcmp-weight-metering branch from ec8018e to e2dc043 Compare March 19, 2025 09:26
@serban300 serban300 force-pushed the xcmp-weight-metering branch from e2dc043 to 4b7b77d Compare March 19, 2025 09:27
@paritytech paritytech deleted a comment from github-actions bot Mar 19, 2025
@paritytech paritytech deleted a comment from github-actions bot Mar 19, 2025
@serban300
Copy link
Contributor Author

/cmd bench --pallet cumulus_pallet_xcmp_queue

@github-actions
Copy link
Contributor

Command "bench --pallet cumulus_pallet_xcmp_queue" has started 🚀 See logs here

@github-actions
Copy link
Contributor

Command "bench --pallet cumulus_pallet_xcmp_queue" has failed ❌! See logs here

Details

Command output:

✅ Successful benchmarks of runtimes/pallets:
-- asset-hub-westend: ['cumulus_pallet_xcmp_queue']
-- asset-hub-rococo: ['cumulus_pallet_xcmp_queue']
-- bridge-hub-rococo: ['cumulus_pallet_xcmp_queue']
-- bridge-hub-westend: ['cumulus_pallet_xcmp_queue']
-- collectives-westend: ['cumulus_pallet_xcmp_queue']
-- coretime-rococo: ['cumulus_pallet_xcmp_queue']
-- coretime-westend: ['cumulus_pallet_xcmp_queue']
-- people-rococo: ['cumulus_pallet_xcmp_queue']
-- people-westend: ['cumulus_pallet_xcmp_queue']

@serban300 serban300 requested a review from ggwpez March 19, 2025 12:22
- replace `do_enqueue_message()` with `do_enqueue_messages()` which
  batches by default. This improves the performance of
 `enqueue_messages()` while keeing the same performance for
 `enqueue_message()`
- make `message_queue::do_enqueue_message()` logic easier to follow
@serban300 serban300 requested a review from a team as a code owner March 20, 2025 13:51
@serban300 serban300 added this pull request to the merge queue Mar 21, 2025
@serban300
Copy link
Contributor Author

Merging the PR since it has the required approves. I will get back with a follow-up PR with batching and accuracy improvements soon

Merged via the queue into paritytech:master with commit 855c47b Mar 21, 2025
254 of 260 checks passed
@serban300 serban300 deleted the xcmp-weight-metering branch March 21, 2025 12:40
github-merge-queue bot pushed a commit that referenced this pull request Apr 23, 2025
This is a follow-up for
#7963

#7963 introduced some
[performance improvements for the message_queue enqueuing
logic](ae657d6).
This PR leverages those improvements by implementing batching in the
XCMP queue pallet.

Also the PR increases the weight metering accuracy for the enqueuing
logic.

The performance difference can be seen in [this
commit](1d6c426):

```
	fn enqueue_1000_small_xcmp_messages() -> Weight {
		// Proof Size summary in bytes:
		//  Measured:  `151`
		//  Estimated: `5487`
		// Minimum execution time: 134_166_000 picoseconds.
		Weight::from_parts(138_915_000, 5487)
			.saturating_add(T::DbWeight::get().reads(4_u64))
			.saturating_add(T::DbWeight::get().writes(3_u64))
	}

	fn enqueue_1000_small_xcmp_messages_individually() -> Weight {
		// Proof Size summary in bytes:
		//  Measured:  `151`
		//  Estimated: `5487`
		// Minimum execution time: 10_181_142_000 picoseconds.
		Weight::from_parts(10_200_139_000, 5487)
			.saturating_add(T::DbWeight::get().reads(4_u64))
			.saturating_add(T::DbWeight::get().writes(3_u64))
	}
``` 

For 1000 messages of 3 bytes each it takes `134us` to enqueue them using
batching and `10181us` to enqueue them individually. This is a ~75x
improvement.

---------

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Oliver Tale-Yazdi <[email protected]>
ordian added a commit that referenced this pull request Apr 28, 2025
* master: (26 commits)
  Snowbridge V2 (#7402)
  [AHM] Revert multi-block election, slashing and staking client pallets (#7939)
  docs: update local ci execution instruction (#8003)
  Upgrade deps to eliminate ancient dependencies (#7999)
  Removed `pallet:getter` from XCM pallets (#7916)
  Add digest processor xcm emulator (#7915)
  Fix: [Referenda Tracks] Resolve representation issues that are breaking PJS apps (#7671)
  Improve XCMP weight metering (#7963)
  bump version of zombienet-sdk (#7964)
  rpc-v2/archive: Rename archive call method result to value (#7885)
  Bump parachains runtime api to 13 (#7981)
  `bp-runtime`: make macro expansion not rely on `sp-std` in scope. (#7978)
  [CI/CD] Refactor backports flow so that it can determine automatically where to do a backport based on labels (#7976)
  Treasury: update expire date on payout (#7958) (#7959)
  `fatxpool`: report_invalid: do not ban Future/Stale txs from re-entering the view (#7777)
  Fix XCM Barrier Rejection Handling to Return Incomplete with Weight (#7843)
  Bump openssl from 0.10.64 to 0.10.70 (#7442)
  runtime-api: remove redundant version checks (#7610)
  Upgrade link-checker cache to v4 (#7874)
  Updating readmes (#7950)
  ...
castillax pushed a commit that referenced this pull request May 12, 2025
This is a follow-up for
#7963

#7963 introduced some
[performance improvements for the message_queue enqueuing
logic](ae657d6).
This PR leverages those improvements by implementing batching in the
XCMP queue pallet.

Also the PR increases the weight metering accuracy for the enqueuing
logic.

The performance difference can be seen in [this
commit](1d6c426):

```
	fn enqueue_1000_small_xcmp_messages() -> Weight {
		// Proof Size summary in bytes:
		//  Measured:  `151`
		//  Estimated: `5487`
		// Minimum execution time: 134_166_000 picoseconds.
		Weight::from_parts(138_915_000, 5487)
			.saturating_add(T::DbWeight::get().reads(4_u64))
			.saturating_add(T::DbWeight::get().writes(3_u64))
	}

	fn enqueue_1000_small_xcmp_messages_individually() -> Weight {
		// Proof Size summary in bytes:
		//  Measured:  `151`
		//  Estimated: `5487`
		// Minimum execution time: 10_181_142_000 picoseconds.
		Weight::from_parts(10_200_139_000, 5487)
			.saturating_add(T::DbWeight::get().reads(4_u64))
			.saturating_add(T::DbWeight::get().writes(3_u64))
	}
``` 

For 1000 messages of 3 bytes each it takes `134us` to enqueue them using
batching and `10181us` to enqueue them individually. This is a ~75x
improvement.

---------

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Oliver Tale-Yazdi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

R0-no-crate-publish-required The change does not require any crates to be re-published. T6-XCM This PR/Issue is related to XCM.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants