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
Introduce CLUSTER SLOT-STATS command (#20). #351
base: unstable
Are you sure you want to change the base?
Conversation
Run:
To fix the DCO complaint. |
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>
605c923
to
e17019b
Compare
Thanks for sharing. Two changes added;
|
@PingXie I think you asked for this in the past, you should also take a look if you have time. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #351 +/- ##
============================================
+ Coverage 68.40% 68.42% +0.02%
============================================
Files 108 109 +1
Lines 61562 61662 +100
============================================
+ Hits 42111 42195 +84
- Misses 19451 19467 +16
|
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.
I remember most of this, and it still mostly LGTM.
* Copyright (c) 2024, Kyle Kim <kimkyle at amazon dot com>, Amazon Web Services. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* * Neither the name of Valkey nor the names of its contributors may be used | ||
* to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ |
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.
* Copyright (c) 2024, Kyle Kim <kimkyle at amazon dot com>, Amazon Web Services. | |
* All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions are met: | |
* | |
* * Redistributions of source code must retain the above copyright notice, | |
* this list of conditions and the following disclaimer. | |
* * Redistributions in binary form must reproduce the above copyright | |
* notice, this list of conditions and the following disclaimer in the | |
* documentation and/or other materials provided with the distribution. | |
* * Neither the name of Valkey nor the names of its contributors may be used | |
* to endorse or promote products derived from this software without | |
* specific prior written permission. | |
* | |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
* POSSIBILITY OF SUCH DAMAGE. | |
*/ | |
* | |
* Copyright Valkey contributors. | |
* All rights reserved. | |
* SPDX-License-Identifier: BSD 3-Clause | |
*/ |
We live in the future where you get to write less stuff.
checkSlotAssignment(slots, startslot, endslot); | ||
addReplySlotStats(c, slots); | ||
} else if (!strcasecmp(c->argv[2]->ptr,"orderby") && c->argc >= 4) { | ||
/* CLUSTER SLOT-STATS ORDERBY column [LIMIT limit] [ASC | DESC] */ |
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.
/* CLUSTER SLOT-STATS ORDERBY column [LIMIT limit] [ASC | DESC] */ | |
/* CLUSTER SLOT-STATS ORDERBY metric [LIMIT limit] [ASC | DESC] */ |
Did we really use column before? Seems like the wrong wording for sure.
#include "cluster.h" | ||
#include "cluster_legacy.h" |
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.
What do you need from cluster_legacy.h? We have some vague notion that we want to better abstract away cluster_legacy unless it's dealing with the clusterbus and/or low-level topology.
/* No further arguments. */ | ||
if (c->argc == 2) { | ||
/* CLUSTER SLOT-STATS */ | ||
markAssignedSlots(slots); | ||
addReplySlotStats(c, slots); | ||
return; | ||
} |
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.
Have we ever called this operationally? I feel like we always call it filtered. Maybe we should move away from a foot gun and encourage people to limit the amount of data they pull by deleting the 2 arg form? Not a strong opinion, just something I thought about since I'm taking a fresh look.
#include "cluster_legacy.h" | ||
|
||
#define DEFAULT_SLOT -1 | ||
#define DEFAULT_STAT 0 |
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.
What is this used for?
#include "cluster.h" | ||
#include "cluster_legacy.h" | ||
|
||
#define DEFAULT_SLOT -1 |
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.
What is this used for? Either remove or document it.
@@ -0,0 +1,217 @@ | |||
/* Cluster slots APIs and commands - to retrieve, update and process slot level data |
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.
I remember we named this because we planned to break up the APIs, but we ended up naming it weirdly (what is a "legacy cluster" when there is only one cluster) but it doesn't make a lot of sense to revert it now. I don't mind this in its own file, but maybe we call it cluster_slot_stats instead?
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.