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
redis.cli: Add --print-duration-threshold option #10055
base: unstable
Are you sure you want to change the base?
redis.cli: Add --print-duration-threshold option #10055
Conversation
i'm not sure how useful this is. please also note: #9462 that could maybe help solve similar problem (although counted per command, and not per-command execution ) |
yes indeed (also hesitated, some kind a debug action).. The following reply is copied from here: 615ac3d#commitcomment-62543945 just a random idea, we have encountered the problem of high duration (due to cloud service host issue, long time ago). |
WOW.. i have a short memory, and i'm also inconsistent with myself 😄. |
Recently saw this failure in my daily FreeBSD (due to the assert_equal and duration), and it make me remind this PR.
|
Yep, seems useful and needed. |
redis-cli in interactive mode will prints the time elapsed of the operation performed if it took more than 500ms by default. Added `--print-duration-threshold` option, now we can set the value explicitly, the default value is 500 and the unit is milliseconds. This information is very useful in the interactive mode, which is different from the slowlog. That we can observe the time consumption of each command if it touch the threshold. Note in normal way, the duration is very slow because redis is quite fast. But it still useful if we encounter network/host issues or some commands with high time/space complexity. Some usages: ``` [root]# ./src/redis-cli --print-duration-threshold 20 127.0.0.1:6379> debug sleep 0.01 OK 127.0.0.1:6379> debug sleep 0.02 OK (0.02s) ```
7234423
to
9cacd36
Compare
…ion-threshold_option
@@ -3467,7 +3476,7 @@ static void repl(void) { | |||
} | |||
|
|||
elapsed = mstime()-start_time; | |||
if (elapsed >= 500 && | |||
if (elapsed >= config.print_duration_threshold && |
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.
A few thoughts:
- If we print the duration in seconds (like
(0.02s)
) the option should also take the value in the same unit, seconds. (We can parse it and store it as milliseconds internally.) - The option name is a bit complicated. (I don't have a better idea. The only idea I can come up with now is variants like
--print-elapsed-if-gt
which is not really better.) - Do you really need to tweak the value that much? Perhaps you just want to print the elapsed time for all commands? Maybe we can use the existing
--verbose
flag, which doesn't do almost anything at all. (All it does it affects some printout in--cluster rebalance
.)
if (elapsed >= config.print_duration_threshold && | |
if ((elapsed >= 500 || config.verbose) && |
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.
Yean, the name is too long to use.
You are right, actually i want to print the elapsed time for all commands. verbose thing seem fine, not sure which is more versatile though, I actually like the small diff too
if (config.print_duration_threshold < 0) { | ||
fprintf(stderr, "The threshold option must be greater than 0.\n"); |
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.
greater than or equal to zero, according to if
.
redis-cli in interactive mode will prints the time elapsed of the
operation performed if it took more than 500ms by default.
Added
--print-duration-threshold
option, now we can set the valueexplicitly, the default value is 500 and the unit is milliseconds.
This information is very useful in the interactive mode, which is
different from the slowlog. That we can observe the time consumption
of each command if it touch the threshold.
Note in normal way, the duration is very slow because redis is quite
fast. But it still useful if we encounter network/host issues or some
commands with high time/space complexity.
Some usages: