Skip to content

Conversation

aramikm
Copy link
Collaborator

@aramikm aramikm commented Sep 18, 2025

Goal

The goal of this PR is to update the database benchmarks

Closes #2606

Discussion

  • The read values are substantially increased but it appears that the POV is still the bottle-neck for the most part for weights and not the ref time.
  • I had to update the stable weights since they were going to change regardless.
  • Here is the calculations solely based on ref time
Screenshot 2025-09-22 at 4 41 38 PM

Some considerations

  • Providers might ran out of capacity faster due to increase in weights

Checklist

  • Unit Tests updated
  • Spec version incremented?

@github-actions github-actions bot added metadata-changed Metadata has changed since the latest full release metadata-version-not-incremented Metadata has changed since the latest full release, but the version has not been incremented labels Sep 18, 2025
@github-actions github-actions bot removed metadata-changed Metadata has changed since the latest full release metadata-version-not-incremented Metadata has changed since the latest full release, but the version has not been incremented labels Sep 22, 2025
@github-actions github-actions bot added metadata-changed Metadata has changed since the latest full release metadata-version-not-incremented Metadata has changed since the latest full release, but the version has not been incremented labels Sep 22, 2025
@github-actions github-actions bot removed metadata-changed Metadata has changed since the latest full release metadata-version-not-incremented Metadata has changed since the latest full release, but the version has not been incremented labels Sep 22, 2025
@aramikm aramikm marked this pull request as ready for review September 22, 2025 23:46
@aramikm aramikm requested a review from wilwade as a code owner September 22, 2025 23:46
@aramikm aramikm changed the title updated: storage benchmarks (WIP) updated: storage benchmarks Sep 22, 2025
Copy link

codecov bot commented Sep 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions bot added the metadata-changed Metadata has changed since the latest full release label Sep 23, 2025
@JoeCap08055
Copy link
Collaborator

Also to note, it's not just the increase in MSAs that contributes to the growth in keys. Freesky is posting tons of content; right now on testnet there are over 3.4M message keys and growing daily at a significant clip. This is significant, because while the growth in new accounts and graphs may plateau at points, presumably the amount of content will continue to grow unbounded...

@github-actions github-actions bot added metadata-changed Metadata has changed since the latest full release and removed metadata-changed Metadata has changed since the latest full release labels Sep 23, 2025
Copy link
Collaborator

@shannonwells shannonwells left a comment

Choose a reason for hiding this comment

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

Can we estimate, based on the freesky usage, how comparatively fast capacity will drain based on these new weights? Might be good to have numbers like that somewhere. Not a blocking comment obviously.

@github-actions github-actions bot removed the metadata-changed Metadata has changed since the latest full release label Sep 25, 2025
});

it('should allow retiring MSA after additional keys have been deleted and tokens withdran', async function () {
it.skip('should allow retiring MSA after additional keys have been deleted and tokens withdran', async function () {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tried multiple attempts to fix this test but for it always found a way to fail in one way or another. Would appreciate if you know how to fix this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moving all of them into sudo.test.ts because if a test is using sudo key it should be inside that file so that it doesn't error in parallel mode.

@aramikm
Copy link
Collaborator Author

aramikm commented Sep 25, 2025

Can we estimate, based on the freesky usage, how comparatively fast capacity will drain based on these new weights? Might be good to have numbers like that somewhere. Not a blocking comment obviously.

Based on my calculations presented in the PR add_ipfs_message is increased around ~7x so I would assume that they will need around 7x of their current max used capacity

@github-actions github-actions bot added the metadata-changed Metadata has changed since the latest full release label Sep 25, 2025
@aramikm aramikm marked this pull request as draft September 26, 2025 20:53
@aramikm aramikm changed the title updated: storage benchmarks [DO NOT MERGE] updated: storage benchmarks Sep 26, 2025
@aramikm
Copy link
Collaborator Author

aramikm commented Sep 27, 2025

Pallet base reads

2025-09-26 20:13:26  creating SingleState txpool Limit { count: 8192, total_bytes: 20971520 }/Limit { count: 512, total_bytes: 1048576 }.
2025-09-26 21:13:22 Warmup round 1/2
2025-09-27 00:02:04 Warmup round 2/2
2025-09-27 02:25:04 Preparing keys from block 0x7abe…8bd7
2025-09-27 02:25:04 starting metrics for msa
2025-09-27 02:29:35 Reading 6346291 keys
2025-09-27 02:36:54 Pallet Time summary [ns]:
Total: 434471377632
Min: 3770, Max: 31897572
Average: 68460, Median: 58485, Stddev: 82166.91
Percentiles 99th, 95th, 75th: 242181, 87478, 65701
Value size summary:
Total: 95733143
Min: 1, Max: 138
Average: 15, Median: 8, Stddev: 15.36
Percentiles 99th, 95th, 75th: 35, 35, 35
2025-09-27 02:36:54 starting metrics for schemas
2025-09-27 02:36:54 Reading 70 keys
2025-09-27 02:36:54 Pallet Time summary [ns]:
Total: 1200539
Min: 6790, Max: 62902
Average: 17150, Median: 15230, Stddev: 7620.46
Percentiles 99th, 95th, 75th: 62902, 27710, 19871
Value size summary:
Total: 12930
Min: 2, Max: 1367
Average: 184, Median: 5, Stddev: 286.21
Percentiles 99th, 95th, 75th: 1367, 700, 414
2025-09-27 02:36:54 starting metrics for messages
2025-09-27 02:37:09 Reading 1605421 keys
2025-09-27 02:38:20 Pallet Time summary [ns]:
Total: 70052453862
Min: 2109, Max: 1809357
Average: 43634, Median: 42268, Stddev: 17860.76
Percentiles 99th, 95th, 75th: 68231, 58795, 48476
Value size summary:
Total: 81876373
Min: 2, Max: 51
Average: 50, Median: 51, Stddev: 0.05
Percentiles 99th, 95th, 75th: 51, 51, 51
2025-09-27 02:38:20 starting metrics for handles
2025-09-27 02:42:49 Reading 6013797 keys
2025-09-27 02:50:27 Pallet Time summary [ns]:
Total: 453641114292
Min: 16910, Max: 37473914
Average: 75433, Median: 55114, Stddev: 134426.98
Percentiles 99th, 95th, 75th: 867059, 83356, 61523
Value size summary:
Total: 61214021
Min: 4, Max: 34
Average: 10, Median: 8, Stddev: 6.13
Percentiles 99th, 95th, 75th: 25, 22, 15
2025-09-27 02:50:27 starting metrics for capacity
2025-09-27 02:50:27 Reading 50 keys
2025-09-27 02:50:27 Pallet Time summary [ns]:
Total: 18421944
Min: 1395, Max: 15846482
Average: 368438, Median: 13308, Stddev: 2218895.41
Percentiles 99th, 95th, 75th: 15846482, 913746, 18029
Value size summary:
Total: 1602
Min: 1, Max: 101
Average: 32, Median: 32, Stddev: 23.32
Percentiles 99th, 95th, 75th: 101, 101, 41
2025-09-27 02:50:30 Time summary [ns]:
Total: 958184568269
Min: 1395, Max: 37473914
Average: 68610, Median: 55534, Stddev: 104861.07
Percentiles 99th, 95th, 75th: 743669, 82813, 62747
Value size summary:
Total: 238838069
Min: 1, Max: 1367
Average: 17, Median: 8, Stddev: 16.69
Percentiles 99th, 95th, 75th: 51, 51, 35
2025-09-27 02:50:30 Writing weights to "/home/ubuntu/rocksdb_weights.rs"

@aramikm
Copy link
Collaborator Author

aramikm commented Sep 27, 2025

No child tree read weights

//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 48.0.0
//! DATE: 2025-09-26 (Y/M/D)
//! HOSTNAME: `ip-10-173-4-131`, CPU: `Intel(R) Xeon(R) Platinum 8488C`
//!
//! DATABASE: `RocksDb`, RUNTIME: `Frequency`
//! BLOCK-NUM: `BlockId::Number(9443452)`
//! SKIP-WRITE: `true`, SKIP-READ: `false`, WARMUPS: `2`
//! STATE-VERSION: `V1`, STATE-CACHE-SIZE: ``
//! WEIGHT-PATH: ``
//! METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0`

// Executed Command:
//   ./frequency/target/release/frequency
//   benchmark
//   storage
//   --state-version=1
//   --chain=frequency
//   --base-path=/data
//   --warmups=2
//   --skip-write

/// Storage DB weights for the `Frequency` runtime and `RocksDb`.
pub mod constants {
	use frame_support::weights::constants;
	use sp_core::parameter_types;
	use sp_weights::RuntimeDbWeight;

	parameter_types! {
		/// By default, Substrate uses `RocksDB`, so this will be the weight used throughout
		/// the runtime.
		pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight {
			/// Time to read one storage item.
			/// Calculated by multiplying the *Average* of all values with `1.0` and adding `0`.
			///
			/// Stats nanoseconds:
			///   Min, Max: 1_395, 37_473_914
			///   Average:  68_610
			///   Median:   55_534
			///   Std-Dev:  104861.07
			///
			/// Percentiles nanoseconds:
			///   99th: 743_669
			///   95th: 82_813
			///   75th: 62_747
			read: 68_610 * constants::WEIGHT_REF_TIME_PER_NANOS,

			/// Time to write one storage item.
			/// Calculated by multiplying the *Average* of all values with `1.0` and adding `0`.
			///
			/// Stats nanoseconds:
			///   Min, Max: ,
			///   Average:
			///   Median:
			///   Std-Dev:
			///
			/// Percentiles nanoseconds:
			///   99th:
			///   95th:
			///   75th:
			write: 0 * constants::WEIGHT_REF_TIME_PER_NANOS,
		};
	}

	#[cfg(test)]
	mod test_db_weights {
		use super::constants::RocksDbWeight as W;
		use sp_weights::constants;

		/// Checks that all weights exist and have sane values.
		// NOTE: If this test fails but you are sure that the generated values are fine,
		// you can delete it.
		#[test]
		fn bound() {
			// At least 1 µs.
			assert!(
				W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
				"Read weight should be at least 1 µs."
			);
			assert!(
				W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
				"Write weight should be at least 1 µs."
			);
			// At most 1 ms.
			assert!(
				W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
				"Read weight should be at most 1 ms."
			);
			assert!(
				W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
				"Write weight should be at most 1 ms."
			);
		}
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

metadata-changed Metadata has changed since the latest full release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants