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

restore: reduce allocations when restoring to longer tenant keys #120149

Merged
merged 1 commit into from
Mar 11, 2024

Conversation

dt
Copy link
Member

@dt dt commented Mar 8, 2024

Release note: none.
Epic: none.

@dt dt requested a review from msbutler March 8, 2024 19:18
@dt dt requested a review from a team as a code owner March 8, 2024 19:18
Copy link

blathers-crl bot commented Mar 8, 2024

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@dt dt force-pushed the restore-ten-alloc branch from fb561f0 to 2bef9e2 Compare March 8, 2024 19:21
@dt dt linked an issue Mar 8, 2024 that may be closed by this pull request
Copy link
Collaborator

@msbutler msbutler left a comment

Choose a reason for hiding this comment

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

I feel like we need to give key_rewriter_test.go some love. We don't benchmark tenant rekeying. We could push this to stability period.

@@ -273,7 +274,19 @@ func (kr *KeyRewriter) RewriteKey(
copy(keyTenantPrefix, newTenantPrefix)
rekeyed = append(keyTenantPrefix, rekeyed...)
} else {
rekeyed = append(newTenantPrefix, rekeyed...)
l := len(newTenantPrefix) + len(rekeyed)
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you write a comment explaining why you're doing this? I believe the idea is that you want to reduce the number of times we allocate memory by allocating a slab of memory every time we exhaust our alloc buf.

Copy link
Collaborator

Choose a reason for hiding this comment

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

it also seems that we can use this strategy here too, though I think this path in traditional restore.

Copy link
Member Author

Choose a reason for hiding this comment

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

that we can use this strategy here too

We could. we'd need to hang the slab off the rule instead of the rewriter or something. I'm not very motivated until I see it in a profile, which would probably be from backing up table < 127 and restoring > 127.

Copy link
Member Author

Choose a reason for hiding this comment

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

added comments

@dt
Copy link
Member Author

dt commented Mar 11, 2024

We don't benchmark tenant rekeying.

Eh, I think microbenchmarking is useful if we're really hunting for optimizations, but otherwise I'm fine with just letting a profile from a running real cluster tell us when something is worth optimizing. I don't feel particularly motivated to add KeyRewriter benchmarks especially as OR replaces this code.

@dt dt force-pushed the restore-ten-alloc branch from 2bef9e2 to b0645f3 Compare March 11, 2024 20:38
@dt dt force-pushed the restore-ten-alloc branch from b0645f3 to e7316d6 Compare March 11, 2024 21:45
@dt
Copy link
Member Author

dt commented Mar 11, 2024

TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented Mar 11, 2024

Build succeeded:

@craig craig bot merged commit 734839e into cockroachdb:master Mar 11, 2024
18 of 19 checks passed
@dt dt deleted the restore-ten-alloc branch March 12, 2024 04:45
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.

restore: excessive allocations during restore into UA cluster
3 participants