alignment with log2
This commit is contained in:
parent
9068e1f5d3
commit
90c3e25afd
|
|
@ -7,6 +7,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.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"
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
|
|
@ -278,13 +279,19 @@ static int PlatformMapReadOnly(IOFile& io, const char* path) {
|
||||||
// a fun amount of fragmentation on the disk.
|
// a fun amount of fragmentation on the disk.
|
||||||
map_flags |= MAP_NOSYNC;
|
map_flags |= MAP_NOSYNC;
|
||||||
#endif
|
#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 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 :)
|
// 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
|
// 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.
|
// 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
|
// Again the cost of faults may make this negligible gains, but hey, we gotta work
|
||||||
// what we gotta work with.
|
// 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;
|
using namespace Common::Literals;
|
||||||
u64 big_file_threshold = 512_MiB;
|
u64 big_file_threshold = 512_MiB;
|
||||||
map_flags |= u64(st.st_size) >= big_file_threshold ? MAP_ALIGNED_SUPER : 0;
|
map_flags |= u64(st.st_size) >= big_file_threshold ? MAP_ALIGNED_SUPER : 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue