Skip to content
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

Meter_humanUnit() rewrite and *IOMeter code improvements #1321

Merged
merged 11 commits into from
Nov 24, 2023

Conversation

Explorer09
Copy link
Contributor

@Explorer09 Explorer09 commented Nov 1, 2023

  1. Rewrite Meter_humanUnit() to make it work with double (floating point) values.
  2. DiskIOMeter and NetworkIOMeter code improvements to work with the new Meter_humanUnit() function. See commit description for details.

pcp/PCPDynamicMeter.c Outdated Show resolved Hide resolved
@Explorer09 Explorer09 changed the title Meter_humanUnit() rewrite and other code quality improvements Meter_humanUnit() rewrite and *IOMeter code improvements Nov 1, 2023
DiskIOMeter.c Outdated Show resolved Hide resolved
NetworkIOMeter.c Outdated Show resolved Hide resolved
@Explorer09 Explorer09 marked this pull request as ready for review November 5, 2023 06:07
NetworkIOMeter.c Outdated Show resolved Hide resolved
XUtils.h Show resolved Hide resolved
@Explorer09 Explorer09 force-pushed the meter-human-unit branch 2 times, most recently from e308f76 to 965b143 Compare November 10, 2023 04:55
DiskIOMeter.c Outdated Show resolved Hide resolved
Meter.c Show resolved Hide resolved
@BenBE BenBE added enhancement Extension or improvement to existing feature code quality ♻️ Code quality enhancement labels Nov 10, 2023
@BenBE BenBE added this to the 3.3.0 milestone Nov 10, 2023
@Explorer09 Explorer09 force-pushed the meter-human-unit branch 3 times, most recently from c70be03 to ebadab8 Compare November 12, 2023 15:39
When `cached_utilisation_diff` is capped, it would never be greater
than `DiskIOMeter.total`.

Signed-off-by: Kang-Che Sung <[email protected]>
Always update the `values` member during the call of
DiskIOMeter_updateValues().

This makes the values of every instance of DiskIOMeter consistent.
The user might see non-zero bars (or graph) during the "stale" status
of the meter after this commit. The side effect is not a bug.

Signed-off-by: Kang-Che Sung <[email protected]>
Always update the `values` member during the call of
NetworkIOMeter_updateValues().

This makes the values of every instance of NetworkIOMeter consistent.
The user might see non-zero bars (or graph) during the "stale" status
of the meter after this commit. The side effect is not a bug.

Signed-off-by: Kang-Che Sung <[email protected]>
Since Meter_humanUnit() is often called with floating point values in
Meter objects, rewrite the function to let it process `double` type
natively, and save floating point to integer casts.

The rewritten function:
* Allows higher orders of magnitude including 'R' and 'Q', and
  addresses infinity. (The previous version has a maximum value of
  (2^64 - 1) representing 16 ZiB.)
* Rounds values when they are in intervals (99.9, 100) and (9.99, 10),
  and displays them with correct precision (number of fraction digits).
* Produces assertion error on negative and NaN values (undefined
  behavior).

Signed-off-by: Kang-Che Sung <[email protected]>
In DiskIOMeter, the number strings of bytes per second are formatted
with Meter_humanUnit(). As the numbers are only updated every 500 ms,
it is good to cache the formatted strings. This saves code size.

Signed-off-by: Kang-Che Sung <[email protected]>
In NetworkIOMeter, the number strings of bytes per second are formatted
with Meter_humanUnit(). As the numbers are only updated every 500 ms,
it is good to cache the formatted strings. This saves code size.

Signed-off-by: Kang-Che Sung <[email protected]>
Improve precisions when drawing in bar meter mode.

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

@natoscott natoscott left a comment

Choose a reason for hiding this comment

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

@Explorer09 @BenBE LGTM, thanks.

Copy link
Member

@BenBE BenBE left a comment

Choose a reason for hiding this comment

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

LGTM.

@BenBE BenBE merged commit 1d3a823 into htop-dev:main Nov 24, 2023
12 checks passed
@Explorer09 Explorer09 deleted the meter-human-unit branch November 24, 2023 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality ♻️ Code quality enhancement enhancement Extension or improvement to existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants