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

storage: avoid per-kv allocations during consistency checks #29419

Merged

Conversation

nvanbenschoten
Copy link
Member

I noticed in an alloc_objects heap profile on a 3-node cluster restoring tpcc that more than 46% of all allocations were made in computeChecksumPostApply. Specifically, these allocations were all made in Replica.sha512. 28% of allocations were due to protobuf marshaling of hlc.LegacyTimestamp.
The other 18% was in encoding/binary.Write.

This removes both of these sources of per-key allocations. The first allocation was avoided by sharing a byte buffer across protobuf marshals. The second was avoided by removing the call to binary.Write (see golang/go#27403). I confirmed that this is no longer an issue by looking at heap profiles from before and after in a test that performed a consistency check.

I plan to follow up on golang/go#27403 and search for any other offenders in our codebase. I already see a few.

Release note: None

I noticed in an `alloc_objects` heap profile on a 3-node cluster
restoring tpcc that more than 46% of all allocations were made in
`computeChecksumPostApply`. Specifically, these allocations were all
made in `Replica.sha512`. 28% of allocations were due to protobuf
marshaling of `hlc.LegacyTimestamp`. The other 18% was in `encoding/binary.Write`.

This removes both of these sources of per-key allocations. The first
allocation was avoided by sharing a byte buffer across protobuf marshals.
The second was avoided by removing the call to `binary.Write` (see
golang/go#27403). I confirmed that this is no
longer an issue by looking at heap profiles from before and after in a test
that performed a consistency check.

I plan to follow up on golang/go#27403 and
search for any other offenders in our codebase. I already see a few.

Release note: None
@nvanbenschoten nvanbenschoten requested review from benesch and a team August 31, 2018 06:51
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@nvanbenschoten
Copy link
Member Author

screen shot 2018-08-31 at 2 51 38 am

Copy link
Collaborator

@petermattis petermattis left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)

@jordanlewis
Copy link
Member

Excellent! I've noticed these too - glad you figured out how to zap them.

@nvanbenschoten
Copy link
Member Author

TFTRs.

bors r+

craig bot pushed a commit that referenced this pull request Aug 31, 2018
29419: storage: avoid per-kv allocations during consistency checks r=nvanbenschoten a=nvanbenschoten

I noticed in an `alloc_objects` heap profile on a 3-node cluster restoring tpcc that more than 46% of all allocations were made in `computeChecksumPostApply`. Specifically, these allocations were all made in `Replica.sha512`. 28% of allocations were due to protobuf marshaling of `hlc.LegacyTimestamp`. 
The other 18% was in `encoding/binary.Write`.

This removes both of these sources of per-key allocations. The first allocation was avoided by sharing a byte buffer across protobuf marshals. The second was avoided by removing the call to `binary.Write` (see golang/go#27403). I confirmed that this is no longer an issue by looking at heap profiles from before and after in a test that performed a consistency check.

I plan to follow up on golang/go#27403 and search for any other offenders in our codebase. I already see a few.

Release note: None

Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
@craig
Copy link
Contributor

craig bot commented Aug 31, 2018

Build succeeded

@craig craig bot merged commit a858aeb into cockroachdb:master Aug 31, 2018
@nvanbenschoten nvanbenschoten deleted the nvanbenschoten/checksumAlloc branch September 11, 2018 15:41
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.

4 participants