Remix.run Logo
▲ debugnik 3 hours ago

Aren't madvise and mincore the APIs you want?

▲masklinn 2 hours ago | parent [-]

Probably more mlock (keep memory area in RAM), mincore just tells you what is or is not in RAM, and madvise is about access patterns.

You could MADV_WILLNEED the GC metadata when you start the GC process hoping they’ll have been paged in by the time you STW, but assuming that area is not massive it’s probably a better idea to just prevent it being paged out.

▲debugnik an hour ago | parent [-]

I was assuming they meant for the heap. Not even executable memory is locked though, so if you mlock too much memory the kernel will page out your executable instead. Something has to give, so it's better to schedule it.

On a lower level, the OCaml and cpython GCs use a prefetch buffer during marking to schedule around the cache.