Skip to content

Introduce CLUSTER SLOT-STATS command, key-count metic#351

Merged
madolson merged 11 commits intovalkey-io:unstablefrom
kyle-yh-kim:20-slotstats
Jun 27, 2024
Merged

Introduce CLUSTER SLOT-STATS command, key-count metic#351
madolson merged 11 commits intovalkey-io:unstablefrom
kyle-yh-kim:20-slotstats

Conversation

@kyle-yh-kim
Copy link
Contributor

The command provides detailed slot usage statistics upon invocation, with initial support for key-count metric. cpu-usec (approved) and memory-bytes (pending-approval) metrics will soon follow after the merger of this PR.

@madolson
Copy link
Member

madolson commented Apr 23, 2024

Run:

git rebase HEAD~1 --signoff
git push origin --force 20-slotstats

To fix the DCO complaint.

@madolson madolson added the major-decision-pending Major decision pending by TSC team label Apr 23, 2024
The command provides detailed slot usage statistics upon invocation,
with initial support for key-count metric. cpu-usec (approved) and
memory-bytes (pending-approval) metrics will soon follow after the
merger of this PR.

Signed-off-by: Kyle Kim <kimkyle@amazon.com>
@kyle-yh-kim
Copy link
Contributor Author

Thanks for sharing. Two changes added;

  • Fixed DCO complaint through --signoff
  • Added trailing new line for cluster_slots.c

@madolson
Copy link
Member

madolson commented May 7, 2024

@PingXie I think you asked for this in the past, you should also take a look if you have time.

@codecov
Copy link

codecov bot commented May 7, 2024

Codecov Report

Attention: Patch coverage is 87.36842% with 12 lines in your changes missing coverage. Please review.

Project coverage is 70.12%. Comparing base (ce79539) to head (3cf86ab).
Report is 10 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable     #351      +/-   ##
============================================
+ Coverage     70.05%   70.12%   +0.06%     
============================================
  Files           110      111       +1     
  Lines         60084    60203     +119     
============================================
+ Hits          42094    42218     +124     
+ Misses        17990    17985       -5     
Files Coverage Δ
src/commands.def 100.00% <ø> (ø)
src/server.h 100.00% <ø> (ø)
src/cluster_slot_stats.c 87.36% <87.36%> (ø)

... and 14 files with indirect coverage changes

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.

I remember most of this, and it still mostly LGTM.

@madolson
Copy link
Member

Review this during a separate meeting.

  1. High level approval for the approach of adding per-slot statistics.
  2. Start with CPU, key count, network bytes in, network bytes out.
  3. Defer the decision about memory usage since it was contentious.

Still need alignment about the command arguments. Will have separate approval for that.

@madolson madolson added major-decision-approved Major decision approved by TSC team major-decision-pending Major decision pending by TSC team and removed major-decision-pending Major decision pending by TSC team major-decision-approved Major decision approved by TSC team labels May 27, 2024
- Renamed cluster_slots.c to cluster_slot_stats.c
- Renamed function signature and variables.
- Removed 0 argument support.

Signed-off-by: Kyle Kim <kimkyle@amazon.com>
@kyle-yh-kim
Copy link
Contributor Author

I've cut a 2nd revision, which includes;

  • Renamed cluster_slots.c to cluster_slot_stats.c
  • Renamed function signature and variables (ex: *slots --> *assigned_slots).
  • Removed 0 argument support (just CLUSTER SLOT-STATS).

@PingXie @madolson
I did not update the existing bytes array into bitmaps, based on the performance testing result attached here.
Unless there's a strong opinion and/or hard evidence otherwise, I'd prefer moving forward with what we have now.

@madolson madolson added major-decision-approved Major decision approved by TSC team and removed major-decision-pending Major decision pending by TSC team labels Jun 20, 2024
- Update reply_schema.

Signed-off-by: Kyle Kim <kimkyle@amazon.com>
@madolson madolson added release-notes This issue should get a line item in the release notes needs-doc-pr This change needs to update a documentation page. Remove label once doc PR is open. labels Jun 24, 2024
@madolson
Copy link
Member

@kyle-yh-kim Can you do a git merge and resolve the conflicts. Also please open a PR like valkey-io/valkey-doc#143 to add documentation for it.

Signed-off-by: Kyle Kim <kimkyle@amazon.com>
- Fixed origin/unstable merge conflicts.
- Updated formatting.
- Updated cluster-slot-stats.json.

Signed-off-by: Kyle Kim <kimkyle@amazon.com>
kyle-yh-kim added a commit to kyle-yh-kim/valkey-doc that referenced this pull request Jun 25, 2024
- Valkey PR link; valkey-io/valkey#351.

Signed-off-by: Kyle Kim <kimkyle@amazon.com>
kyle-yh-kim added a commit to kyle-yh-kim/valkey-doc that referenced this pull request Jun 25, 2024
- Valkey PR link; valkey-io/valkey#351.

Signed-off-by: Kyle Kim <kimkyle@amazon.com>
@kyle-yh-kim
Copy link
Contributor Author

PR for Valkey-doc has been opened; valkey-io/valkey-doc#150

kyle-yh-kim added a commit to kyle-yh-kim/valkey-doc that referenced this pull request Jun 25, 2024
- Valkey PR link; valkey-io/valkey#351.

Signed-off-by: Kyle Kim <kimkyle@amazon.com>
- Updated RESP reply from map to array.
- Renamed slotStatEntry to slotStatForSort.

Signed-off-by: Kyle Kim <kimkyle@amazon.com>
- Updated the RESP3 response from array of maps to array of arrays.

Signed-off-by: Kyle Kim <kimkyle@amazon.com>
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
madolson added 2 commits June 27, 2024 16:26
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
@madolson madolson merged commit 1269532 into valkey-io:unstable Jun 27, 2024
zuiderkwast added a commit to valkey-io/valkey-doc that referenced this pull request Nov 18, 2024
Docs for CLUSTER SLOT-STATS, with key-count, cpu-usec, network-bytes-in,
and network-bytes-out metrics.

- valkey-io/valkey#351
- valkey-io/valkey#712
- valkey-io/valkey#720

---------

Signed-off-by: Kyle Kim <kimkyle@amazon.com>
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
Co-authored-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
skaslev added a commit to skaslev/redis that referenced this pull request May 13, 2025
Add CLUSTER SLOT-STATS command for key count, cpu time and
network IO per slot currently.

The command has the following syntax

    CLUSTER SLOT-STATS SLOTSRANGE start-slot end-slot

or

    CLUSTER SLOT-STATS ORDERBY metric [LIMIT limit] [ASC/DESC]

where metric can currently be one of the following

    key-count -- Number of keys 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

This PR is based on:
    valkey-io/valkey#351
    valkey-io/valkey#709
    valkey-io/valkey#710

Co-authored-by: Kyle Kim <kimkyle@amazon.com>
Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
skaslev added a commit to skaslev/redis that referenced this pull request May 19, 2025
Add CLUSTER SLOT-STATS command for key count, cpu time and
network IO per slot currently.

The command has the following syntax

    CLUSTER SLOT-STATS SLOTSRANGE start-slot end-slot

or

    CLUSTER SLOT-STATS ORDERBY metric [LIMIT limit] [ASC/DESC]

where metric can currently be one of the following

    key-count -- Number of keys 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

This PR is based on:
    valkey-io/valkey#351
    valkey-io/valkey#709
    valkey-io/valkey#710

Co-authored-by: Kyle Kim <kimkyle@amazon.com>
Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
@enjoy-binbin enjoy-binbin changed the title Introduce CLUSTER SLOT-STATS command (#20). Introduce CLUSTER SLOT-STATS command, key-count metic Jun 25, 2025
skaslev added a commit to redis/redis that referenced this pull request Jul 1, 2025
Add CLUSTER SLOT-STATS command for key count, cpu time and network IO
per slot currently.

The command has the following syntax

    CLUSTER SLOT-STATS SLOTSRANGE start-slot end-slot

or

    CLUSTER SLOT-STATS ORDERBY metric [LIMIT limit] [ASC/DESC]

where metric can currently be one of the following

    key-count -- Number of keys 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

This PR is based on:
    valkey-io/valkey#351
    valkey-io/valkey#709
    valkey-io/valkey#710
    valkey-io/valkey#720
    valkey-io/valkey#840

Co-authored-by: Kyle Kim <kimkyle@amazon.com>
Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
Co-authored-by: Harkrishn Patro <harkrisp@amazon.com>

---------

Co-authored-by: Kyle Kim <kimkyle@amazon.com>
Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
fcostaoliveira pushed a commit to filipecosta90/redis that referenced this pull request Jul 4, 2025
Add CLUSTER SLOT-STATS command for key count, cpu time and network IO
per slot currently.

The command has the following syntax

    CLUSTER SLOT-STATS SLOTSRANGE start-slot end-slot

or

    CLUSTER SLOT-STATS ORDERBY metric [LIMIT limit] [ASC/DESC]

where metric can currently be one of the following

    key-count -- Number of keys 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

This PR is based on:
    valkey-io/valkey#351
    valkey-io/valkey#709
    valkey-io/valkey#710
    valkey-io/valkey#720
    valkey-io/valkey#840

Co-authored-by: Kyle Kim <kimkyle@amazon.com>
Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
Co-authored-by: Harkrishn Patro <harkrisp@amazon.com>

---------

Co-authored-by: Kyle Kim <kimkyle@amazon.com>
Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

major-decision-approved Major decision approved by TSC team needs-doc-pr This change needs to update a documentation page. Remove label once doc PR is open. release-notes This issue should get a line item in the release notes

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants