-
Notifications
You must be signed in to change notification settings - Fork 720
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
Add new replicate module API to bypass command validation #1357
base: unstable
Are you sure you want to change the base?
Conversation
18763c9
to
c54ba74
Compare
c54ba74
to
24e6573
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #1357 +/- ##
============================================
+ Coverage 71.11% 71.13% +0.01%
============================================
Files 123 123
Lines 65532 65547 +15
============================================
+ Hits 46603 46626 +23
+ Misses 18929 18921 -8
|
Open a pr for documentation of this: valkey-io/valkey-doc#192 |
The PR comes from a performance issue about current VM_Replicated, then could you pls provide the result how much performance improvement on this PR? |
I don't see notable performance improvement in the multiple tests (1. benchmark 2. CPU utilization, 3. CPU profiling with perf) so I wonder if it is worth introducing this new API. @hwware @hpatro 1. BenchmarkWith validation
Bypass validation
2. CPU utilization
With validation
Bypass validation
3. Performance profiling with
|
@valkey-io/core-team Do you think this is a proper solution? |
I added another CPU utilization test to push around 90% |
fd2cbc0
to
1f41ddd
Compare
New performance test showing performance increase. |
The new module api, if the command does not exist, the server will crash, right? Are we considering adding flags to the client to bypass some checks? For example, a trusted client flag? |
@enjoy-binbin I may be wrong, but I believe the primary can replica anything. The replica receiving it will try to execute it and will fail with an error which is normally just ignored. But there is a config that makes the replica crash:
What do you mean? The module can send stuff to the replication stream even no actually command was sent by any real client. A module is always trusted. A module can do all kinds of dangerous things that can crash the server. |
right, sorry about this confusing wording, i got the context mixed up (reading other discussions at the same time). anyway, what i means is that, can we add flags to the client, or like ctx flags then can bypass some internal checks? i am not sure about it though, i am not that good at module, i am ok with the new module api if needed. |
@valkey-io/core-team can we settle on the |
Signed-off-by: Seungmin Lee <[email protected]>
Signed-off-by: Seungmin Lee <[email protected]>
Signed-off-by: Seungmin Lee <[email protected]>
1f41ddd
to
67dbe62
Compare
@valkey-io/core-team nudge! |
Add it to next meeting agenda |
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.
Implementation LGTM.
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.
Looks good to me as well, just minor suggestions.
Co-authored-by: Madelyn Olson <[email protected]> Signed-off-by: Seungmin Lee <[email protected]>
Co-authored-by: Madelyn Olson <[email protected]> Signed-off-by: Seungmin Lee <[email protected]>
Signed-off-by: Seungmin Lee <[email protected]>
ValkeyModule_ReplicateWithoutValidation(ctx, "INCR", | ||
"c", "counter-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.
nit: Can't this in a single line?
ValkeyModule_ReplicateWithoutValidation(ctx, "INCR", | ||
"c", "counter-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.
Same as above.
@@ -681,7 +681,6 @@ tags "modules" { | |||
} | |||
} | |||
|
|||
|
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.
Remove.
Issue #1175
Problem
Performance degradation occurs due to the sanity check(lookupCommandByCString) in the VM_Replicate function, which converts const char* into sds and free them for command dictionary lookup. This check is mainly used for debugging purpose, but it is unnecessary for trusted modules. The user seeks a way to bypass this check for performance gains.
Solution
Adding a module API
ReplicateWithoutValidation
allows trusted modules to bypass validation for performance improvements while retaining flexibility for handling failure scenarios on replicas.Test
Unit test
Follow-up work
Valkey document update required: https://valkey.io/topics/modules-api-ref/#section-commands-replication-api