Skip to content

Commit 5ca9876

Browse files
authored
Use MAP_SHARED to allow sharing memory between processing (#11733)
1 parent 7565342 commit 5ca9876

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

extension/data_loader/mmap_data_loader.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,13 @@ Result<FreeableBuffer> MmapDataLoader::load(
193193
map_size = file_size_ - range.start;
194194
}
195195

196-
// Map the pages read-only. MAP_PRIVATE vs. MAP_SHARED doesn't matter since
197-
// the data is read-only, but use PRIVATE just to further avoid accidentally
198-
// modifying the file.
196+
// Map the pages read-only. Use shared mappings so that other processes
197+
// can also map the same pages and share the same memory.
199198
void* pages = ::mmap(
200199
nullptr,
201200
map_size,
202201
PROT_READ,
203-
MAP_PRIVATE,
202+
MAP_SHARED,
204203
fd_,
205204
static_cast<off_t>(range.start));
206205
ET_CHECK_OR_RETURN_ERROR(

0 commit comments

Comments
 (0)