Skip to content

Commit 89ac873

Browse files
GregoryComerfacebook-github-bot
authored andcommitted
Default to mmap load mode in module
Summary: We've seen a number of people hit issues with mlock as the default load mode. In particular, mlock will fail above a certain PTE size and may require elevated permissions on some systems. We should not default to using mlock and can leave at as an opt-in optimization. We could use file or mmap mode. I'm leaning towards mmap, as it can lead to lower peak resident memory size, which can be significant for larger models. Differential Revision: D74607072
1 parent d4c9a30 commit 89ac873

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

extension/module/module.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Module {
5353
*/
5454
explicit Module(
5555
const std::string& file_path,
56-
const LoadMode load_mode = LoadMode::MmapUseMlock,
56+
const LoadMode load_mode = LoadMode::Mmap,
5757
std::unique_ptr<runtime::EventTracer> event_tracer = nullptr);
5858

5959
/**
@@ -68,7 +68,7 @@ class Module {
6868
explicit Module(
6969
const std::string& file_path,
7070
const std::string& data_map_path,
71-
const LoadMode load_mode = LoadMode::MmapUseMlock,
71+
const LoadMode load_mode = LoadMode::Mmap,
7272
std::unique_ptr<runtime::EventTracer> event_tracer = nullptr);
7373

7474
/**
@@ -481,7 +481,7 @@ class Module {
481481

482482
std::string file_path_;
483483
std::string data_map_path_;
484-
LoadMode load_mode_{LoadMode::MmapUseMlock};
484+
LoadMode load_mode_{LoadMode::Mmap};
485485
std::shared_ptr<Program> program_;
486486
std::unique_ptr<runtime::DataLoader> data_loader_;
487487
std::unique_ptr<runtime::MemoryAllocator> memory_allocator_;

0 commit comments

Comments
 (0)