mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-14 06:27:07 +02:00
fix linux readahead
This commit is contained in:
parent
895a9a12f5
commit
2425a569e2
1 changed files with 8 additions and 1 deletions
|
|
@ -10,6 +10,7 @@
|
||||||
#include "common/bit_util.h"
|
#include "common/bit_util.h"
|
||||||
#include "common/fs/file.h"
|
#include "common/fs/file.h"
|
||||||
#include "common/fs/fs.h"
|
#include "common/fs/fs.h"
|
||||||
|
#include "common/fs_types.h"
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
#include "common/fs/fs_android.h"
|
#include "common/fs/fs_android.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -301,7 +302,13 @@ static int PlatformMapReadOnly(IOFile& io, const char* path) {
|
||||||
close(io.mmap_fd);
|
close(io.mmap_fd);
|
||||||
io.mmap_fd = -1;
|
io.mmap_fd = -1;
|
||||||
} else {
|
} else {
|
||||||
posix_madvise(io.mmap_base, io.mmap_size, POSIX_MADV_WILLNEED);
|
// For small files it is acceptable to use a full readahead
|
||||||
|
// See https://github.com/torvalds/linux/blob/e80d033851b3bc94c3d254ac66660ddd0a49d72c/include/linux/pagemap.h#L1392
|
||||||
|
if (st.st_size >= 256_MiB) {
|
||||||
|
posix_madvise(io.mmap_base, io.mmap_size, POSIX_MADV_RANDOM);
|
||||||
|
} else {
|
||||||
|
posix_madvise(io.mmap_base, io.mmap_size, POSIX_MADV_SEQUENTIAL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return io.mmap_fd;
|
return io.mmap_fd;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue