Skip to content

perf: optimize checksum calculation with IncrementalHash#764

Open
olavloite wants to merge 2 commits into
mainfrom
optimize-checksum-calc
Open

perf: optimize checksum calculation with IncrementalHash#764
olavloite wants to merge 2 commits into
mainfrom
optimize-checksum-calc

Conversation

@olavloite

Copy link
Copy Markdown
Collaborator

Use IncrementalHash for calculating the checksum of a transaction, rather than creating a new SHA256 instance for every row.

Use IncrementalHash for calculating the checksum of a transaction, rather than
creating a new SHA256 instance for every row.
@olavloite olavloite requested review from a team as code owners June 22, 2026 13:20

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors SpannerDataReaderWithChecksum to use IncrementalHash (SHA256) for running checksum calculations instead of re-calculating it from scratch on every row, which improves performance and reduces allocations. It also caches the final checksum upon disposal to support transaction retries. The reviewer suggests optimizing the CodedOutputStream instantiation in AppendRowToHash by specifying a smaller buffer size (e.g., 256 bytes) to further reduce per-row memory allocations and mitigate GC pressure.

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.

1 participant