Support for RDB analysis reports#1743
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #1743 +/- ##
============================================
+ Coverage 71.17% 71.44% +0.27%
============================================
Files 123 122 -1
Lines 65536 66766 +1230
============================================
+ Hits 46645 47704 +1059
- Misses 18891 19062 +171
🚀 New features to boost your workflow:
|
Co-authored-by: wei.kukey <[email protected]> Signed-off-by: artikell <[email protected]>
523708d to
04c476c
Compare
There was a problem hiding this comment.
Cool. Not sure about the argument name --profiler. Profiler is more often used for things like CPU time.
How about --stats or --verbose?
An RDB file can also contain Functions IIRC. Shall we print the count too?
@enjoy-binbin I know you wanted to print the eval scripts in old RDB files. Maybe we can print the number of scripts as part of stats here too?
|
|
Signed-off-by: artikell <[email protected]>
Signed-off-by: artikell <[email protected]>
You have a wrong memory, i dont want to print the lua scripts, i want to print the number of scripts. See #1448 |
Sorry, I mean number of scripts. This PR prints the number of many things, such as the of functions, number of keys of each type, etc. To print the number of lua scripts if any would make sense here? Maybe only print it if it's non-zero, because it's only for quite old RDB files. WDYT? |
SGTM, we can print it (that is what i was looking for at that time). I can re-open the old PR if needed if you want to keep the history. Or we can do it in this PR. |
I guess in this PR is better in that case. This PR prints the info in another way. Or maybe reopen it after this PR is merged. @artikell do you want to add the number of lua scripts from old RDB files as in #1448? They are just aux-fields with the name "lua". I suggest print them only if the number is non-zero since it's old stuff that will always be zero except in very old RDB files. |
|
@artikell What is the "form" formats? Can you mention it in the PR top comment? What's the use case of the "form" format? If it is to consume by scripts, I guess CSV or JSON formats is more common. We already use those formats in valkey-cli and valkey-benchmark. |
Regarding the number of Lua scripts, I will refer to Binbin's MR to make the addition in this MR. |
Yes maybe "table" is a better name. The example in the PR comment is the "info" format? It is also readable for users. Not a big difference to "form"? I'm thinking maybe we don't need both.... For CSV, JSON, YAML, I don't have a strong opinion but it seems nice to align the output format from our different tools. CSV seems to be supported by most of them so add it here too? |
Co-authored-by: Binbin <[email protected]> Signed-off-by: artikell <[email protected]>
Signed-off-by: artikell <[email protected]>
@zuiderkwast I've understood your thoughts. Now I've changed it to three formats:
|
There was a problem hiding this comment.
The CSV output is prefixed with some non-CSV content like
[offset 8999] \o/ RDB looks OK! \o/
[info] 60 keys read
[info] 0 expires
[info] 0 already expired
.... so I guess it doesn't work to direct the output to file and load it as a CSV file.
Can we skip the prefix information for the CSV output mode? An option could be to print the non-CSV prefix info to stderr and the CSV content to stdout (?).
Signed-off-by: skyfirelee <[email protected]>
I have added an |
zuiderkwast
left a comment
There was a problem hiding this comment.
Yeah the --output argument will work with --csv. I hope users will find it, instead of using shell redirect or pipe valkey-check-rdb --csv > file.
Signed-off-by: skyfirelee <[email protected]>
Signed-off-by: skyfirelee <[email protected]>
zuiderkwast
left a comment
There was a problem hiding this comment.
LGTM, thanks and sorry for the delay.
Please update the PR top comment to mention the parameters that were actually implemented.
@enjoy-binbin or @madolson do you want to take a look? If not, I will merge it.
Adjust the irrelevant comments. Co-authored-by: Viktor Söderqvist <[email protected]> Signed-off-by: skyfirelee <[email protected]>
7f58984 to
f6adf9b
Compare
Signed-off-by: wei.kukey <[email protected]> Signed-off-by: artikell <[email protected]>
bce221f to
b033ab7
Compare
|
This commit causes a build failure in alpine-linux |
…2225) Use the standard `dup2` to redirect `stdout` Closes #2224 Follow-up of #1743 Signed-off-by: skyfirelee <[email protected]> Signed-off-by: Binbin <[email protected]> Co-authored-by: Binbin <[email protected]>
The PR add analysis capabilities to the valkey-check-rdb tool. Now the tool can statistically analyze various types of keys, expired keys, and key elements. - Added the --stats parameter to the valkey-check-rdb tool's rdb analysis functionality, which enables opening reports. - Supported the --format parameter with three options, table/csv/info, to provide more flexible output formats. - Add function & lua script number info The content format is as follows: ``` ... ... [offset 8999] \o/ RDB looks OK! \o/ [info] 60 keys read [info] 0 expires [info] 0 already expired db.0.type.name string list set zset hash module stream db.0.keys.total 10 0 0 0 0 0 0 db.0.exipre_keys.total 0 0 0 0 0 0 0 db.0.already_expired.total 0 0 0 0 0 0 0 db.0.keys.size 200 0 0 0 0 0 0 db.0.keys.value_size 2000 0 0 0 0 0 0 db.0.elements.total 10 0 0 0 0 0 0 db.0.elements.size 2000 0 0 0 0 0 0 db.0.elements.num.max 1 0 0 0 0 0 0 db.0.elements.num.avg 1.00 0.00 0.00 0.00 0.00 0.00 0.00 db.0.elements.num.p99 1.00 0.00 0.00 0.00 0.00 0.00 0.00 db.0.elements.num.p90 1.00 0.00 0.00 0.00 0.00 0.00 0.00 db.0.elements.num.p50 1.00 0.00 0.00 0.00 0.00 0.00 0.00 db.0.elements.size.max 200 0 0 0 0 0 0 db.0.elements.size.avg 200.00 0.00 0.00 0.00 0.00 0.00 0.00 db.0.elements.size.p99 200.00 0.00 0.00 0.00 0.00 0.00 0.00 db.0.elements.size.p90 200.00 0.00 0.00 0.00 0.00 0.00 0.00 db.0.elements.size.p50 200.00 0.00 0.00 0.00 0.00 0.00 0.00 ``` --------- Signed-off-by: artikell <[email protected]> Signed-off-by: skyfirelee <[email protected]> Signed-off-by: wei.kukey <[email protected]> Co-authored-by: wei.kukey <[email protected]> Co-authored-by: Binbin <[email protected]> Co-authored-by: Viktor Söderqvist <[email protected]>
…alkey-io#2225) Use the standard `dup2` to redirect `stdout` Closes valkey-io#2224 Follow-up of valkey-io#1743 Signed-off-by: skyfirelee <[email protected]> Signed-off-by: Binbin <[email protected]> Co-authored-by: Binbin <[email protected]>
There are two problems with initializing databases to 1: 1. db0 is used by default. After printing db0, we will additionally print db1 with no reason. 2. Based on 1, if the RDB is an empty RDB, check-rdb will crash. Because there is no key data, we don't have the chance to call tryExpandRdbStats, and then when printting db1, we will crash on rdbstate.stats. Intrudoced in valkey-io#1743. Signed-off-by: Binbin <[email protected]>
There are two problems with initializing databases to 1: 1. db0 is used by default. After printing db0, we will additionally print db1 with no reason. 2. Based on 1, if the RDB is an empty RDB, check-rdb will crash. Because there is no key data, we don't have the chance to call tryExpandRdbStats, and then when printting db1, we will crash on rdbstate.stats. Introduced in #1743. Signed-off-by: Binbin <[email protected]>


The PR add analysis capabilities to the valkey-check-rdb tool. Now the tool can statistically analyze various types of keys, expired keys, and key elements.
The content format is as follows: