Skip to content

Conversation

@not-matthias
Copy link
Member

No description provided.

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 20, 2025

CodSpeed Performance Report

Merging #152 will degrade performances by 10%

Comparing cod-1711-codspeed-rust-add-analysis-mode-support (435a805) with main (9181bce)

Summary

⚡ 31 improvements
❌ 2 regressions
✅ 333 untouched
🆕 2 new

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Mode Benchmark BASE HEAD Change
WallTime large_drop 204 µs 170.9 µs +19.35%
WallTime large_setup 20 ns 11 ns +81.82%
WallTime small_setup 2 ns 1 ns ×2
WallTime iter_with_setup 36 ns 39 ns -7.69%
WallTime iter_batched_per_iteration 36 ns 40 ns -10%
WallTime init_array[1000] 2.1 µs 2 µs +7.34%
🆕 Simulation allocate N/A < 1 ns N/A
🆕 WallTime allocate N/A 1 s N/A
WallTime slice_into_vec_with_bytes 59 ns 55 ns +7.27%
WallTime string_copy_with_bytes_counter 61 ns 58 ns +5.17%
WallTime print_env_hello 5.2 µs 2 µs ×2.6
WallTime recursive[5] 34 ns 33 ns +3.03%
WallTime recursive_memoized[BTreeMap<u64, u64>, 20] 2.3 µs 1.8 µs +23.7%
WallTime recursive_memoized[BTreeMap<u64, u64>, 30] 3.4 µs 2.9 µs +15.11%
WallTime recursive_memoized[HashMap<u64, u64>, 0] 16 ns 15 ns +6.67%
WallTime recursive_memoized[HashMap<u64, u64>, 10] 1.8 µs 1.5 µs +16.29%
WallTime recursive_memoized[HashMap<u64, u64>, 20] 3.8 µs 3.3 µs +15.58%
WallTime recursive_memoized[HashMap<u64, u64>, 30] 6.5 µs 5.7 µs +13.69%
WallTime generate_combinations[5] 1,181 ns 794 ns +48.74%
WallTime generate_combinations[6] 1.8 µs 1.4 µs +30.46%
... ... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

@not-matthias not-matthias changed the title chore: wip [skip ci] feat: add support for analysis mode Nov 20, 2025
@not-matthias not-matthias force-pushed the cod-1711-codspeed-rust-add-analysis-mode-support branch from 8638bef to 5bab4b1 Compare November 21, 2025 15:26
@not-matthias not-matthias force-pushed the cod-1711-codspeed-rust-add-analysis-mode-support branch from 5bab4b1 to f2e74d7 Compare November 21, 2025 15:33
@not-matthias not-matthias requested a review from Copilot November 21, 2025 15:33
Copy link

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 adds support for a new "analysis" measurement mode to the CodSpeed benchmarking framework. The analysis mode enables instrumentation similar to simulation mode and integrates with instrument hooks for tracking benchmark execution.

Key changes:

  • Introduced a new Analysis variant to the MeasurementMode enum
  • Integrated InstrumentHooks for tracking benchmark lifecycle events
  • Removed the deprecated is_instrumented() function and RunningOnValgrind enum variant

Reviewed changes

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

Show a summary per file
File Description
crates/divan_compat/examples/benches/alloc.rs New benchmark file for testing memory allocation scenarios
crates/divan_compat/examples/Cargo.toml Added the new alloc benchmark to the build configuration
crates/codspeed/src/request/mod.rs Removed unused RunningOnValgrind client request variant
crates/codspeed/src/measurement.rs Removed deprecated is_instrumented() function
crates/codspeed/src/codspeed.rs Integrated InstrumentHooks for benchmark lifecycle tracking
crates/cargo-codspeed/src/measurement_mode.rs Added Analysis variant to measurement modes
crates/cargo-codspeed/src/build.rs Extended codspeed cfg flag to apply to analysis mode
.github/workflows/ci.yml Added CI workflow for testing memory analysis integration
crates/codspeed/instrument-hooks Updated submodule commit reference

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@not-matthias not-matthias marked this pull request as ready for review November 24, 2025 09:52
@not-matthias not-matthias force-pushed the cod-1711-codspeed-rust-add-analysis-mode-support branch from f2e74d7 to 435a805 Compare November 24, 2025 10:26
Copy link
Contributor

@GuillaumeLagrange GuillaumeLagrange left a comment

Choose a reason for hiding this comment

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

olgtm

# runner-branch: cod-1670-runner-profile-memory-of-command
# run: cargo codspeed run
# mode: memory
# token: ${{ secrets.CODSPEED_TOKEN }}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be able to remove secrets now with OIDC

token: ${{ secrets.CODSPEED_TOKEN }}


compat-integration-test-memory:
Copy link
Contributor

Choose a reason for hiding this comment

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

We can have multi-dimensional matrices, as well as some dimensions precising two things

We could combine everything in one big matrix, one dimension being the library we are testing, the other one the mode and the runner it runs on like here https://github.com/CodSpeedHQ/codspeed-cpp/blob/f23b68b27f8543f88f95ff0bdc46785733dee061/.github/workflows/ci.yml#L57-L62

WDYT ?

We could conditionnallly remove the .cargo/config.toml, as well as conditionnally skip the uploading part for memory (for now)

impl CodSpeed {
pub fn new() -> Self {
let is_instrumented = measurement::is_instrumented();
let ih = InstrumentHooks::instance();
Copy link
Contributor

Choose a reason for hiding this comment

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

not a fan of abbreviations overall, but here it does not bring that much, how about hooks ? or hooks_instance or instrument_hooks_instance ?

pub fn start_benchmark(&mut self, name: &str) {
self.current_benchmark = CString::new(name).expect("CString::new failed");
let _ = InstrumentHooks::instance().start_benchmark();
measurement::start();
Copy link
Contributor

Choose a reason for hiding this comment

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

will that not confuse valgrind to keep both this and the start_benchmark call when built in simulation ?

Copy link
Contributor

Choose a reason for hiding this comment

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

It might be the time to say goodbye to the inline assembly and make a major out of this


#[inline(always)]
pub fn end_benchmark(&mut self) {
measurement::stop(&self.current_benchmark);
Copy link
Contributor

Choose a reason for hiding this comment

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

same remark here

"-Cstrip=none".to_owned(),
];

// Add the codspeed cfg flag if simulation mode is enabled
Copy link
Contributor

Choose a reason for hiding this comment

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

Update comment, or create a function that takes measurement_mode and outputs a bool, named should_build_benchmark_target_to_run_only_once or something like this, to convey the intention

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.

3 participants