-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Event Hubs Client] AmqpConsumer Enhancement #19966
Conversation
/azp run net - eventhub - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
).ConfigureAwait(false); | ||
|
||
cancellationToken.ThrowIfCancellationRequested<TaskCanceledException>(); | ||
|
||
// If event messages were received, then package them for consumption and | ||
// return them. | ||
|
||
if ((messagesReceived) && (amqpMessages != null)) | ||
foreach (AmqpMessage message in messagesReceived) |
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.
I was just curious about the perf impacts of removing the conditional check before doing the foreach
on an empty enumerable and it's quite a bit slower (though very fast in absolute time)
| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated |
|----------------------- |---------:|----------:|----------:|------:|--------:|------:|------:|------:|----------:|
| ConditionalEnumeration | 1.132 ns | 0.0147 ns | 0.0137 ns | 1.00 | 0.00 | - | - | - | - |
| DoEnumeration | 5.490 ns | 0.0459 ns | 0.0429 ns | 4.85 | 0.08 | - | - | - | - |
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.
Interesting.
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.
I tweaked to return null
when nothing was received and added a check to bail out early if we have none.
The focus of these changes is to apply some of the Service Bus learnings to the `AmqpConsumer` for better efficiency and fewer allocations due to the closure.
7d27886
to
e22387f
Compare
/check-enforcer override |
Summary
The focus of these changes is to apply some of the Service Bus learnings to the
AmqpConsumer
for better efficiency and fewer allocations due to the closure.Last Upstream Rebase
Tuesday, March 30, 5pm (EST)
References and Related