-
Notifications
You must be signed in to change notification settings - Fork 955
[valkey-benchmark] Allow multiple random (or sequential) placeholders and fix zadd --sequential to create expected data #2102
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
[valkey-benchmark] Allow multiple random (or sequential) placeholders and fix zadd --sequential to create expected data #2102
Conversation
|
Nice! Have you considered I want this for random values too! It's in my mental backlog since I did #2057. I haveaslightly different behavior in mind though. In a transaction or pipeline sequence, I want use the same random number multiple times, for example: (This is a simulation of the suggested GETPXT command in #1455.) Same placeholder, same value. Would this semantic work for sequential too? |
|
Hm, interesting. So you're suggesting that it only retrieve one value per placeholder in a command, whether that's random or sequential? I like that - with multiple placeholders you aren't stuck with duplicating the same value either. How to implement it is not immediately obvious though. The way benchmark is written, for pipelined commands it just duplicates the test command multiple times into a string and forgets about it. It doesn't currently track which parts of the string correspond to prefix/auth stuff or which copy of the command. I'm pretty sure each client sends X pipelined commands and then waits for X replies before sending another batch of commands. (Assuming clients are kept alive) |
I have an idea: We can do one replacement when we write the pipeline to the buffer and another replacement when we execute it. The first replacement inserts some special marker each time a placeholder's value (or counter) should be bumped, alternately when the placeholder's value should not be bumped. Example command sequence: With When we execute it, we replace each placeholder with a random or sequential value and we don't bump it at the Sounds doable? |
|
Ok, I came up with a revision that is used like you suggested! If the same replacement is used with the same command string it will have the same value, and with --sequential they each use independent counters as before. I also made the placeholder location data global rather than duplicated across all clients. It's initialized before threads are created, and is not modified during a test. I also revised the placeholder strings, though I'm reluctant to change the original |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #2102 +/- ##
============================================
- Coverage 71.43% 71.31% -0.12%
============================================
Files 123 123
Lines 67030 67060 +30
============================================
- Hits 47881 47827 -54
- Misses 19149 19233 +84
🚀 New features to boost your workflow:
|
Awesome!
Yeah, we should probably not do this for |
|
@zuiderkwast I've implemented your suggestions. What do you think? 😁 |
zuiderkwast
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.
Great!
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.
Great! Just a very minor nit. Clang-format and spellchecker have some comments.
ac0a6e4 to
9fd3a8d
Compare
|
Need to add "nd" (for 2nd) to the wordlist I guess, |
…equential counters Signed-off-by: Rain Valentine <[email protected]>
Signed-off-by: Rain Valentine <[email protected]>
Signed-off-by: Rain Valentine <[email protected]>
Signed-off-by: Rain Valentine <[email protected]>
…lues), new placeholders have same value for multiple occurrences Signed-off-by: Rain Valentine <[email protected]>
Signed-off-by: Rain Valentine <[email protected]>
9fd3a8d to
5f8ceeb
Compare
Signed-off-by: Rain Valentine <[email protected]>
|
Can you update the title and top comment of the PR to what was finally implemented? |
This extends the
__rand_int__pattern to add__rand_1st__through__rand_9th__.For the new placeholders, multiple occurrences within a command will have the same value.
With the
--sequentialoption, each placeholder will use separate counters.For
__rand_int__, the behavior is unchanged - multiple occurrences of the pattern within a command will have different values.Examples of using the
__rand_int__with--sequential:For the new patterns, multiple occurrences within the command will have the same value.
I also fixed the zadd benchmark so it produces the expected number of keys when used with
--sequential. (By using the same counter twice per command it was effectively counting by twos)I made this for myself but raised a PR in case y'all like it. 🙂