Skip to content

fix: measure individual call durations in sequential phase of concurrency decorator#2140

Merged
aseembits93 merged 2 commits intomainfrom
cf-fix-concurrency-measurement
May 7, 2026
Merged

fix: measure individual call durations in sequential phase of concurrency decorator#2140
aseembits93 merged 2 commits intomainfrom
cf-fix-concurrency-measurement

Conversation

@KRRT7
Copy link
Copy Markdown
Collaborator

@KRRT7 KRRT7 commented May 7, 2026

Summary

  • Fix asymmetric timing in codeflash_concurrency_async that inflated sequential/concurrent ratios
  • The old approach timed the entire sequential loop including event loop scheduling overhead between iterations, while asyncio.gather has a fast-path with minimal inter-task overhead
  • Now sums per-iteration durations, excluding event loop scheduling overhead from the measurement
  • Applied to both codeflash_wrap_decorator.py and the inlined copy in instrument_existing_tests.py
  • Added mypy overrides for these runtime helper files (pre-existing strict-mode violations)

Test plan

  • tests/test_async_concurrency_decorator.py — all 9 tests pass
  • test_concurrency_decorator_blocking_function no longer flaky (ratio stays < 2.0 reliably)

…ency decorator

The old approach timed the entire sequential loop (including event loop
scheduling overhead between iterations), while the concurrent phase
used asyncio.gather which has a fast-path with minimal inter-task
overhead. This asymmetry inflated the sequential/concurrent ratio,
causing false positives in concurrency gain detection.

Sum per-iteration durations instead, excluding event loop scheduling
overhead from the measurement.
@KRRT7 KRRT7 force-pushed the cf-fix-concurrency-measurement branch from 51fb98a to 9399561 Compare May 7, 2026 17:40
@aseembits93 aseembits93 enabled auto-merge May 7, 2026 22:20
@aseembits93 aseembits93 merged commit f7db112 into main May 7, 2026
34 of 35 checks passed
@aseembits93 aseembits93 deleted the cf-fix-concurrency-measurement branch May 7, 2026 22:26
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