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

The only recent memory heh of worrying about ram usage is trying to do stuff on a 1-2gb VPS. For desktop I'm only ever checking top for CPU because why is my fan running? Or something is glitching in a sluggish way.

Caching feels foundational to good UX with Nostr. I bet you're caching a lot of things nobody ever has to think about.

Reply to this note

Please Login to reply.

Discussion

No replies yet.