Skip to content

Commit

Permalink
Populate the mapping only if MAP_POPULATE is defined (#68)
Browse files Browse the repository at this point in the history
Signed-off-by: yah01 <yah2er0ne@outlook.com>
  • Loading branch information
yah01 authored Sep 11, 2023
1 parent 7667353 commit 5f337f9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion thirdparty/hnswlib/hnswlib/hnswalg.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,11 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {

auto input = knowhere::FileReader(location);
map_size_ = input.size();
map_ = static_cast<char*>(mmap(nullptr, map_size_, PROT_READ, MAP_SHARED | MAP_POPULATE, input.descriptor(), 0));
int map_flags = MAP_SHARED;
#ifdef MAP_POPULATE
map_flags |= MAP_POPULATE;
#endif
map_ = static_cast<char*>(mmap(nullptr, map_size_, PROT_READ, map_flags, input.descriptor(), 0));
madvise(map_, map_size_, MADV_RANDOM);

size_t dim;
Expand Down

0 comments on commit 5f337f9

Please sign in to comment.