Skip to content

valkey-benchmark: fix non-interactive session output#2801

Closed
rainsupreme wants to merge 1 commit into
valkey-io:unstablefrom
rainsupreme:benchmark-non-interactive
Closed

valkey-benchmark: fix non-interactive session output#2801
rainsupreme wants to merge 1 commit into
valkey-io:unstablefrom
rainsupreme:benchmark-non-interactive

Conversation

@rainsupreme

Copy link
Copy Markdown
Contributor

This fixes output in valkey-benchmark for non-interactive sessions to avoid \r character. This issue was noticed by @zuiderkwast in #2581

@codecov

codecov Bot commented Nov 4, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 46.66667% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.44%. Comparing base (f54818c) to head (1f4cb21).
⚠️ Report is 8 commits behind head on unstable.

Files with missing lines Patch % Lines
src/valkey-benchmark.c 46.66% 8 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #2801      +/-   ##
============================================
+ Coverage     72.30%   72.44%   +0.14%     
============================================
  Files           128      128              
  Lines         70211    70253      +42     
============================================
+ Hits          50763    50898     +135     
+ Misses        19448    19355      -93     
Files with missing lines Coverage Δ
src/valkey-benchmark.c 60.48% <46.66%> (-0.14%) ⬇️

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

Comment thread src/valkey-benchmark.c
hdr_mean(config.current_sec_latency_histogram) / 1000.0f, hdr_mean(config.latency_histogram) / 1000.0f);
config.last_printed_bytes = printed_bytes;
} else {
printf("%s: rps=%.1f (overall: %.1f) avg_msec=%.3f (overall: %.3f)\n", config.title, instantaneous_rps, rps,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have not forgotten this PR. :) The code changes are small, but I wanted to test it locally to see the behaviour. I've done that now.

So instead of overwriting the progress indicator, we print it many times in multiple lines. This is what I get locally when piping the output to cat. We get many lines like this:

$ ./src/valkey-benchmark -n 1000000 -t get -q | cat
GET: rps=0.0 (overall: nan) avg_msec=nan (overall: nan)
GET: rps=284031.9 (overall: 284031.9) avg_msec=0.121 (overall: 0.121)
GET: rps=192940.0 (overall: 238576.9) avg_msec=0.162 (overall: 0.137)
GET: rps=295292.0 (overall: 257456.7) avg_msec=0.122 (overall: 0.131)
GET: rps=244816.0 (overall: 254299.7) avg_msec=0.130 (overall: 0.131)
GET: rps=288032.0 (overall: 261040.8) avg_msec=0.119 (overall: 0.128)
GET: rps=269064.0 (overall: 262377.1) avg_msec=0.127 (overall: 0.128)
GET: rps=295576.0 (overall: 267117.1) avg_msec=0.124 (overall: 0.127)
GET: rps=227880.5 (overall: 262197.8) avg_msec=0.150 (overall: 0.130)
GET: rps=226408.0 (overall: 258224.7) avg_msec=0.142 (overall: 0.131)
GET: rps=256704.0 (overall: 258072.7) avg_msec=0.131 (overall: 0.131)
GET: rps=294444.0 (overall: 261376.8) avg_msec=0.120 (overall: 0.130)
GET: rps=266188.0 (overall: 261777.5) avg_msec=0.133 (overall: 0.130)
GET: rps=162352.0 (overall: 254134.1) avg_msec=0.185 (overall: 0.133)
GET: rps=220988.0 (overall: 251767.8) avg_msec=0.150 (overall: 0.134)
GET: rps=236768.9 (overall: 250764.7) avg_msec=0.141 (overall: 0.134)
GET: 252844.50 requests per second, p50=0.127 msec

I don't think this progress indicator is meaningful in non-interactive mode. I prefer that we don't print it at all. Maybe I'm missing something. Do you have some use case for a non-interactive progress indicator that I'm not aware of?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Anecdotally, I personally use it in scripts to get time series data from valkey-benchmark. I pasted some graphs below for fun. ;) What you describe though is kind of what --csv does. Do you feel there's a need for different behavior?

image Above I noticed that throughput was jumping in an odd way over time when there were io threads due to context switching. (top half is time series, bottom half is histogram) image Above I was testing with and without sleep states and variable/boost frequency. image Above I was testing different cpu pinning strategies.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wow! Beautiful, especially the text version! So you are parsing this output...

What you describe though is kind of what --csv does. Do you feel there's a need for different behavior?

My hypothetical use case is that automated benchmarks can be collected with the same outout as when running interactivly, for example to be posted on github by a bot or so. It's just hypothetical though. I didn't see the time series use case coming.

For machine consumption, wouldn't it be nice to get time series in CSV format? Or not---I suppose the text version is just as easy to parse using a regex so no real need to invent a new format.

Isn't it best to just keep the old tty-unaware code and just let people handle the \r in the output, like you did?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'm happy enough to leave it. It's not difficult to programatically parse the \r, and AIs and humans seem to be able to deal with it, and there's always --csv. I think it could be convenient (but not essential) to add a --json parameter.

I'll cancel the PR then. :)

Signed-off-by: Rain Valentine <rsg000@gmail.com>
@rainsupreme rainsupreme force-pushed the benchmark-non-interactive branch from 1f4cb21 to 9e10c35 Compare November 13, 2025 23:05
@rainsupreme rainsupreme deleted the benchmark-non-interactive branch March 6, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants