Skip to content

Use MAP_SHARED to allow sharing memory between processing #11733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 3 additions & 4 deletions extension/data_loader/mmap_data_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,13 @@ Result<FreeableBuffer> MmapDataLoader::load(
map_size = file_size_ - range.start;
}

// Map the pages read-only. MAP_PRIVATE vs. MAP_SHARED doesn't matter since
// the data is read-only, but use PRIVATE just to further avoid accidentally
// modifying the file.
// Map the pages read-only. Use shared mappings so that other processes
// can also map the same pages and share the same memory.
void* pages = ::mmap(
nullptr,
map_size,
PROT_READ,
MAP_PRIVATE,
MAP_SHARED,
fd_,
static_cast<off_t>(range.start));
ET_CHECK_OR_RETURN_ERROR(
Expand Down
Loading