-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Conversation
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. |
There was a problem hiding this 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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added comments
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. |
Release note: none. Epic: none.
TFTR! bors r+ |
Build succeeded: |
Release note: none.
Epic: none.