Skip to content

Conversation

roberto-bayardo
Copy link
Collaborator

@roberto-bayardo roberto-bayardo commented Aug 11, 2025

The benchmark follows the implementation of the any::Fixed init benchmark, only inserting varying sized vectors instead of fixed digests.

Because reads from the variable journal are not currently buffered, this benchmark runs slowly (3-7 seconds per iteration depending on the parameters). It will allow us to measure the impact of buffering in #1384

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR creates a new benchmark for the variable anydb that measures initialization performance with varying-sized vectors instead of fixed digests. The implementation follows the existing fixeddb benchmark pattern but uses Vec<u8> values of variable length (7-21 bytes) instead of fixed digest values.

Key changes:

  • Created a new variable_init.rs benchmark module for testing variable-sized data
  • Renamed the existing benchmark function from bench_any_init to bench_fixed_init for clarity
  • Updated the benchmark runner to include both fixed and variable benchmarks

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
storage/src/adb/benches/variable_init.rs New benchmark module implementing variable-sized vector testing
storage/src/adb/benches/fixed_init.rs Renamed benchmark function for consistency
storage/src/adb/benches/bench.rs Updated module imports and criterion_main to include both benchmarks

@commonwarexyz commonwarexyz deleted a comment from Copilot AI Aug 11, 2025
@commonwarexyz commonwarexyz deleted a comment from Copilot AI Aug 11, 2025
@commonwarexyz commonwarexyz deleted a comment from Copilot AI Aug 11, 2025
@roberto-bayardo roberto-bayardo marked this pull request as ready for review August 11, 2025 18:39
let mut rng = StdRng::seed_from_u64(42);
for i in 0u64..num_elements {
let k = hash(&i.to_be_bytes());
let v = vec![(rng.next_u32() % 255) as u8; ((rng.next_u32() % 14) + 8) as usize];
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make more sense to have the size of this be up to ~32 bytes (for a better parity check with fixed)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed values to have avg. of 32 bytes

let runner = tokio::Runner::new(cfg.clone());
for elements in [NUM_ELEMENTS, NUM_ELEMENTS * 2] {
for operations in [NUM_OPERATIONS, NUM_OPERATIONS * 2] {
info!(elements, operations, "benchmarking any init",);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: trailing ,

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

let runner = tokio::Runner::new(cfg.clone());
for elements in [NUM_ELEMENTS, NUM_ELEMENTS * 2] {
for operations in [NUM_OPERATIONS, NUM_OPERATIONS * 2] {
info!(elements, operations, "benchmarking any init",);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: benchmarking any::variable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed


/// Benchmark the initialization of a large randomly generated any db.
fn bench_variable_init(c: &mut Criterion) {
tracing_subscriber::fmt().try_init().ok();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: in other benchmarks, I don't perform any logging?

(I suppose it is preferred to do so?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added this because startup was really slow (creating the massive DB to then replay) and wanted to see it making some progress...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(This is outside the part being timed)

@patrick-ogrady patrick-ogrady merged commit 3ac52aa into main Aug 11, 2025
37 checks passed
@patrick-ogrady patrick-ogrady deleted the variable-any-bench branch August 11, 2025 22:27
Copy link

codecov bot commented Aug 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.34%. Comparing base (5ea06c0) to head (88c990b).
⚠️ Report is 1 commits behind head on main.

@@           Coverage Diff           @@
##             main    #1388   +/-   ##
=======================================
  Coverage   91.34%   91.34%           
=======================================
  Files         265      265           
  Lines       66726    66726           
=======================================
+ Hits        60950    60952    +2     
+ Misses       5776     5774    -2     

see 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5ea06c0...88c990b. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants