Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ absl::Status create_file_and_mmap(const std::string& object_id, size_t size,
return ErrnoToStatus("mmap() failed for file: " + object_id);
}

// On success, set kernel memory hints:
// MADV_WILLNEED: expect access in the near future, so can prefetch
// pages into memory in the background.
// MADV_HUGEPAGE: use huge pages when possible, to minimize TLB misses and
// improve read/write throughput.
madvise(ptr, size, MADV_WILLNEED | MADV_HUGEPAGE);

// On success, set all the output parameters.
out_fd = fd;
out_data_size = size;
Expand Down Expand Up @@ -173,6 +180,13 @@ absl::Status open_file_and_mmap_ro(const std::string& object_id, int& out_fd,
return ErrnoToStatus("mmap() failed for file: " + object_id);
}

// On success, set kernel memory hints:
// MADV_WILLNEED: expect access in the near future, so can prefetch
// pages into memory in the background.
// MADV_HUGEPAGE: use huge pages when possible, to minimize TLB misses and
// improve read throughput.
madvise(ptr, size, MADV_WILLNEED | MADV_HUGEPAGE);

// On success, set all the output parameters.
out_fd = fd;
out_data_size = size;
Expand Down Expand Up @@ -271,4 +285,4 @@ absl::Status unmap_and_close(int fd, void* data_ptr, size_t data_size,
}

} // namespace
// ml_flashpoint::checkpoint_object_manager::buffer_object::internal
// ml_flashpoint::checkpoint_object_manager::buffer_object::internal
Loading