-
Notifications
You must be signed in to change notification settings - Fork 5k
Add ThroughputMonitor for enhanced data transfer tracking #49720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add ThroughputMonitor for enhanced data transfer tracking #49720
Conversation
Introduces the ThroughputMonitor class to monitor and calculate throughput during data transfer operations. Updates - JobBuilder, - TransferJobInternal, - TransferManager, and - TransferProgressTracker to integrate throughput monitoring. Adds unit tests for ThroughputMonitor functionality and updates existing tests to mock and verify its integration in transfer processes.
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
added a new parameterless constructor that initializes the instance with a default processor.
API change check APIView has identified API level changes in this PR and created following API reviews. |
/// <summary> | ||
/// Gets the current throughput in bytes per second. | ||
/// </summary> | ||
internal virtual decimal Throughput { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably stick with float
for decimal types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jalauzon-msft oops. I thought we said double, but I can change them to float.
if (_totalBytesTransferred == 0) | ||
return Task.CompletedTask; | ||
|
||
if (!_isStopwatchRunning) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way we can get rid of stopwatch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jalauzon-msft done.
/// Monitors the throughput of data transfer operations by tracking the total bytes transferred | ||
/// and calculating the throughput in bytes per second. | ||
/// </summary> | ||
internal class ThroughputMonitor : IAsyncDisposable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be an IDiposable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jalauzon-msft done.
sdk/storage/Azure.Storage.DataMovement/src/ConcurrencyTuner/ThroughputMonitor.cs
Show resolved
Hide resolved
sdk/storage/Azure.Storage.DataMovement/src/ConcurrencyTuner/ThroughputMonitor.cs
Outdated
Show resolved
Hide resolved
Significantly modify the TransferManager class to replace the previous TransferOptions property with a parameterized approach using transferOptions in various methods. Update ResumeAllTransfersAsync and ResumeTransferAsync to utilize the transferOptions parameter, ensuring robustness by initializing transferOptions when null. Enhance TransferProgressTracker to guarantee proper initialization of ThroughputMonitor and improve progress tracking consistency.
The `TransferOptions` property and its associated private field `_transferOptions` have been removed from the `TransferManager` class. This change eliminates the property implementation that managed the assignment and validation of transfer options, including the handling of `ProgressHandlerOptions`. This simplification may reflect a shift in how transfer options are managed or a refactoring of the codebase.
- Modify `AvgThroughput` to return `double.MaxValue` for zero elapsed time with bytes transferred. - Update `ProcessBytesTransferredAsync` to handle zero elapsed time correctly. - Change `DisposeAsync` to a synchronous `Dispose` method. - Refactor and rename tests in `ThroughputMonitorTests.cs` for clarity. - Add new tests for `AvgThroughput` under various conditions. - Enhance tests to verify internal state using reflection. - Clarify cancellation token handling in `QueueBytesTransferredAsync`.
Modified the `ThroughputInMb_And_AvgThroughputInMb_CalculatedCorrectly` test in `ThroughputMonitorTests.cs` to use a tolerance of `0.05` Mbps for assertions. This change enhances the flexibility of comparisons for calculated throughput values, allowing for minor variations in results.
Updated the ThroughputMonitor class to change properties and calculations from double to float for improved performance and reduced memory usage. Changed the access modifier of QueueBytesTransferredAsync from public to internal. Added a SetStartTime method for direct initialization of _startTime. Updated tests in ThroughputMonitorTests to reflect these changes, including using float comparisons, renaming tests for clarity, and adding assertions for throughput calculations.
Introduces the ThroughputMonitor class to monitor and calculate throughput during data transfer operations.
Updates
Adds unit tests for ThroughputMonitor functionality and updates existing tests to mock and verify its integration in transfer processes.
Contributing to the Azure SDK
Please see our CONTRIBUTING.md if you are not familiar with contributing to this repository or have questions.
For specific information about pull request etiquette and best practices, see this section.