Skip to content

Conversation

SoulPancake
Copy link
Contributor

For #844

Implement slot-based MGET batching for cluster clients

Co-authored-by: SoulPancake <70265851+SoulPancake@users.noreply.github.com>
Copy link

jit-ci bot commented Oct 4, 2025

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.

Copy link
Collaborator

@rueian rueian left a 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?

@SoulPancake
Copy link
Contributor Author

I optimised the slice mem allocation, is there any other potential improvement I can work on? @rueian

Comment on lines +278 to +282
i := 0
for _, cmd := range slotCmds {
cmds.s[i] = cmd.Pin()
i++
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we put i into the loop?

Comment on lines +311 to +315
i := 0
for _, cmd := range slotCmds {
cmds.s[i] = cmd.Pin()
i++
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we put i into the loop?

Comment on lines +286 to +288
if err := resp.NonRedisError(); err != nil {
return nil, err
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if err := resp.NonRedisError(); err != nil {
return nil, err
}

The below resp.ToArray should cover this already.

Comment on lines +319 to +321
if err := resp.NonRedisError(); err != nil {
return nil, err
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if err := resp.NonRedisError(); err != nil {
return nil, err
}

The below resp.ToArray() should cover this already.

Comment on lines +273 to +275
if len(slotCmds) == 0 {
return ret, nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

When could this happen?

@rueian
Copy link
Collaborator

rueian commented Oct 10, 2025

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 MGets since it allocates a make(map[uint16]Completed, 8) though I am not sure if it is allocated on the heap or the stack after compiler optimization. Would you mind checking that? If it is allocated on the stack, then it should be fine.

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.

2 participants