logoalt Hacker News

torginus • today at 8:11 AM • 1 reply • view on HN

Modern OSes need a facility to signal to a thread that it hit a paged out chunk of memory. It's not like it's not possible to create a swap-aware GC (or any other kind of code that touches lots of memory).

I would go further - I think the whole swap lifecycle needs to be communicated. Before the OS swaps out a page, if it could invoke the GC which would clean up that piece of memory so that we dont end up writing garbage to swap.

The OS should also allow marking pages as piority to stop them from being swapped out.


Replies

aktau • today at 8:40 AM

> The OS should also allow marking pages as piority to stop them from being swapped out.

This is IIUC possible using the mlock(2) family of syscalls: https://man7.org/linux/man-pages/man2/mlock.2.html. (On Linux, though I'm guessing other UNIXen and operating systems have it or something equivalent.)

➕ show 1 reply