Skip to content
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 CLUSTER SLOT-STATS document. #150

Merged
merged 11 commits into from
Nov 18, 2024
Merged

Conversation

kyle-yh-kim
Copy link
Contributor

@kyle-yh-kim kyle-yh-kim commented Jun 25, 2024

- Valkey PR link; valkey-io/valkey#351.

Signed-off-by: Kyle Kim <[email protected]>
commands.json Outdated Show resolved Hide resolved
- Removed commands.json changes.
- Added ordering invariance within the markdown.

Signed-off-by: Kyle Kim <[email protected]>
- Added RESP3 response.

Signed-off-by: Kyle Kim <[email protected]>
- Added cpu, network-bytes-in and network-bytes-out metrics.
- Added a tie breaker condition for ORDERBY argument.

Signed-off-by: Kyle Kim <[email protected]>
commands/cluster-slot-stats.md Outdated Show resolved Hide resolved
commands/cluster-slot-stats.md Outdated Show resolved Hide resolved
commands/cluster-slot-stats.md Outdated Show resolved Hide resolved
commands/cluster-slot-stats.md Outdated Show resolved Hide resolved
commands/cluster-slot-stats.md Show resolved Hide resolved
commands/cluster-slot-stats.md Outdated Show resolved Hide resolved
commands/cluster-slot-stats.md Outdated Show resolved Hide resolved
commands/cluster-slot-stats.md Outdated Show resolved Hide resolved
commands/cluster-slot-stats.md Outdated Show resolved Hide resolved
Copy link
Member

@madolson madolson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, finally really looked through everything and left a few comments about clarity.

@zuiderkwast
Copy link
Contributor

@kyle-yh-kim Will you update this PR? It would be good to have docs for the feature. 8.0 is already released.

- Consolidated metrics/statistics wording into statistics.
- Remove verbosity.

Signed-off-by: Kyle Kim <[email protected]>
@kyle-yh-kim
Copy link
Contributor Author

Thanks for the reminder. All comments have been addressed, now awaiting for approval.

Copy link
Contributor

@zuiderkwast zuiderkwast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I have some comments about the structure of the page.

When we generate the man pages, stuff like Reply, ACL categories and History are inserted above Examples. (It looks for certain headings.)

Example man page HSET screenshot

image

commands/cluster-slot-stats.md Outdated Show resolved Hide resolved
commands/cluster-slot-stats.md Outdated Show resolved Hide resolved
- Re-order sections to fit existing standards; OPTIONS and EXAMPLES.

Signed-off-by: Kyle Kim <[email protected]>
@kyle-yh-kim
Copy link
Contributor Author

kyle-yh-kim commented Nov 17, 2024

Thanks for your suggestions, I agree with following the existing man page standards.

Attached below is the new man page for cluster-slot-stats.3valkey, let me know what you think.

CLUSTER-SLOT-STATS(3valkey)               Valkey Command Manual              CLUSTER-SLOT-STATS(3valkey)

NAME
       cluster-slot-stats - Return an array of slot usage statistics for slots assigned to the current
       node.

SYNOPSIS
       CLUSTER SLOT-STATS SLOTSRANGE start-slot end-slot
       CLUSTER SLOT-STATS ORDERBY metric [LIMIT limit] [ASC | DESC]

DESCRIPTION
       CLUSTER SLOT-STATS returns an array of slot usage statistics for slots assigned to the current
       shard.  The command is suitable for Valkey Cluster users aiming to assess general slot usage
       trends, identify hot / cold slots, migrate slots for a balanced cluster workload, and / or
       re-write application logic to better utilize slots.

       The following statistics are supported:

       • KEY-COUNT – Number of keys residing in a given slot.

       • CPU-USEC micro-seconds – Amount of cpu time (in micro-seconds) spent on a given slot.

       • NETWORK-BYTES-IN bytes – Amount of network ingress (in bytes) received for given slot.

       • NETWORK-BYTES-OUT bytes – Amount of network egress (in bytes) sent out for given slot.

