Fix storage stats to report wall-clock duration instead of sum - #1734
Open
sachinsharma3191 wants to merge 6 commits into
Open
Fix storage stats to report wall-clock duration instead of sum#1734sachinsharma3191 wants to merge 6 commits into
sachinsharma3191 wants to merge 6 commits into
Conversation
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
|
|
jmaeagle99
reviewed
Aug 10, 2026
- 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
Author
|
Thanks for the thorough review! Addressed all feedback:
|
jmaeagle99
reviewed
Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
StorageOperationMetrics.track(), which now captures a single wall-clock bracket around the entire concurrent operationdurationparameter fromrecord_batch()— duration is no longer accumulated per-callstart_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_durationreported ~300ms (sum of individual durations).After:
total_durationreports ~100ms (wall-clock time of thetrack()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— verifiestrack()records wall-clock timeTestStorageOperationMetrics.test_concurrent_operations_report_wall_clock— 3 concurrent 50ms sleeps report ~50ms wall-clock, not ~150ms sumtest_extstore.pytests unaffected (none referencerecord_batchortotal_durationdirectly)bridge/worker.pyorworker/_workflow.py—track()already wraps the correct span andtotal_durationattribute name/type preserved