Skip to content

Conversation

@not-matthias
Copy link
Member

@not-matthias not-matthias commented Nov 28, 2025

Rough outline of what internally happens and why we didn't emit markers:

Working case (RunParallel/Run/b.N):
runN: StartTimer() → b.startTimestamp = X
User: StopTimer() → (timer off, but we don't care about this pair)
User: StartTimer() → b.startTimestamp = Y
RunParallel executes
User: StopTimer() → endTimestamp = Z, appends (Y, Z) to arrays ✓
runN: StopTimer() → timer already off, does nothing

Broken case (b.Loop()):
runN: StartTimer() → b.startTimestamp = X
Loop: StopTimerWithoutMarker() → timer off, NO timestamp captured ✗
Loop body executes
Loop: StartTimerWithoutMarker() → timer on, NO new startTimestamp ✗
runN: StopTimer() → timerOn is false (from Loop), does nothing ✗
Result: No timestamps ever added to arrays!

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 fixes a bug where benchmarks using b.Loop() were not emitting performance markers, preventing proper performance profiling. The issue occurred because b.Loop() uses StopTimerWithoutMarker() internally, leaving the timer off when runN() attempts to call StopTimer(), which then skips marker emission.

Key Changes

  • Extracted marker emission logic into a new AddBenchmarkMarkers() function to enable reuse
  • Added explicit marker emission in loopSlowPath() when the benchmark loop completes
  • Updated the patch file to include these changes in the fork's build process

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
testing/testing/codspeed.go Added new AddBenchmarkMarkers() helper function to encapsulate the logic for adding benchmark start/stop timestamps with validation
testing/testing/benchmark.go Refactored StopTimer() to use AddBenchmarkMarkers() and added explicit marker emission in loopSlowPath() to fix missing markers for b.Loop() benchmarks
testing/patches/benchmark_benchmarkers_bloop.patch Added patch file containing the benchmark.go changes to be applied during the fork build process
testing/fork.sh Updated fork script to apply the new patch file

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

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 28, 2025

CodSpeed Performance Report

Merging #42 will improve performances by ×2.3

Comparing cod-1760-investigate-missing-flamegraph-for-opentelemetry (3ba284c) with main (a6c2549)

Summary

⚡ 2 improvements
✅ 46 untouched

Benchmarks breakdown

Benchmark BASE HEAD Change
bench_collect_results[10000000, 5] 2.8 s 2 s +39.9%
bench_go_runner 59.6 s 26.4 s ×2.3

@not-matthias not-matthias merged commit 3ba284c into main Nov 28, 2025
22 checks passed
@not-matthias not-matthias deleted the cod-1760-investigate-missing-flamegraph-for-opentelemetry branch November 28, 2025 15:16
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