From 5e4b2f1788e1d2a1f21fb7cefa79a18679e6a256 Mon Sep 17 00:00:00 2001 From: Anthony Shoumikhin Date: Mon, 16 Jun 2025 11:13:52 -0700 Subject: [PATCH] Use MAP_SHARED to allow sharing memory between processing --- extension/data_loader/mmap_data_loader.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/extension/data_loader/mmap_data_loader.cpp b/extension/data_loader/mmap_data_loader.cpp index 53fd7bdf624..32999930b0a 100644 --- a/extension/data_loader/mmap_data_loader.cpp +++ b/extension/data_loader/mmap_data_loader.cpp @@ -193,14 +193,13 @@ Result 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(range.start)); ET_CHECK_OR_RETURN_ERROR(