-
Notifications
You must be signed in to change notification settings - Fork 494
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
Internal Query: Fixes ToList work #2060
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,18 +83,26 @@ public async ValueTask<bool> MoveNextAsync(ITrace trace) | |
else | ||
{ | ||
// left most and any non null continuations | ||
List<FeedRangeState<QueryState>> feedRangeStates = crossPartitionState | ||
IOrderedEnumerable<FeedRangeState<QueryState>> feedRangeStates = crossPartitionState | ||
.Value | ||
.ToArray() | ||
.OrderBy(tuple => (FeedRangeEpk)tuple.FeedRange, EpkRangeComparer.Singleton) | ||
.ToList(); | ||
.OrderBy(tuple => ((FeedRangeEpk)tuple.FeedRange).Range.Min); | ||
|
||
List<ParallelContinuationToken> activeParallelContinuationTokens = new List<ParallelContinuationToken>(); | ||
for (int i = 0; i < feedRangeStates.Count; i++) | ||
{ | ||
FeedRangeState<QueryState> firstState = feedRangeStates.First(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the internal from the PR title. This can impact external customers. Query: Fixes high CPU caused by LINQ orderBy logic There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't even know if it fixes anything. No reproduce means no validation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't make a change unless there is a reason. How do you know this will not make it worse? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's removing instructions from the compare operator thus faster. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no benchmark so how do you know it is faster? |
||
ParallelContinuationToken firstParallelContinuationToken = new ParallelContinuationToken( | ||
token: firstState.State != null ? ((CosmosString)firstState.State.Value).Value : null, | ||
range: ((FeedRangeEpk)firstState.FeedRange).Range); | ||
|
||
activeParallelContinuationTokens.Add(firstParallelContinuationToken); | ||
} | ||
|
||
foreach (FeedRangeState<QueryState> feedRangeState in feedRangeStates.Skip(1)) | ||
{ | ||
this.cancellationToken.ThrowIfCancellationRequested(); | ||
|
||
FeedRangeState<QueryState> feedRangeState = feedRangeStates[i]; | ||
if ((i == 0) || (feedRangeState.State != null)) | ||
if (feedRangeState.State != null) | ||
{ | ||
ParallelContinuationToken parallelContinuationToken = new ParallelContinuationToken( | ||
token: feedRangeState.State != null ? ((CosmosString)feedRangeState.State.Value).Value : null, | ||
|
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.
Please add tests to prevent future regressions.
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 don't even have a reproduce, so there is not test. It also never affected correctness, so what kind of test are you looking for?
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.
How do we know the issue is fixed then? Can't we have a test that defines the expected behavior and verifies this change is actually fixing the issue?
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.
Or at least have a test that defines the behavior that we had before the code change to assert that the new code does not regress/change it?
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 know that the problem container only had 2 physical partitions. It should be easy to unit test all the possible combinations with 2 items [(a,b)(b,a)(null,a)(null,null)(b,null)(a,a)], and verify they all complete in reasonable time.
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 enumerated the combinations. Nothing reproduced. Send a reproduce and create a work item. This PR is just to take query code out of the stack. If the high CPU is caused by doing string comparison, then we know to route to dotnet team.
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.
If the diagnostics does not include the necessary information to reproduce the issue please update it to include it. Then capture the information to reproduce the issue.
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.
The user didn't even have diagnostics for the reported issue. Im sure tracing would show time being spent in move next async if that were the case.