Skip to content

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

t-davidbrown-msft
Copy link

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.

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.

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.
@github-actions github-actions bot added the Storage Storage Service (Queues, Blobs, Files) label Apr 29, 2025
@azure-sdk
Copy link
Collaborator

azure-sdk commented Apr 29, 2025

API Change Check

APIView identified API level changes in this PR and created the following API reviews

Azure.Storage.DataMovement

added a new parameterless constructor that initializes the instance with a default processor.
@azure-sdk
Copy link
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

Azure.Storage.DataMovement

/// <summary>
/// Gets the current throughput in bytes per second.
/// </summary>
internal virtual decimal Throughput { get; set; }
Copy link
Member

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.

Copy link
Author

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)
Copy link
Member

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?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// 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
Copy link
Member

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

David Brown added 6 commits May 8, 2025 00:12
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants