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

perf: calculate checksum using protobuf values #2848

Merged
merged 6 commits into from
Feb 9, 2024

Conversation

olavloite
Copy link
Collaborator

@olavloite olavloite commented Jan 27, 2024

Calculates the read/write transaction checksum for query results in the Connection API using the protobuf values instead of the decoded Java objects. This reduces both memory and CPU usage for the calculation.

The hash algorithm is also changed from sha-256 to md5. The latter has a slightly higher collision probability, but still widely within the acceptable ranges for the use-case at hand, which is not security related, but only needed in order to determine equality between query results. Switching to md5 also reduces CPU usage.

@product-auto-label product-auto-label bot added size: l Pull request size is large. api: spanner Issues related to the googleapis/java-spanner API. labels Jan 27, 2024
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. and removed size: l Pull request size is large. labels Feb 8, 2024
@olavloite olavloite marked this pull request as ready for review February 8, 2024 14:01
@olavloite olavloite requested a review from a team as a code owner February 8, 2024 14:01
@olavloite olavloite requested a review from ankiaga February 8, 2024 14:02
@olavloite olavloite requested a review from ankiaga February 9, 2024 09:01
@olavloite olavloite merged commit ec1d3c5 into lazy-decode-result-set Feb 9, 2024
19 checks passed
@olavloite olavloite deleted the calculate-checksum-on-protobuf branch February 9, 2024 14:31
olavloite added a commit that referenced this pull request Feb 9, 2024
* feat: support lazy decoding of query results

Adds an option for lazy decoding of query results. Currently, all values
in a query result row are decoded from protobuf values to plain Java
objects at the moment that the result set is advanced to the next row.
This means that all values are decoded, regardless whether the
application actually fetches these or not.

Lazy decoding also enables the possibility for (internal) consumers
of a result set to access the protobuf value before it is converted
to a plain Java object. This for example allows ChecksumResultSet to
calculate the checksum based on the protobuf value, instead of a
Java object, which can be more efficient.

* fix: add null check

* perf: calculate checksum using protobuf values (#2848)

* perf: calculate checksum using protobuf values

* chore: cleanup

* test: remove unrelated test

* fix: undo change to public API

* chore: cleanup|
olavloite added a commit that referenced this pull request Feb 9, 2024
* refactor: move inner classes to top level

Move the gRPC-related inner classes from AbstractResultSet to
top-level classes, so they are easier to modify and maintain.

This change only contains modifications that are needed to move
these inner classes. There are no functional changes.

* feat: support lazy decoding of query results (#2847)

* feat: support lazy decoding of query results

Adds an option for lazy decoding of query results. Currently, all values
in a query result row are decoded from protobuf values to plain Java
objects at the moment that the result set is advanced to the next row.
This means that all values are decoded, regardless whether the
application actually fetches these or not.

Lazy decoding also enables the possibility for (internal) consumers
of a result set to access the protobuf value before it is converted
to a plain Java object. This for example allows ChecksumResultSet to
calculate the checksum based on the protobuf value, instead of a
Java object, which can be more efficient.

* fix: add null check

* perf: calculate checksum using protobuf values (#2848)

* perf: calculate checksum using protobuf values

* chore: cleanup

* test: remove unrelated test

* fix: undo change to public API

* chore: cleanup|

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/java-spanner API. size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants