-
Notifications
You must be signed in to change notification settings - Fork 653
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
Move prepareClientToWrite out of loop for lrange command to reduce the redundant call. #860
Conversation
loop for lrange command. --------- Signed-off-by: Lipeng Zhu <lipeng.zhu@intel.com> Co-authored-by: Wangyang Guo <wangyang.guo@intel.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## unstable #860 +/- ##
============================================
- Coverage 70.47% 70.32% -0.16%
============================================
Files 112 113 +1
Lines 61467 61744 +277
============================================
+ Hits 43320 43422 +102
- Misses 18147 18322 +175
|
Ping @valkey-io/core-team, could you help to take a look? |
@lipzhu So I have a proposal to add some more type checking, which alleviates my concerns to prevent someone from misusing this API. |
--------- Signed-off-by: Lipeng Zhu <lipeng.zhu@intel.com> Co-authored-by: Wangyang Guo <wangyang.guo@intel.com>
@madolson I am not sure I got your point, I just simply introduce the |
Or we can introduce a new flag like |
We would have to reset it at the end of the command evocation. My concern is that someone might miss resetting it. There is no good idiomatic way to execute a defer in C afaik. |
I think the application of this writeReadyClient API will be in plenty of places if we accept it. The part I'm not sure about is how/when devs will pick the writeReady API(s) over the regular API(s). Also, we would need to duplicate most of the addReply API(s). Overall, I feel introducing the client flag |
We could maybe do it in afterCommand. Would need to go look through the various edge cases like client disconnects that might get bypassed. @lipzhu Do you want to prototype that? Otherwise I'm fine merging this as is. |
@madolson Maybe we can merge this firstly. Regarding the proposal, I can open a new PR which focus on the code refactor. |
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
The code felt good, but I changed the wording to |
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
…e redundant call. (#860) ## Description When I explore the cycles distributions for `lrange` test ( `valkey-benchmark -p 9001 -t lrange -d 100 -r 1000000 -n 1000000 -c 50 --threads 4`). I found the `prepareClientToWrite` and `clientHasPendingReplies` could be reduced to single call outside instead of called in a loop, ideally we can gain 3% performance. The corresponding `LRANG_100`, `LRANG_300`, `LRANGE_500`, `LRANGE_600` have ~2% - 3% performance boost, the benchmark test prove it helps. This patch try to move the `prepareClientToWrite` and its child `clientHasPendingReplies` out of the loop to reduce the function overhead. --------- Signed-off-by: Lipeng Zhu <lipeng.zhu@intel.com>
…e redundant call. (#860) ## Description When I explore the cycles distributions for `lrange` test ( `valkey-benchmark -p 9001 -t lrange -d 100 -r 1000000 -n 1000000 -c 50 --threads 4`). I found the `prepareClientToWrite` and `clientHasPendingReplies` could be reduced to single call outside instead of called in a loop, ideally we can gain 3% performance. The corresponding `LRANG_100`, `LRANG_300`, `LRANGE_500`, `LRANGE_600` have ~2% - 3% performance boost, the benchmark test prove it helps. This patch try to move the `prepareClientToWrite` and its child `clientHasPendingReplies` out of the loop to reduce the function overhead. --------- Signed-off-by: Lipeng Zhu <lipeng.zhu@intel.com>
Similar to valkey-io#860 but this is for HGETALL families (HGETALL/HKEYS/HVALS). This patch moves `prepareClientToWrite` out of the loop to reduce the function overhead. | test | unstable(150c197) rpc | this patch (rpc) | improvements | | ------------- | -------------------------- | ---------------- | ------------ | | HGETALL h1 | 85084.66 | 86926.29 | 2.16446772 | | HGETALL h10 | 78400.62 | 76893.5 | -1.922331737 | | HGETALL h25 | 64487.01 | 58802.77 | -8.814550403 | | HGETALL h50 | 47587.32 | 49360.78 | 3.726749058 | | HGETALL h100 | 33028.37 | 34454.25 | 4.317137055 | | HGETALL h300 | 14628.22 | 15540.98 | 6.239720212 | | HGETALL h500 | 9593.52 | 10395.44 | 8.358975642 | Signed-off-by: Masahiro Ide <masahiro.ide@lycorp.co.jp>
Similar to #860 but this is for HGETALL families (HGETALL/HKEYS/HVALS). This patch moves `prepareClientToWrite` out of the loop to reduce the function overhead. Signed-off-by: Masahiro Ide <imasahiro9@gmail.com> Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
…1119) Similar to valkey-io#860 but this is for HGETALL families (HGETALL/HKEYS/HVALS). This patch moves `prepareClientToWrite` out of the loop to reduce the function overhead. Signed-off-by: Masahiro Ide <imasahiro9@gmail.com> Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
Description
When I explore the cycles distributions for
lrange
test (valkey-benchmark -p 9001 -t lrange -d 100 -r 1000000 -n 1000000 -c 50 --threads 4
). I found theprepareClientToWrite
andclientHasPendingReplies
could be reduced to single call outside instead of called in a loop, ideally we can gain 3% performance. The correspondingLRANG_100
,LRANG_300
,LRANGE_500
,LRANGE_600
have ~2% - 3% performance boost, the benchmark test prove it helps.This patch try to move the
prepareClientToWrite
and its childclientHasPendingReplies
out of the loop to reduce the function overhead.Test Environment
OPERATING SYSTEM: Ubuntu 22.04.4 LTS
Kernel: 5.15.0-116-generic
PROCESSOR: Intel Xeon Platinum 8380
Server and Client in same socket.
Server Configuration
Benchmark Results