Skip to content

Conversation

@ReubenBond
Copy link
Member

@ReubenBond ReubenBond commented Mar 16, 2025

This PR improves the implementation of IAsyncEnumerable<T> support.

  1. Canceled tasks are propagated to callers.
  2. All asynchronous operations (MoveNextAsync, cancellation, disposal) have bounded times, based on MessagingOptions.ResponseTimeout.
  3. Cleanup is reimplemented based on a mark-and-sweep algorithm which won't clean up enumerators which are actively in-use.
  4. Test coverage has been improved.
Microsoft Reviewers: Open in CodeFlow

@ReubenBond ReubenBond requested a review from Copilot March 17, 2025 20:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the IAsyncEnumerable support to propagate cancellation, bound asynchronous operation times, and improve enumerator cleanup via a mark‐and‐sweep algorithm while also adding new tests.

  • Introduces new tests to cover cancellation, slow consumer, and eviction scenarios
  • Refactors AsyncEnumerableGrainExtension to use a mark‐and‐sweep cleanup and bounds on asynchronous operations
  • Updates MessagingOptions and AsyncEnumerableRequest to support new timeout configurations

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/DefaultCluster.Tests/AsyncEnumerableGrainCallTests.cs Added new test cases for cancellation and slow consumer scenarios
src/Orleans.Core/Runtime/AsyncEnumerableGrainExtension.cs Refactored internals for cancellation propagation and cleanup, including changes to task handling and flag management
test/Grains/TestInternalGrains/ObservableGrain.cs Minor reordering in error handling for GetValuesWithError
src/Orleans.Core.Abstractions/Runtime/AsyncEnumerableRequest.cs Updates to incorporate WaitAsync and cancellation handling
src/Orleans.Core/Configuration/Options/MessagingOptions.cs Added a new internal property to expose the configured response timeout
test/Grains/TestGrainInterfaces/IObservableGrain.cs Minor namespace whitespace update
Comments suppressed due to low confidence (1)

src/Orleans.Core/Runtime/AsyncEnumerableGrainExtension.cs:22

  • The initialization of '_enumerators' uses '[]', but a new Dictionary should be instantiated using 'new Dictionary<Guid, EnumeratorState>()' to ensure proper behavior.
private readonly Dictionary<Guid, EnumeratorState> _enumerators = [];

@ReubenBond ReubenBond merged commit 4960397 into dotnet:main Mar 18, 2025
25 checks passed
@ReubenBond ReubenBond deleted the iasyncenumerable/fixes-1 branch March 18, 2025 17:18
@github-actions github-actions bot locked and limited conversation to collaborators Apr 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants