|
|
|
@ -7,6 +7,7 @@ |
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "common/assert.h"
|
|
|
|
#include "common/bit_util.h"
|
|
|
|
#include "common/fs/file.h"
|
|
|
|
#include "common/fs/fs.h"
|
|
|
|
#ifdef ANDROID
|
|
|
|
@ -278,13 +279,19 @@ static int PlatformMapReadOnly(IOFile& io, const char* path) { |
|
|
|
// a fun amount of fragmentation on the disk.
|
|
|
|
map_flags |= MAP_NOSYNC; |
|
|
|
#endif
|
|
|
|
#ifdef MAP_ALIGNED_SUPER
|
|
|
|
#if defined(NDEBUG) && defined(MAP_NOCORE)
|
|
|
|
map_flags |= MAP_NOCORE; |
|
|
|
#endif
|
|
|
|
#ifdef MAP_ALIGNED
|
|
|
|
// File must be big enough that it's worth to super align. We can't just super-align every
|
|
|
|
// file otherwise we will run out of alignments for actually important files :)
|
|
|
|
// System doesn't guarantee a super alignment, but if it's available it will delete
|
|
|
|
// about 3 layers(?) of the TLB tree for each read/write.
|
|
|
|
// Again the cost of faults may make this negligible gains, but hey, we gotta work
|
|
|
|
// what we gotta work with.
|
|
|
|
auto const align_log = Common::Log2Ceil64(u64(st.st_size)); |
|
|
|
map_flags |= align_log > 12 ? MAP_ALIGNED(align_log) : 0; |
|
|
|
#elif defined(MAP_ALIGNED_SUPER)
|
|
|
|
using namespace Common::Literals; |
|
|
|
u64 big_file_threshold = 512_MiB; |
|
|
|
map_flags |= u64(st.st_size) >= big_file_threshold ? MAP_ALIGNED_SUPER : 0; |
|
|
|
|