-
Notifications
You must be signed in to change notification settings - Fork 224
feat : Implement slot-based MGET batching for cluster clients #908
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
base: main
Are you sure you want to change the base?
feat : Implement slot-based MGET batching for cluster clients #908
Conversation
Implement slot-based MGET batching for cluster clients Co-authored-by: SoulPancake <[email protected]>
|
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
rueian
left a comment
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.
Functionally, it works, but can we optimize allocations?
|
I optimised the slice mem allocation, is there any other potential improvement I can work on? @rueian |
I wonder if it is possible to avoid using |
@rueian |
|
|
I have some trouble will my personal laptop, I will address these in a week approx, hope that is okay |
Co-authored-by: Rueian <[email protected]>
Co-authored-by: Rueian <[email protected]>
32627b2 to
39a9e9f
Compare
|
@rueian
|
helper.go
Outdated
| slotGroups := make(map[uint16][]string) | ||
| for _, key := range keys { | ||
| ks := slot(key) | ||
| slotGroups[ks] = append(slotGroups[ks], key) |
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.
Is it possible to avoid the string slice allocation here? Maybe use a map[uint16]int instead?
|
Hi @rueian Any chance to review this? |
|
|
||
| func clusterMGet(client Client, ctx context.Context, keys []string) (ret map[string]RedisMessage, err error) { | ||
| ret = make(map[string]RedisMessage, len(keys)) | ||
| slots := make(map[uint16][]int, len(keys)/2) |
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.
Hi @SoulPancake, you just replaced map[uint16][]string with map[uint16][]int, which actually has not much differences. Can you try avoid this temporary slice allocation in the map?
For #844