Skip to content

Add codec benches#2058

Merged
Shourya742 merged 1 commit intostratum-mining:mainfrom
Shourya742:2026-01-26-add-codec-benches
Apr 23, 2026
Merged

Add codec benches#2058
Shourya742 merged 1 commit intostratum-mining:mainfrom
Shourya742:2026-01-26-add-codec-benches

Conversation

@Shourya742
Copy link
Copy Markdown
Collaborator

@Shourya742 Shourya742 commented Jan 26, 2026

closes: #2060

@Shourya742 Shourya742 force-pushed the 2026-01-26-add-codec-benches branch 2 times, most recently from ae5e79e to 043beed Compare March 12, 2026 08:00
@Shourya742 Shourya742 marked this pull request as ready for review March 12, 2026 08:00
@Shourya742 Shourya742 force-pushed the 2026-01-26-add-codec-benches branch 2 times, most recently from a45c2a6 to a2791e9 Compare March 12, 2026 08:02
@Alkamal01
Copy link
Copy Markdown

Hey, just reviewing the benchmarks so far, looks great!
One thing I noticed: in bench_frame_serialize_and_create, a Vec is allocated inside the iter() loop. This might include allocation overhead in the timing results.
Would it make sense to pre-allocate the buffer outside the loop or use black_box to isolate serialization performance?
Happy to help with a small PR if that would be useful.

Comment thread sv2/codec-sv2/Cargo.toml Outdated
Comment thread sv2/codec-sv2/BENCHES.md Outdated
Comment thread sv2/codec-sv2/benches/decoder.rs Outdated
Comment thread sv2/codec-sv2/BENCHES.md Outdated
Comment thread sv2/codec-sv2/benches/noise_roundtrip.rs
@Shourya742 Shourya742 force-pushed the 2026-01-26-add-codec-benches branch 2 times, most recently from 8769562 to f562111 Compare March 24, 2026 08:02
@Shourya742
Copy link
Copy Markdown
Collaborator Author

Oopsie, I didn't pushed my local head.

@Shourya742 Shourya742 force-pushed the 2026-01-26-add-codec-benches branch from f562111 to f16945a Compare March 27, 2026 08:31
Comment thread sv2/codec-sv2/benches/serialization.rs Outdated
Comment thread sv2/codec-sv2/benches/serialization.rs
let mut total = Duration::ZERO;
for _ in 0..iters {
let mut enc = Encoder::<TestMsg>::new();
let held: Vec<_> = (0u8..8)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

you are getting this (0u8..8) from the POOL_CAPACITY in buffer_sv2?

pub const POOL_CAPACITY: usize = 8;

If yes, I would encourage to get this value from the crate itself. If we ever change this capacity, the bench will become silently outdated. Also apply this in the other places that we need

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Its not exposed publicly to downstream crates. Opened an issue: #2130

Comment thread sv2/codec-sv2/benches/pool_lifecycle.rs
drop(held);
}

eprintln!(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this seems unusual. was it intentional to add here? or is just a leftover?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I agree. I just couldn’t come up with a better way to observe the allocations and deallocations during these operations. I might remove them later if I find a cleaner approach.

@Shourya742 Shourya742 force-pushed the 2026-01-26-add-codec-benches branch from f16945a to b6cebab Compare April 8, 2026 09:50
Comment thread sv2/codec-sv2/BENCHES.md Outdated
Comment thread sv2/codec-sv2/BENCHES.md Outdated
@Shourya742 Shourya742 force-pushed the 2026-01-26-add-codec-benches branch from b6cebab to 5901a68 Compare April 22, 2026 08:25
Copy link
Copy Markdown
Collaborator

@lucasbalieiro lucasbalieiro left a comment

Choose a reason for hiding this comment

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

tACK 5901a68

The two open remaining points are non-blockers for me: #2058 (comment) and #2058 (comment)

@Shourya742 Shourya742 force-pushed the 2026-01-26-add-codec-benches branch from 5901a68 to e5408b3 Compare April 23, 2026 04:54
@Shourya742 Shourya742 merged commit af4348e into stratum-mining:main Apr 23, 2026
14 checks passed
@Shourya742 Shourya742 deleted the 2026-01-26-add-codec-benches branch April 23, 2026 05:29
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.

Benchmark codec-sv2

3 participants