This is an indication to me that something has gone very wrong in your code base.
This is an indication to me that something has gone very wrong in your code base.
I'm not sure on what planet all of these people here live that they have success with Linux swap. It's been broken for me forever and the first thing I do is disable it everywhere.
echo y >/sys/kernel/mm/lru_gen/enabled(IIRC these options are used like -XX:foo=bar)
(Edit - no, but some do use : instead of = I guess)
TBH this was sloppy on my part. I tested multiple runs of the index build and early on kswapd was super busy. I assumed Linux was just caching recently read parts of the source dataset, but it's also possible it was something external to the index build since it's my daily driver machine. After I turned off swap I had no issues and didn't look into it harder.
Edit: see for instance https://insights.oetiker.ch/linux/fadvise.html
Otherwise, JNA is probably the easiest way, and how Cassandra does it.
https://docs.oracle.com/en/java/javase/21/core/calling-c-lib...
I don't know how Linux does this in particular, but intuitively swapping can make sense if part of your allocated RAM isn't being accessed often and the disk is. The kernel isn't going to know for sure of course, and seems in my case it guessed wrong.
It is much better to swap out anonymous memory that isn't being used than to flush file data that is being used. Or another way of looking at it if you run out of memory you will thrash with or without swap enabled. The difference is that with swap the kernel can evict the most rarely accessed memory whether file-backed or anonymous. Without swap the kernel is forced to only consider file-backed memory, even if it is being used more frequently than the anonymous memory.
I'll let my personal laptop swap, though. Especially if my wife is also logged in and has tons of idle stuff open.
I suspect they just need to pass in -xmx options to the jvm to avoid this.
If you're referring to full GC you can configure how often that happens and by default it doesn't just wait until memory is nearly full.