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

CPU hotpath originating in CosmosQueryClientCore.GetCosmosElementResponse #2815

Closed
olivertowers opened this issue Oct 22, 2021 · 2 comments · Fixed by #2861 or #2869
Closed

CPU hotpath originating in CosmosQueryClientCore.GetCosmosElementResponse #2815

olivertowers opened this issue Oct 22, 2021 · 2 comments · Fixed by #2861 or #2869
Assignees
Labels

Comments

@olivertowers
Copy link
Member

olivertowers commented Oct 22, 2021

Describe the bug
Seeing CPU hotpath that is originating in CosmosQueryClientCore.GetCosmosElementResponse which is using 6% of application CPU during a query workload.

Flame graph reference internal link:

image

Zooming into the QueryPage ctor:

image

The main issue is whether this CPU impact can be reduced when SDK is handling high volume query workloads.

Within this hotpath two methods are of note:

  1. Page ctor is creating an ImmutableDictionary for AdditionalHeaders property, see - ImmutableDictionary is known to be much slower than Dictionary, so maybe IReadOnlyDictionary would be better for this even if the trade-off is that true immutability guarantee is lost?

  2. QueryExceutionInfo header is deserialized with Newtonsoft.Json here - Would it be more performant to use the Json text readers built-in to the SDK instead?

To Reproduce

Run a high volume query workload and monitor/profile on the SDK.
More likely to see the issue with the following setup/workload

  1. 10+ partitions collection.
  2. Query workload issuing cross partition queries which return no results. This highlights the impact of many empty pages being returned but where the header/execution info is still significant.

Expected behavior
Expect a lower CPU impact on an application for the critical path in query responses.

Actual behavior
Higher CPU impact for query response handling especially when very few items are returned.

Environment summary
SDK Version: 3.21/Any
OS Version: Win 10

@kirankumarkolli
Copy link
Member

@sourabh1007 what else is pending for this issue?

@sourabh1007
Copy link
Contributor

It can be closed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment