rtk icon indicating copy to clipboard operation
rtk copied to clipboard

`gain`: add median and concentration to the summary — means alone hide what the tool is actually doing

Open juxtapo9090 opened this issue 3 months ago • 1 comments

The gap

rtk gain reports totals and averages. Command output sizes are long-tailed — a handful of recursive greps and find / runs are orders of magnitude larger than everything else — and on that shape a mean describes almost none of the population.

My install, 10,321 commands over the 90-day window:

reported            587.9M saved   96.5%
median per-command  0.9762x
unchanged           53% of commands, byte-for-byte identical output
above ~7.5k tokens  396 of 10,321 commands

The headline says 96.5%. The median command is compressed by 2.4%, and over half are not modified at all. Both facts are true; only the first is displayed.

Concentration on the same data:

top   1 command  =  69.4% of the reported total
top   5 commands =  90.0%
top   8 commands =  92.1%
top 100 commands =  98.8%

One command is 69% of the lifetime figure. That's worth surfacing in the tool rather than leaving to whoever opens the SQLite file.

Why it matters beyond cosmetics

This isn't only presentation. A mean-only view is, I think, why a larger accounting question on my install went unexamined for so long: with a median of 0.98x printed beside the 96.5%, the gap between them is obvious at a glance and invites the question. Without it, the headline looks like a straightforward win.

It also undersells the tool where it genuinely wins. Those 396 tail commands are where real work happens, and a gain that said "half your commands are untouched, but the 4% that matter get cut hard" would be both more honest and more persuasive.

Suggested addition

Three lines in the summary block:

Median ratio:      0.98x   (53% unchanged)
Concentration:     top 8 commands = 92.1% of total savings
Above ceiling:     396 / 10,321 commands

Environment

rtk 0.45.0, Linux x86-64.

juxtapo9090 avatar Aug 10 '26 01:08 juxtapo9090

wshm · Automated triage by AI

🔍 Automated Triage

✨ Category feature
🟡 Priority medium
🎯 Confidence 88%

Summary

Add median ratio, savings concentration (top-N%), and above-ceiling count to rtk gain summary output, since mean-only reporting on long-tailed data misrepresents typical impact

This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

📁 Relevant files
  • src/gain.rs

Triaged automatically by wshm · This is an automated analysis, not a human review.

pszymkowiak avatar Aug 10 '26 01:08 pszymkowiak