Retrieve page size by getpagesize() (#23561)

Signed-off-by: yah01 <yang.cen@zilliz.com>
This commit is contained in:
yah01 2023-04-20 12:36:30 +08:00 committed by GitHub
parent 967a97b9bd
commit aa2985490c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,6 +15,7 @@
#include <fmt/core.h>
#include <google/protobuf/text_format.h>
#include <sys/mman.h>
#include <unistd.h>
#include <cstring>
#include <filesystem>
@ -420,10 +421,10 @@ CreateMap(int64_t segment_id,
#ifndef MAP_POPULATE
// Manually access the mapping to populate it
const size_t PAGE_SIZE = 4 << 10; // 4KiB
const size_t page_size = getpagesize();
char* begin = (char*)map;
char* end = begin + written;
for (char* page = begin; page < end; page += PAGE_SIZE) {
for (char* page = begin; page < end; page += page_size) {
char value = page[0];
}
#endif