Skip to content

Advise/Prefetch Wrapper #28

@johnpatek

Description

@johnpatek

Hi @johnpatek I've been using mio for a few years to map a 400 GB file that I use as a circular file to simulate a 15-20TB file. Obviously it constantly gets over written but I also read/write randomly, sequentially write 1.5GB chunks. I have looked with envy at the linux madvise() function, large/huge memory pages but I'm basically left with what Windows has had since the 32 era. 64 bit has improved the memory map size but the API has remained pretty basic. The performance of my application is totally at the mercy of the Windows memory manager which is a black box although we have recently got PrefetchVirtualMemory(). Good luck

Originally posted by @spudwa in #15

As discussed in the above issue, it would be helpful to add a method to the mapping that allows Windows and Linux to use PrefetchVirtualMemory and madvise, respectively. There is a huge gap in what the APIs actually offer, but there's enough overlap in what people might use them for that this feature could be worthwhile. A quick and dirty outline of the provisional API could be the following:

enum class advice
{
    will_need
    dont_need,
    access_random,
    access_sequential
};

void advise(void *addr, size_t len, advice adv);

The flags access_* can be ignored for Windows, as PrefetchVirtualMemory is essentially brute force control over paging.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status

Ready

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions