Skip to content

Add --hotkeys-samples option for Valkey-cli #1933

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

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

Conversation

hwware
Copy link
Member

@hwware hwware commented Apr 8, 2025

Now we only have --hotkeys option, and the default output value is 16.
This PR add one more option for hotkeys as "--hotkeys-samples", users have chance to specific how many output items they want.

Example 1:

./src/valkey-cli --hotkeys-samples 10

[00.00%] Hot key '"memtier-3308"' found so far with counter 5
[00.00%] Hot key '"memtier-23516"' found so far with counter 5
[00.00%] Hot key '"memtier-16678"' found so far with counter 5
[00.00%] Hot key '"memtier-25001"' found so far with counter 5
[00.00%] Hot key '"memtier-63829"' found so far with counter 5
[00.00%] Hot key '"memtier-21281"' found so far with counter 5
[00.00%] Hot key '"memtier-81379"' found so far with counter 5
[00.00%] Hot key '"memtier-30335"' found so far with counter 5
[00.00%] Hot key '"memtier-87521"' found so far with counter 5
[00.00%] Hot key '"memtier-42166"' found so far with counter 5

-------- summary -------

Sampled 100000 keys in the keyspace!
hot key found with counter: 5 keyname: "memtier-3308"
hot key found with counter: 5 keyname: "memtier-23516"
hot key found with counter: 5 keyname: "memtier-16678"
hot key found with counter: 5 keyname: "memtier-25001"
hot key found with counter: 5 keyname: "memtier-63829"
hot key found with counter: 5 keyname: "memtier-21281"
hot key found with counter: 5 keyname: "memtier-81379"
hot key found with counter: 5 keyname: "memtier-30335"
hot key found with counter: 5 keyname: "memtier-87521"
hot key found with counter: 5 keyname: "memtier-42166"

Example 2:

./src/valkey-cli --hotkeys-samples 20

[00.00%] Hot key '"memtier-3308"' found so far with counter 5
[00.00%] Hot key '"memtier-23516"' found so far with counter 5
[00.00%] Hot key '"memtier-16678"' found so far with counter 5
[00.00%] Hot key '"memtier-25001"' found so far with counter 5
[00.00%] Hot key '"memtier-63829"' found so far with counter 5
[00.00%] Hot key '"memtier-21281"' found so far with counter 5
[00.00%] Hot key '"memtier-81379"' found so far with counter 5
[00.00%] Hot key '"memtier-30335"' found so far with counter 5
[00.00%] Hot key '"memtier-87521"' found so far with counter 5
[00.00%] Hot key '"memtier-42166"' found so far with counter 5
[00.00%] Hot key '"memtier-6370"' found so far with counter 5
[00.01%] Hot key '"memtier-37381"' found so far with counter 5
[00.01%] Hot key '"memtier-95045"' found so far with counter 5
[00.01%] Hot key '"memtier-14027"' found so far with counter 5
[00.01%] Hot key '"memtier-60370"' found so far with counter 5
[00.01%] Hot key '"memtier-98622"' found so far with counter 5
[00.01%] Hot key '"memtier-18642"' found so far with counter 5
[00.01%] Hot key '"memtier-39260"' found so far with counter 5
[00.01%] Hot key '"memtier-64371"' found so far with counter 5
[00.01%] Hot key '"memtier-27099"' found so far with counter 5

-------- summary -------

Sampled 100000 keys in the keyspace!
hot key found with counter: 5 keyname: "memtier-3308"
hot key found with counter: 5 keyname: "memtier-23516"
hot key found with counter: 5 keyname: "memtier-16678"
hot key found with counter: 5 keyname: "memtier-25001"
hot key found with counter: 5 keyname: "memtier-63829"
hot key found with counter: 5 keyname: "memtier-21281"
hot key found with counter: 5 keyname: "memtier-81379"
hot key found with counter: 5 keyname: "memtier-30335"
hot key found with counter: 5 keyname: "memtier-87521"
hot key found with counter: 5 keyname: "memtier-42166"
hot key found with counter: 5 keyname: "memtier-6370"
hot key found with counter: 5 keyname: "memtier-37381"
hot key found with counter: 5 keyname: "memtier-95045"
hot key found with counter: 5 keyname: "memtier-14027"
hot key found with counter: 5 keyname: "memtier-60370"
hot key found with counter: 5 keyname: "memtier-98622"
hot key found with counter: 5 keyname: "memtier-18642"
hot key found with counter: 5 keyname: "memtier-39260"
hot key found with counter: 5 keyname: "memtier-64371"
hot key found with counter: 5 keyname: "memtier-27099"

@hwware hwware force-pushed the add-hotkeys-samples-options branch from 88addb2 to 34a57b9 Compare April 8, 2025 14:49
@hwware hwware force-pushed the add-hotkeys-samples-options branch from 34a57b9 to 76987a6 Compare April 9, 2025 13:54
Copy link

codecov bot commented Apr 9, 2025

Codecov Report

Attention: Patch coverage is 4.54545% with 21 lines in your changes missing coverage. Please review.

Project coverage is 70.95%. Comparing base (44dafba) to head (76987a6).
Report is 2 commits behind head on unstable.

Files with missing lines Patch % Lines
src/valkey-cli.c 4.54% 21 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #1933      +/-   ##
============================================
- Coverage     70.99%   70.95%   -0.04%     
============================================
  Files           123      123              
  Lines         65769    65786      +17     
============================================
- Hits          46693    46680      -13     
- Misses        19076    19106      +30     
Files with missing lines Coverage Δ
src/valkey-cli.c 55.94% <4.54%> (-0.15%) ⬇️

... and 13 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zuiderkwast
Copy link
Contributor

I'm not sure "samples" is the right name for this. Samples already means how many keys were checked. The output says

Sampled 100000 keys in the keyspace!

Maybe --hotkeys-count?

@PingXie
Copy link
Member

PingXie commented Apr 14, 2025

+1 on "hotkeys-count". Changes LGTM overall. We should add documentation too.

@zuiderkwast zuiderkwast added 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 labels Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
None yet
Development

Successfully merging this pull request may close these issues.

3 participants