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

Query and change feed: Add serialization optimization by using array instead of by item #1516

Merged
merged 16 commits into from
May 15, 2020

Conversation

j82w
Copy link
Contributor

@j82w j82w commented May 14, 2020

Pull Request Template

Description

This optimizes the query, read feed, and change feed serialization logic. This now sends an array to the serializer instead of serializing each item individually.

Read feed and change feed instead of using cosmos elements which has a DOM this now just searches the binary array for the start and end of the outer documents array.

This being done under the assumption that any new array being added to the service envelope will be a breaking change and will require an API version bump to correctly handle it.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

This only includes the cost of unwrapping the service envelope and getting the array of documents that serializer can easily understand.

ReadFeedPerf

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Please follow the required format: "[Internal] Category: (Add|Fix|Refactor) Description"

Examples:
Diagnostics: Add GetElapsedClientLatency to CosmosDiagnostics
PartitionKey: Fix null reference when using default(PartitionKey)
[v4] Client Encryption: Refactor code to external project
[Internal] Query: Add code generator for CosmosNumbers for easy additions in the future.

@j82w j82w changed the title Read and change feed serialization: Optimize serialization cost Read and change feed: Add serialization optimization May 14, 2020
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Please follow the required format: "[Internal] Category: (Add|Fix|Refactor) Description"

Examples:
Diagnostics: Add GetElapsedClientLatency to CosmosDiagnostics
PartitionKey: Fix null reference when using default(PartitionKey)
[v4] Client Encryption: Refactor code to external project
[Internal] Query: Add code generator for CosmosNumbers for easy additions in the future.

@github-actions github-actions bot dismissed stale reviews from themself May 14, 2020 18:50

All good!

ealsur
ealsur previously approved these changes May 14, 2020
Copy link
Member

@ealsur ealsur left a comment

Choose a reason for hiding this comment

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

90% memory improvement and even greater CPU improvement :shipit:

Copy link
Member

@FabianMeiswinkel FabianMeiswinkel left a comment

Choose a reason for hiding this comment

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

LGTM except for the few comments above

@j82w j82w changed the title Read and change feed: Add serialization optimization Query and change feed: Add serialization optimization by using list instead of by item May 15, 2020
@j82w j82w dismissed stale reviews from FabianMeiswinkel and ealsur via 5962a6e May 15, 2020 12:04
@j82w j82w merged commit 08dfe3e into master May 15, 2020
@j82w j82w deleted the users/jawilley/serializer/fasterParser branch May 15, 2020 19:05
@j82w j82w changed the title Query and change feed: Add serialization optimization by using list instead of by item Query and change feed: Add serialization optimization by using array instead of by item May 15, 2020
@j82w j82w added the QUERY label May 15, 2020
kirankumarkolli pushed a commit that referenced this pull request May 16, 2020
…nstead of by item (#1516)

* ReadFeed and ChangeFeed optimization.
# Conflicts:
#	Microsoft.Azure.Cosmos/src/Serializer/CosmosElementSerializer.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants