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

Introduce CLUSTER SLOT-STATS command (#20). #351

Open
wants to merge 1 commit into
base: unstable
Choose a base branch
from

Conversation

kyle-yh-kim
Copy link

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 Needs decision by core 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
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.

Copy link

codecov bot commented May 7, 2024

Codecov Report

Attention: Patch coverage is 89.32039% with 11 lines in your changes are missing coverage. Please review.

Project coverage is 68.42%. Comparing base (87a5bfc) to head (e17019b).
Report is 46 commits behind head on unstable.

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     
Files Coverage Δ
src/commands.def 100.00% <ø> (ø)
src/cluster_slots.c 89.32% <89.32%> (ø)

... and 15 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.

Comment on lines +4 to +30
* 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.
*/
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* 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] */
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/* 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.

Comment on lines +33 to +34
#include "cluster.h"
#include "cluster_legacy.h"
Copy link
Member

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.

Comment on lines +153 to +159
/* No further arguments. */
if (c->argc == 2) {
/* CLUSTER SLOT-STATS */
markAssignedSlots(slots);
addReplySlotStats(c, slots);
return;
}
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major-decision-pending Needs decision by core team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants