ClementTsang / bottom

Yet another cross-platform graphical process/system monitor.
https://clementtsang.github.io/bottom
MIT License
10.06k stars 239 forks source link

Add option to subtract ARC/ZFS cache from total memory usage #1297

Open Tahinli opened 1 year ago

Tahinli commented 1 year ago

Checklist

What operating system and version are you using?

Linux Mint 21.2 Cinnamon

What architecture are you using?

x86_64 / AMD64

What terminal(s) are you running bottom on?

alacritty

What version of bottom are you running?

0.9.6

How did you install bottom?

Cargo

Describe the issue

I don't know which one is right, but htop and bottom show different ram usages.

Screenshot from 2023-09-11 02-30-56

What is the expected behaviour?

They should be same.

What is the actual behaviour?

They are not same.

How can we reproduce this?

I don't know

Additional information

No response

ClementTsang commented 1 year ago

Hm, in htop, would it be possible for you to enable the Memory [Text] meter?

But yeah that's weird, it looks fine if I bring them both up on my machine, in that the two match fine (btm 0.9.6, htop 3.2.2):

image

I'll take a look though.

ClementTsang commented 1 year ago

Also could you run free -mh, and paste the results? Thanks!

ClementTsang commented 1 year ago

Hm, was just checking around, and noticed that sysinfo just patched a bug around memory retrieval - let me bump the dependency and get a build out.

Tahinli commented 1 year ago

Here text Screenshot from 2023-09-11 02-46-10

here free -mh Screenshot from 2023-09-11 02-47-03

and here linux mint system monitor

Screenshot from 2023-09-11 02-47-20

Tahinli commented 1 year ago

Hm, was just checking around, and noticed that sysinfo just patched a bug around memory retrieval - let me bump the dependency and get a build out.

yeah should be something like this because my computer doesn't make me feel like i'm using 26gb ram lol. I know what kind of programs are working and potentially how much ram should be consumed.

there should be something because even free -mh says I'm using over 20gb

ClementTsang commented 1 year ago

Thanks! And yeah, it... actually looks like btm matches closer to what free and the system monitor report, so I'm not sure if that means htop is calculating things differently here...

I do notice you're running VMs, I wonder if that's causing something weird to happen. But yeah let me get that sysinfo bump out and run a nightly build.

Tahinli commented 1 year ago

Thanks! And yeah, it... actually looks like btm matches closer to what free and the system monitor report, so I'm not sure if that means htop is calculating things differently here...

I do notice you're running VMs, I wonder if that's causing something weird to happen. But yeah let me get that sysinfo bump out and run a nightly build.

btw i closed vm and tried again. still same. and actually even if it running i just gave it to 2gb ram

ClementTsang commented 1 year ago

Thanks, that rules that out at least. Some other questions:

Tahinli commented 1 year ago

I killed vm and took screen shot Screenshot from 2023-09-11 02-59-03

if i'm not wrong, yes i'm using zfs Screenshot from 2023-09-11 03-01-36

ClementTsang commented 1 year ago

Ah, yeah, that explains it - tools like free do not remove the ARC (ZFS cache) usage from total memory usage, while tools like htop do. This matches your above screenshot - in bottom, 19.76 GiB - 15.5 GiB = 4.26 GiB which is about what htop is showing.

If you don't mind, I can turn this report to a feature request to add a config option to allow you to enable/disable this. Wouldn't be too hard... I think.

Tahinli commented 1 year ago

Ah, yeah, that explains it - tools like free do not remove the ARC (ZFS cache) usage from total memory usage, while tools like htop do. This matches your above screenshot - in bottom, 19.76 GiB - 15.5 GiB = 4.26 GiB which is about what htop is showing.

If you don't mind, I can turn this report to a feature request to add a config option to allow you to enable/disable this. Wouldn't be too hard.

yeah sure, actually this makes me happy.

Tahinli commented 1 year ago

but as a question, technically which one is right. included zfs cache or not ?

I mean if countinue to allocate memory with some heavy programs, am i going to be allowed or my system going to crash / kill process

ClementTsang commented 1 year ago

From what I remember (my understanding of ZFS is only rudimentary though!) if memory is needed by the rest of the system then the memory used by the ZFS cache ends up getting reclaimed as needed, so it shouldn't affect your system.

And as for which one is correct, they're... well, kinda both right in this case. It depends what the program creator wants to represent. free/top (and currently, btm) all represent it as part of the usage, while htop chooses to not represent it as they believe that's more accurate. In this case, you could definitely argue for both (hence why I would rather just make it configurable).

jamartin9 commented 1 year ago

I mean if countinue to allocate memory with some heavy programs, am i going to be allowed or my system going to crash / kill process

if memory is needed by the rest of the system then the memory used by the ZFS cache ends up getting reclaimed as needed, so it shouldn't affect your system.

OOM killer may be invoked if ARC does not free memory fast enough. If your workload allocates a lot of RAM quickly (vms/games/etc) some zfs properties like zfs_arc_sys_free/zfs_arc_max/etc should probably be configured.

I am unsure of how the UI will handle the arc max changes if it is done dynamically with respect to the time scrolling...

(htop can also be setup to display ARC meters. Apologizes if this is off topic)

duskmoss commented 4 weeks ago

this would be a nice feature if you get time to work on it :)