OPTIONS
       • ORDERBY – Returns an ordered slot statistics based on the specified statistic and sub-arguments
         to identify hot / cold slots across the cluster.  In the event of a tie in the stats, ascending
         slot number is used as a tie breaker.

       • SLOTSRANGE – Returns slot statistics based on the slots range provided for pagination.  The
         range is inclusive.  The response is ordered in ascending slot number.

COMPLEXITY
       O(N) where N is the total number of slots based on arguments.  O(N*log(N)) with ORDERBY
       subcommand.

ACL CATEGORIES
       @slow

HISTORY
       • Available since: 8.0.0

EXAMPLES
   Response in RESP2
              > CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 2 DESC
              1) 1) (integer) 12426
                 2) 1) "key-count"
                    2) (integer) 45
                    3) "cpu-usec"
                    4) (integer) 0
                    5) "network-bytes-in"
                    6) (integer) 0
                    7) "network-bytes-out"
                    8) (integer) 0
              2) 1) (integer) 13902
                 2) 1) "key-count"
                    2) (integer) 20
                    3) "cpu-usec"
                    4) (integer) 0
                    5) "network-bytes-in"
                    6) (integer) 0
                    7) "network-bytes-out"
                    8) (integer) 0

              > CLUSTER SLOT-STATS SLOTSRANGE 0 1
              1) 1) (integer) 0
                 2) 1) "key-count"
                    2) (integer) 0
                    3) "cpu-usec"
                    4) (integer) 0
                    5) "network-bytes-in"
                    6) (integer) 0
                    7) "network-bytes-out"
                    8) (integer) 0
              2) 1) (integer) 1
                 2) 1) "key-count"
                    2) (integer) 0
                    3) "cpu-usec"
                    4) (integer) 0
                    5) "network-bytes-in"
                    6) (integer) 0
                    7) "network-bytes-out"
                    8) (integer) 0

   Response in RESP3
              > CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 2 DESC
              1) 1) (integer) 12426
                 2) 1# "key-count" => (integer) 45
                    2# "cpu-usec" => (integer) 0
                    3# "network-bytes-in" => (integer) 0
                    4# "network-bytes-out" => (integer) 0
              2) 1) (integer) 13902
                 2) 1# "key-count" => (integer) 20
                    2# "cpu-usec" => (integer) 0
                    3# "network-bytes-in" => (integer) 0
                    4# "network-bytes-out" => (integer) 0

              > CLUSTER SLOT-STATS SLOTSRANGE 0 1
              1) 1) (integer) 0
                 2) 1# "key-count" => (integer) 0
                    2# "cpu-usec" => (integer) 0
                    3# "network-bytes-in" => (integer) 0
                    4# "network-bytes-out" => (integer) 0
              2) 1) (integer) 1
                 2) 1# "key-count" => (integer) 0
                    2# "cpu-usec" => (integer) 0
                    3# "network-bytes-in" => (integer) 0
                    4# "network-bytes-out" => (integer) 0

SEE ALSO
       asking(3valkey), cluster(3valkey), cluster-addslots(3valkey), cluster-addslotsrange(3valkey),
       cluster-bumpepoch(3valkey), cluster-count-failure-reports(3valkey),
       cluster-countkeysinslot(3valkey), cluster-delslots(3valkey), cluster-delslotsrange(3valkey),
       cluster-failover(3valkey), cluster-flushslots(3valkey), cluster-forget(3valkey),
       cluster-getkeysinslot(3valkey), cluster-help(3valkey), cluster-info(3valkey),
       cluster-keyslot(3valkey), cluster-links(3valkey), cluster-meet(3valkey), cluster-myid(3valkey),
       cluster-myshardid(3valkey), cluster-nodes(3valkey), cluster-replicas(3valkey),
       cluster-replicate(3valkey), cluster-reset(3valkey), cluster-saveconfig(3valkey),
       cluster-set-config-epoch(3valkey), cluster-setslot(3valkey), cluster-shards(3valkey),
       cluster-slot-stats(3valkey), cluster-slots(3valkey), readonly(3valkey), readwrite(3valkey).

Valkey Documentation                           2024-11-16                    CLUSTER-SLOT-STATS(3valkey)

kyle-yh-kim and others added 2 commits November 17, 2024 16:08
- Updated stat type to lower case.

Signed-off-by: Kyle Kim <[email protected]>
Co-authored-by: Viktor Söderqvist <[email protected]>
Signed-off-by: Madelyn Olson <[email protected]>
commands/cluster-slot-stats.md Outdated Show resolved Hide resolved
commands/cluster-slot-stats.md Outdated Show resolved Hide resolved
commands/cluster-slot-stats.md Outdated Show resolved Hide resolved
@zuiderkwast
Copy link
Contributor

I remember we have two files that describe the reply types of each command:

resp2_replies.json
resp3_replies.json

They are easily forgotten because the website still doesn't display this information. It's used in the man page version though.

@kyle-yh-kim
Copy link
Contributor Author

New man page has been attached below;

CLUSTER-SLOT-STATS(3valkey)                      Valkey Command Manual                      CLUSTER-SLOT-STATS(3valkey)

NAME
       cluster-slot-stats - Return an array of slot usage statistics for slots assigned to the current node.

SYNOPSIS
       CLUSTER SLOT-STATS SLOTSRANGE start-slot end-slot
       CLUSTER SLOT-STATS ORDERBY metric [LIMIT limit] [ASC | DESC]

DESCRIPTION
       Returns an array of slot usage statistics for slots assigned to the current shard.  The command is suitable for
       Valkey Cluster users aiming to assess general slot usage trends, identify hot / cold slots, migrate slots for a
       balanced cluster workload, and / or re-write application logic to better utilize slots.

       The following statistics are supported:

       • key-count – Number of keys residing in a given slot.

       • cpu-usec – Amount of CPU time (in microseconds) spent on a given slot.

       • network-bytes-in – Amount of network ingress (in bytes) received for given slot.

       • network-bytes-out – Amount of network egress (in bytes) sent out for given slot.

OPTIONS
       • ORDERBY – Returns an ordered slot statistics based on the specified statistic and sub-arguments to identify
         hot / cold slots across the cluster.  Either ASC or DESC modifiers can be used.  In the event of a tie in the
         stats, ascending slot number is used as a tie breaker.

       • SLOTSRANGE – Returns slot statistics based on the slots range provided for pagination.  The range is
         inclusive.  The response is ordered in ascending slot number.

REPLY
   RESP2
       valkey-protocol(7) Array reply: nested list of slot usage statistics.

COMPLEXITY
       O(N) where N is the total number of slots based on arguments.  O(N*log(N)) with ORDERBY subcommand.

ACL CATEGORIES
       @slow

HISTORY
       • Available since: 8.0.0

EXAMPLES
   Response in RESP2
       For ORDERBY:

              > CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 2 DESC
              1) 1) (integer) 12426
                 2) 1) "key-count"
                    2) (integer) 45
                    3) "cpu-usec"
                    4) (integer) 0
                    5) "network-bytes-in"
                    6) (integer) 0
                    7) "network-bytes-out"
                    8) (integer) 0
              2) 1) (integer) 13902
                 2) 1) "key-count"
                    2) (integer) 20
                    3) "cpu-usec"
                    4) (integer) 0
                    5) "network-bytes-in"
                    6) (integer) 0
                    7) "network-bytes-out"
                    8) (integer) 0

       For SLOTSRANGE:

              > CLUSTER SLOT-STATS SLOTSRANGE 0 1
              1) 1) (integer) 0
                 2) 1) "key-count"
                    2) (integer) 0
                    3) "cpu-usec"
                    4) (integer) 0
                    5) "network-bytes-in"
                    6) (integer) 0
                    7) "network-bytes-out"
                    8) (integer) 0
              2) 1) (integer) 1
                 2) 1) "key-count"
                    2) (integer) 0
                    3) "cpu-usec"
                    4) (integer) 0
                    5) "network-bytes-in"
                    6) (integer) 0
                    7) "network-bytes-out"
                    8) (integer) 0

   Response in RESP3
       For ORDERBY:

              > CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 2 DESC
              1) 1) (integer) 12426
                 2) 1# "key-count" => (integer) 45
                    2# "cpu-usec" => (integer) 0
                    3# "network-bytes-in" => (integer) 0
                    4# "network-bytes-out" => (integer) 0
              2) 1) (integer) 13902
                 2) 1# "key-count" => (integer) 20
                    2# "cpu-usec" => (integer) 0
                    3# "network-bytes-in" => (integer) 0
                    4# "network-bytes-out" => (integer) 0

       For SLOTSRANGE:

              > CLUSTER SLOT-STATS SLOTSRANGE 0 1
              1) 1) (integer) 0
                 2) 1# "key-count" => (integer) 0
                    2# "cpu-usec" => (integer) 0
                    3# "network-bytes-in" => (integer) 0
                    4# "network-bytes-out" => (integer) 0
              2) 1) (integer) 1
                 2) 1# "key-count" => (integer) 0
                    2# "cpu-usec" => (integer) 0
                    3# "network-bytes-in" => (integer) 0
                    4# "network-bytes-out" => (integer) 0

SEE ALSO
       asking(3valkey), cluster(3valkey), cluster-addslots(3valkey), cluster-addslotsrange(3valkey),
       cluster-bumpepoch(3valkey), cluster-count-failure-reports(3valkey), cluster-countkeysinslot(3valkey),
       cluster-delslots(3valkey), cluster-delslotsrange(3valkey), cluster-failover(3valkey),
       cluster-flushslots(3valkey), cluster-forget(3valkey), cluster-getkeysinslot(3valkey), cluster-help(3valkey),
       cluster-info(3valkey), cluster-keyslot(3valkey), cluster-links(3valkey), cluster-meet(3valkey),
       cluster-myid(3valkey), cluster-myshardid(3valkey), cluster-nodes(3valkey), cluster-replicas(3valkey),
       cluster-replicate(3valkey), cluster-reset(3valkey), cluster-saveconfig(3valkey),
       cluster-set-config-epoch(3valkey), cluster-setslot(3valkey), cluster-shards(3valkey),
       cluster-slot-stats(3valkey), cluster-slots(3valkey), readonly(3valkey), readwrite(3valkey).

Valkey Documentation                                   2024-11-18                           CLUSTER-SLOT-STATS(3valkey)

- Added ASC / DESC modifiers to the Option description.
- Added header for each RESP response example.

Signed-off-by: Kyle Kim <[email protected]>
@zuiderkwast
Copy link
Contributor

Good, but add it to resp3 replies too, please. Usually all commands are in both files. (If the content is identical, the man page will detect that and not include it twice.)

- Added SLOT-STATS entry under resp2 and resp3_replies.json.

Signed-off-by: Kyle Kim <[email protected]>
@kyle-yh-kim
Copy link
Contributor Author

Apologies, I've now added CLUSTER SLOT-STATS entries under both resp2_replies.json and resp3_replies.json.

Copy link
Contributor

@zuiderkwast zuiderkwast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! I'm happy now.

@zuiderkwast zuiderkwast merged commit 4256863 into valkey-io:main Nov 18, 2024
2 checks passed
@kyle-yh-kim
Copy link
Contributor Author

Nice, thanks a lot for your feedback and review :)
When will it take effect on our documentation page?

@zuiderkwast
Copy link
Contributor

Ask the other Kyle. :)

I wish we could make it automatic when we merge a doc PR. That's how it used to work in Redis, but Kyle doesn't want that. I think he wants to test every change manually before deploying.

@zuiderkwast
Copy link
Contributor

And Thank you for completing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants