Skip to content
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

Merged
merged 3 commits into from
Dec 16, 2020
Merged

Conversation

bchong95
Copy link
Contributor

Internal Query: Fixes ToList work

Description

Internal customer ran into issue where ToList() was consuming too many CPU cycles. We don't know why this is the case, but we can atleast avoid the allocation for it and remove a comparer this is just a glorified wrapper around string comparer.

@@ -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
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Member

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?

Copy link
Member

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

List<ParallelContinuationToken> activeParallelContinuationTokens = new List<ParallelContinuationToken>();
for (int i = 0; i < feedRangeStates.Count; i++)
{
FeedRangeState<QueryState> firstState = feedRangeStates.First();
Copy link
Contributor

@j82w j82w Dec 11, 2020

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's removing instructions from the compare operator thus faster.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is no benchmark so how do you know it is faster?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants