Bug #3330



Added by about 1 year ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


Hello. I just want to offload a few ideas about swapping.

First of all, nowadays if you are running off HDD you can consume memory faster then swapout will free it. This means that memory allocation throttling will be kicking in almost all of the time when you are trying to do some memory internsive stuff. The more cores the merrier, average compiler (GCC or CLANG) can easily use up to 2G of RAM reading minimum amount of files, memory will be going out in no time.

This can be partially mitigated by tweaking this:


I just upped them 10x and now swapping out starts before and continues after the lowmem, so throttling happens not that often. Proper way to do that might be autosizing them to _start being 10% of RAM and others accordingly.

Second, vm.v_paging_wait. I see an opportunity here. Right now it's same for all processes, but it can be improved by making it default to 1% RAM + (process priority * 0.01% RAM). This means that processes with higher nice or rtprio values in tough situations would be able to get memory first, and lower priority processes will be throttled more.

Third one. On HDDs swap write and read are showing numbers that differ by a magnitude. Swapout can be up to 40Mb/s or even higher, and swapin is almost always under 2Mb/s. If any huge process was pushed out of RAM it can take minutes to get it back. I think this is because swapin gets individual pages from the drive. Even the oldest HDDs do have a prefetch cache, that works by reading to cache all pages in cylinder before requested page is found. It works pretty nice most of the time, except for swapping, probably random access pattern generates too much prefetch data overwriting everything we might want to read after. This can be partially solved by reading not only the page requested from swap, but rather reading minimum 64k from drive if we are not paging out data. Might improve reading huge processes from swap, probably...

Thanks for your attention! Hope this ideas are really worthy.

No data to display


Also available in: Atom PDF