Skip to content

Conversation

@Explorer09
Copy link
Contributor

@Explorer09 Explorer09 commented Aug 31, 2025

Split the DiskIOMeter into two, DiskIOTimeMeter and DiskIORateMeter, showing the time and the rate separately.

The name DiskIOMeter is retained but now shows the combined view of time and rate, similar to MemorySwapMeter.

This PR depends on #1721, which introduces an isPercentChart property to meters. Note this isPercentChart property is different between sub-meters, and it could explain the reason why the split is worth it.

@BenBE BenBE added the new feature Completely new feature label Sep 1, 2025
@Explorer09 Explorer09 force-pushed the disk-io-meter-split branch 2 times, most recently from 68ccd1f to a718df6 Compare October 10, 2025 05:41
@Explorer09 Explorer09 force-pushed the disk-io-meter-split branch 2 times, most recently from 1b33b9b to 8b5bf63 Compare October 15, 2025 06:50
@Explorer09 Explorer09 force-pushed the disk-io-meter-split branch 3 times, most recently from 26ea738 to eecc641 Compare October 28, 2025 12:33
DiskIOMeter.c Outdated
Comment on lines 165 to 176
if (status == RATESTATUS_NODATA) {
xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "no data");
return;
}
if (status == RATESTATUS_INIT) {
xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "init");
return;
}
if (status == RATESTATUS_STALE) {
xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "stale");
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

Any reason for not using a switch/case like in the function below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's to prevent too much style changes to the original code. Not a big deal to switch to switch-case though. (Pun not intended)

Comment on lines 301 to 322
const MeterClass DiskIOMeter_class = {
.super = {
.extends = Class(Meter),
.delete = Meter_delete,
},
.updateValues = DiskIOMeter_updateValues,
.defaultMode = TEXT_METERMODE,
.supportedModes = METERMODE_DEFAULT_SUPPORTED,
.isMultiColumn = true,
.name = "DiskIO",
.uiName = "Disk IO",
.caption = "Disk IO: "
.description = "Disk IO time & rate combined display",
.caption = "Dsk: ",
.draw = DiskIOMeter_draw,
.init = DiskIOMeter_init,
.updateMode = DiskIOMeter_updateMode,
.done = DiskIOMeter_done
};
Copy link
Member

Choose a reason for hiding this comment

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

Having this moved after the rate-based meter from where it was before introduces quite a bit of noise in this commit. Try to keep the commits minimal without unnecessarily re-ordering code. I had to resort to git lol -p --color-moved --color-moved-ws=allow-indentation-change main... to get at least partially sensible diffs; and those were still PITA to review. ;-)

Similar goes for the MeterClass constants, where putting things in the order DiskIOMeter, DiskIORateMeter, DiskIOTimeMeter would have produced a much shorter/cleaner diff.

Copy link
Contributor Author

@Explorer09 Explorer09 Oct 30, 2025

Choose a reason for hiding this comment

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

I thought DiskIOMeter goes after DiskIORateMeter and DiskIOTimeMeter because the former depends on the functionality of the latter. If that makes the diff messy, I can split the reordering into a separate commit. Will that be acceptable?

Copy link
Member

Choose a reason for hiding this comment

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

I think just having the meter classes in the same order s previously with the new meters added below is fine. Moving code always teds to get messy no matter if you split it or not. So if you can avoid moving code (and here keeping things ordered "Ye Old Way"™ is fine), just keep it that way.

NB: The first 3 commits are fine. Only the last commit may benefit from avoiding to move code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I try to rework the last commit (just now), I realised the problem wasn't on the code reordering, but that you failed to recognize the old DiskIOMeter_ functions was renamed to DiskIOTimeMeter_ functions intentionally.

The "DiskIOMeter" name was kept for compatibility, but the new "DiskIOMeter" in this PR is, actually, entirely new. Users with older htop config files that use the "DiskIOMeter" will new see two bars with the new code.

I'm not sure what's the best way to fix the confusion though. Maybe I could introduce both DiskIORate and DiskIOTime first (DiskIOTimeMeter be mostly duplicate of the old DiskIOMeter code). Then rework DiskIOMeter to the now-seen, final form.

@BenBE
Copy link
Member

BenBE commented Oct 30, 2025

What's currently still open for this PR to become ready?

@Explorer09
Copy link
Contributor Author

What's currently still open for this PR to become ready?

I originally made this PR as a "proof of concept" and to grab early comments about the meters' look and functions.

  • I also intended that DiskIOTimeMeter will include the number of disks in the display, so that the greater-than-100% disk time can be understood without reading more context or manual, however I don't have an idea on how to implement that well. I think I can postpone that part into a separate PR. I just leave a reminder here.

The new function is named DiskIOUpdateCache().
Allows code reuse.

Signed-off-by: Kang-Che Sung <[email protected]>
No changes in behavior.

Signed-off-by: Kang-Che Sung <[email protected]>
@BenBE
Copy link
Member

BenBE commented Oct 30, 2025

Just did a quick check with the design and I think the combined meter should show IO rates left, IO Time used on the right. Else you get quite a big gap with just the percentage shown in text mode.

@Explorer09
Copy link
Contributor Author

Just did a quick check with the design and I think the combined meter should show IO rates left, IO Time used on the right. Else you get quite a big gap with just the percentage shown in text mode.

Makes sense. Perhaps another good reason is that people might look at the I/O rate graph more often than the time/utilisation percentage. (Besides, the I/O rate graph can support two channels while the percentage graph cannot.)

The two meters are split from DiskIOMeter and they allow separate
display of disk read & write rates and the busy time percentage,
including drawing the data as separate bars and graphs.

The old DiskIOMeter is kept for backward compatibility. It will be
reworked in the next commit.

Note that DiskIORateMeter and DiskIOTimeMeter have different
'isPercentChart' values.

Signed-off-by: Kang-Che Sung <[email protected]>
The new meter is a combined display of DiskIORate and DiskIOTime.

The mechanism is similar to MemorySwapMeter.

Signed-off-by: Kang-Che Sung <[email protected]>
@Explorer09 Explorer09 marked this pull request as ready for review October 30, 2025 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature Completely new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants