Skip to content

Fix storage stats to report wall-clock duration instead of sum - #1734

Open
sachinsharma3191 wants to merge 6 commits into
temporalio:mainfrom
sachinsharma3191:fix/1562-wall-clock-storage-duration
Open

Fix storage stats to report wall-clock duration instead of sum#1734
sachinsharma3191 wants to merge 6 commits into
temporalio:mainfrom
sachinsharma3191:fix/1562-wall-clock-storage-duration

Conversation

@sachinsharma3191

Copy link
Copy Markdown

Summary

  • Moves duration measurement from per-driver-invocation accumulation into StorageOperationMetrics.track(), which now captures a single wall-clock bracket around the entire concurrent operation
  • Removes duration parameter from record_batch() — duration is no longer accumulated per-call
  • Removes per-call start_time / duration computation from _record_metrics() and all call sites (_store_payload, _store_payload_sequence, _retrieve_payload, _retrieve_payload_sequence)

Before: With 3 concurrent drivers each taking ~100ms, total_duration reported ~300ms (sum of individual durations).

After: total_duration reports ~100ms (wall-clock time of the track() block that brackets all concurrent operations).

This mirrors the approach taken in the Go SDK fix (temporalio/sdk-go#2388).

Closes #1562

Test plan

  • TestStorageOperationMetrics.test_track_records_wall_clock_duration — verifies track() records wall-clock time
  • TestStorageOperationMetrics.test_concurrent_operations_report_wall_clock — 3 concurrent 50ms sleeps report ~50ms wall-clock, not ~150ms sum
  • All existing test_extstore.py tests unaffected (none reference record_batch or total_duration directly)
  • No changes needed in bridge/worker.py or worker/_workflow.pytrack() already wraps the correct span and total_duration attribute name/type preserved

Move duration measurement from per-driver-invocation accumulation into
the StorageOperationMetrics.track() context manager, which now captures
a single wall-clock bracket around the entire concurrent operation.

Previously, each concurrent driver call computed its own elapsed time
and summed it into total_duration via record_batch(). With N concurrent
drivers each taking ~100ms, this reported ~N*100ms instead of ~100ms.

Fixes temporalio#1562
@sachinsharma3191
sachinsharma3191 requested a review from a team as a code owner August 10, 2026 00:33
@CLAassistant

CLAassistant commented Aug 10, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Comment thread tests/test_extstore.py Outdated
Comment thread tests/test_extstore.py Outdated
Comment thread tests/test_extstore.py Outdated
Comment thread tests/test_extstore.py Outdated
- Remove all timing assertions from sync test to avoid OS/version flakiness
- Replace hardcoded duration bounds in async test with elapsed time comparison
- Remove comment about previous behavior
@sachinsharma3191

Copy link
Copy Markdown
Author

Thanks for the thorough review! Addressed all feedback:

  1. Removed all timing assertions from the sync test (test_track_records_wall_clock_duration) — dropped both the > timedelta(0) and < timedelta(seconds=1) checks to avoid OS/Python version flakiness.
  2. Removed the comment about previous behavior.
  3. Replaced hardcoded bounds in the async test (test_concurrent_operations_report_wall_clock) — instead of asserting against fixed millisecond thresholds, the test now tracks elapsed wall-clock time around metrics.track() and asserts total_duration <= elapsed.

Comment thread tests/test_extstore.py Outdated
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.

[Bug] External storage transfer stats reports summation of durations instead of wall-clock duration

3 participants