Skip to content

Conversation

@SoulPancake
Copy link
Contributor

For #844

Implement slot-based MGET batching for cluster clients

Co-authored-by: SoulPancake <[email protected]>
@jit-ci
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.

@SoulPancake
Copy link
Contributor Author

SoulPancake commented Oct 20, 2025

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.

@rueian
make(map[uint16]Completed, 8) in MGets/JsonMGets does escape to heap.
What do you suggest we do here

@rueian
Copy link
Collaborator

rueian commented Oct 20, 2025

What do you suggest we do here

  1. Try inline MGets/JsonMGets manually.
  2. Then replacing make(map[uint16]Completed, 8) with make(map[uint16]int, 8) where the values are the indexes of cmds.s, eliminating the use of slotCmds.

@SoulPancake
Copy link
Contributor Author

I have some trouble will my personal laptop, I will address these in a week approx, hope that is okay

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