-
-
Notifications
You must be signed in to change notification settings - Fork 441
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
Introduce "single value" model for monochrome graph #928
base: main
Are you sure you want to change the base?
Conversation
06d0603
to
2336133
Compare
CPUMeter.c
Outdated
@@ -69,9 +69,12 @@ static void CPUMeter_updateValues(Meter* this) { | |||
double percent = Platform_setCPUValues(this, cpu); | |||
if (isnan(percent)) { | |||
xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "offline"); | |||
this->single_value = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe better to omit this sanitisation? Not sure about it. Platforms that intentionally return NAN
also set curItems
to 0, so the graph should correctly show 0.
We must always update single_value
though (if we ever do), so the alternative would be to always set this->single_value = percent;
before the if
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If unused I think NAN should be preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way we indicate "we have a single value and it's zero", so it will be used.
The other way we put NAN in there and that indicates "we have no single value", in which case Meter will sum curItems
entries, and that should be zero, so also producing zero.
This is also justified by htop's FAQ:
The monochrome graph should be graphing the same "more meaningful metric", not just a wall of 90%. (Although htop is now showing something less meaningful than it was when that FAQ was written, due to the separation of shared memory, but that's being addressed in #913). If/when there is a coloured time graph as in #714, that would be graphing the stack of |
I have no idea what you are doing here. It looks like I would prefer these implemented |
I thought I'd managed to explain it to you in the previous discussion! Once more for luck - as the htop FAQ says, simply adding together all the memory regions does not give a very useful number. On any machine with limited RAM you just tend to see usage stuck up at 90% continuously because of the cache - only dropping when you quit a program, then it just climbs back up again. You just get a graph of "when did I quit something" dips. Increases are often just cache inflation, not increased usage. Showing just "used" (and "shared") is a more useful metric.
"Instead"? Certainly it could be a tweakable option - graph either the sum of all bars, or the more meaningful metric as shown in the bar label - but you'd still need to pass the value from the The other alternative I considered (and discarded rapidly) was to add a return value to the I haven't reviewed which other meters would benefit from using it. I think Linux swap could, at least - its "cached" is similarly not really in use. Edit: |
2336133
to
882ca4d
Compare
That's why I proposed the color graph (#714) in the first place. Even for cache size changes, it's still worth plotting in the graph when they are colored. And I've intended the color graph be a generic solution to all meters. How your solution would benefit after the color graph solution is my main question to ask. |
I don't understand why you seem to think this isn't generic. It's totally generic. It's just that the default behaviour is to use the sum of the values - only meters that want something different need to override it. Any meter can override it if they want. This patch makes the meters more uniform in that the bar text label of all 3 updated meters is now displaying I guess we could update all meters to provide The coloured graph is indeed a solution to the same problem, but it's putting the onus on the user, getting them to interpret a different visualisation to interpret richer data. I'd expect it to be a tweakable mode, either per-meter or globally, so there would still be simple graphs, and they would continue to use the My previous suggestion, of an alternate item count, would offer the possibility of a third graph mode where it's coloured but omits caches, but this version doesn't. It's assuming at most two modes: "simple-omitting-caches" or "stacked-including-caches". And those two modes are consistent with the original (or at least long-term) design of htop's bars - this combination of coloured stacked info for detailed inspection, and the simple "meaningful metric" on the text label. To have only one of those graphable is an omission. Adding the coloured graph is strongly consistent with the design. To remove the simple graph would be to regress again. There should be history graphs of both things that are displayed instantaneously in the bar. |
And I consider this a bad OO (object-oriented) design practice. Introducing a class member where not all instances would specialize its value. It should be a sub-class instead, so that polymorphism and dynamic dispatch can work. There are meters in htop that never provide numeric values: HostnameMeter, SysArchMeter and (most importantly) BlankMeter.
You still need to format the
That would make things more complicated than necessary. For meters that have one value only (Load Average, Uptime), introducing For what I've seen. the only benefit for |
Yes, just like the If you want to complain about the class hierarchy of htop, I'm not the person to be talking to, and this is not the PR for it.
The colour graph is not currently part of the codebase. And I'd very much not want simple graphs to be removed as an option. (I think your proposed patch does, but if it went in as is, I'd re-add a per-meter or global option for them). |
c6539b2
to
f24025e
Compare
Rebased. |
I have one more comment on this PR. I'm not sure if |
Yes, I don't like I'd be okay with That even ties in the words "summary" and "sum". A summary could well be the sum, and that's what we do by default, but it can be something else, specified in summaryValue. |
The text labels for CPU, memory and swap go to the trouble of figuring out a subset of the values to sum, for a single-value summary display. But the monochrome graph simply summed all `curItems` values. This is less sophisticated than the label behaviour. Add a `Meter::summaryValue` member that can be used to output a meter's custom summary value, and make the graph display use it instead of its own "all-bars" sum where available. Implement this in `MemoryMeter`, `SwapMeter` and `CPUMeter`. This has the effect of making a monochrome memory graph not show cached memory, so will not be permanently at the top when the cache is heavily used, and the CPU graph will obey the `account_guest_in_cpu_meter` setting. In both cases, the graph becomes consistent with the text label of the bar.
Here's a version with |
The text labels for CPU and memory go to the trouble of figuring out a subset of the values to sum, for a single-value display.
But the monochrome graph simply summed all
curItems
values. This is less sophisticated than the label behaviour.Add a
Meter::single_value
member that can be used to output a meter's single-value sum, and make the graph display use it instead of its own "all-bars" sum where available.Implement this in
MemoryMeter
,SwapMeter
andCPUMeter
.This has the effect of making a memory graph not show cached memory, so will not be permanently at the top when the cache is heavily used, and the CPU graph will obey the
account_guest_in_cpu_meter
setting. In both cases, the graph becomes consistent with the text label of the bar.This follows discussion on #913 - it's what I was thinking of as
curSumItems
there. If/when #913 is implemented,single_value
would becomevalues[MEMORY_USED] + values[MEMORY_SHARED]
.There are possibly other meters and/or displays that could use
single_value
.