Replying to Avatar jb55

its kind of frustrating that operating systems don't show the actual memory usage of applications properly

right now linux is reporting that notedeck is using 1.8GB of memory, but thats misleading because its counting memory mmap'd in nostrdb. I had to write a script to see the "actual" memory usage:

$ smaps $(pgrep notedeck)

> Total RSS: 1840.65 MiB

> Claimable (file-backed, clean pages): 1317.52 MiB

> Effective memory usage (RSS - claimable): 523.12 MiB

its using 1.3g of page cache memory, but that gets immediately reclaimed by other apps that actually need it. its really only using 500MiB, which is still pretty high, but not as bad as 2GB.

the way mmap works is that you give it a file on disk, and the operating system gives back a pointer that looks like its somewhere in your system memory (RAM). its not a physical address, its a virtual one managed by the OS.

anytime you read from this pointer, it will read in data from disk and store it in the page cache, so to the programmer it looks like you're just accessing memory but its actually data on disk thats cached in memory.

so naturally when you scroll through a million notes, all of this data will get loaded into the page cache, and it looks like notedeck is using 8GB of memory, but in reality its just the operating system that has loaded the entire database into memory for performance. but this memory is *reclaimable* by other processes, so it doesn't have any impact on your system.

the end result: confused users, people removing the app thinking its a memory hog. le sigh.

anyways.... sorry for this long winded sunday morning rant about virtual memory.

gm #nostr

In a sense, you might be right, but I think it's still better that they show the total memory you use. People are trying to see if they have enough memory to run all their apps full speed. Yes, your OS might be allocating more memory to notedeck to run it faster, but that's the performance that most people are trying to measure for.

Personally I would not like it if the OS said I had plenty of free memory left, when in reality, some of my apps would run much faster if I had more.

Notedeck takes 2GBs to run smoothly without reading notes off the hard drive every time. I'd rather know that than to see it slow down without explanation.

The end of this discussion leads to acknowledging that memory isn't a binary "enough" or "not enough". Maybe the solution is for task managers to show levels of memory usage. Like having 3 numbers for each app, one for how much it needs (500MB), one for how much it's actually using (1.8GB), and one for how much it would benefit from having (potentially over the previous figure if you are memory limited).

Reply to this note

Please Login to reply.

Discussion

No replies yet.