Skip to content

Conversation

@Explorer09
Copy link
Contributor

@Explorer09 Explorer09 commented Aug 31, 2025

htop-screenshot-diskio-display

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 (merged), 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 feature request Completely new feature requested 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
@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

Explorer09 commented Oct 30, 2025

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. (Update: This one is done in the new revision.)

@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.)

@Explorer09 Explorer09 marked this pull request as ready for review October 30, 2025 20:15
@Explorer09
Copy link
Contributor Author

@BenBE On the topic of avoiding double assignment in code style, I found there are three other files that had this "double assignment" syntax when initializing data. Not sure if you want these to be changed as well, but I'm reluctant to file a new PR for this minor style change:

--- a/CPUMeter.c
+++ b/CPUMeter.c
@@ -241,9 +241,10 @@ static void CPUMeterCommonInit(Meter* this) {
 
    CPUMeterData* data = this->meterData;
    if (!data) {
-      data = this->meterData = xMalloc(sizeof(CPUMeterData));
+      data = xMalloc(sizeof(CPUMeterData));
       data->cpus = this->host->existingCPUs;
       data->meters = count ? xCalloc(count, sizeof(Meter*)) : NULL;
+      this->meterData = data;
    }
 
    Meter** meters = data->meters;
--- a/Machine.c
+++ b/Machine.c
@@ -79,9 +79,11 @@ void Machine_populateTablesFromSettings(Machine* this, Settings* settings, Table
 
    for (size_t i = 0; i < settings->nScreens; i++) {
       ScreenSettings* ss = settings->screens[i];
+
+      if (!ss->table)
+         ss->table = processTable;
+
       Table* table = ss->table;
-      if (!table)
-         table = ss->table = processTable;
       if (i == 0)
          this->activeTable = table;
 
--- a/MemorySwapMeter.c
+++ b/MemorySwapMeter.c
@@ -47,11 +47,10 @@ static void MemorySwapMeter_draw(Meter* this, int x, int y, int w) {
 }
 
 static void MemorySwapMeter_init(Meter* this) {
-   MemorySwapMeterData* data = this->meterData;
+   if (!this->meterData)
+      this->meterData = xCalloc(1, sizeof(MemorySwapMeterData));
 
-   if (!data) {
-      data = this->meterData = xCalloc(1, sizeof(MemorySwapMeterData));
-   }
+   MemorySwapMeterData* data = this->meterData;
 
    if (!data->memoryMeter)
       data->memoryMeter = Meter_new(this->host, 0, (const MeterClass*) Class(MemoryMeter));

BenBE added a commit that referenced this pull request Nov 2, 2025
Based on a patch in #1763 (comment)

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

BenBE commented Nov 2, 2025

@Explorer09 Patch applied on main with slight modifications.

@Explorer09 Explorer09 marked this pull request as draft November 4, 2025 20:58
@Explorer09 Explorer09 marked this pull request as ready for review November 7, 2025 22:23

char buffer[16];

int color = cached_utilisation_diff > 40.0 ? METER_VALUE_NOTICE : METER_VALUE;
Copy link
Member

Choose a reason for hiding this comment

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

Where does the 40% come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

e518459 I would let @cgzones answer this.

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

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

Signed-off-by: Kang-Che Sung <[email protected]>
@Explorer09 Explorer09 force-pushed the disk-io-meter-split branch 2 times, most recently from a8cb854 to 1509583 Compare November 9, 2025 21:05
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 combination works similarly to MemorySwapMeter.

Signed-off-by: Kang-Che Sung <[email protected]>
@BenBE BenBE merged commit bcf54eb into htop-dev:main Nov 12, 2025
19 checks passed
@BenBE BenBE added this to the 3.5.0 milestone Nov 12, 2025
@Explorer09 Explorer09 deleted the disk-io-meter-split branch November 12, 2025 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request Completely new feature requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants