diff --git a/internal/core/src/segcore/SegmentSealedImpl.cpp b/internal/core/src/segcore/SegmentSealedImpl.cpp index c341e456c3..e435ca7eef 100644 --- a/internal/core/src/segcore/SegmentSealedImpl.cpp +++ b/internal/core/src/segcore/SegmentSealedImpl.cpp @@ -152,8 +152,9 @@ SegmentSealedImpl::WarmupChunkCache(const FieldId field_id) { auto field_info = it->second; auto cc = storage::MmapManager::GetInstance().GetChunkCache(); + const bool mmap_rss_not_need = true; for (const auto& data_path : field_info.insert_files) { - auto column = cc->Read(data_path, mmap_descriptor_); + auto column = cc->Read(data_path, mmap_descriptor_, mmap_rss_not_need); } } diff --git a/internal/core/src/storage/ChunkCache.cpp b/internal/core/src/storage/ChunkCache.cpp index c54202f22b..db44cc4b83 100644 --- a/internal/core/src/storage/ChunkCache.cpp +++ b/internal/core/src/storage/ChunkCache.cpp @@ -22,7 +22,8 @@ namespace milvus::storage { std::shared_ptr ChunkCache::Read(const std::string& filepath, - const MmapChunkDescriptorPtr& descriptor) { + const MmapChunkDescriptorPtr& descriptor, + const bool mmap_rss_not_need) { // use rlock to get future { std::shared_lock lck(mutex_); @@ -61,6 +62,22 @@ ChunkCache::Read(const std::string& filepath, try { field_data = DownloadAndDecodeRemoteFile(cm_.get(), filepath); column = Mmap(field_data->GetFieldData(), descriptor); + if (mmap_rss_not_need) { + auto ok = madvise(reinterpret_cast( + const_cast(column->MmappedData())), + column->ByteSize(), + ReadAheadPolicy_Map["dontneed"]); + if (ok != 0) { + LOG_WARN( + "failed to madvise to the data file {}, addr {}, size {}, " + "err: " + "{}", + filepath, + static_cast(column->MmappedData()), + column->ByteSize(), + strerror(errno)); + } + } allocate_success = true; } catch (const SegcoreError& e) { err_code = e.get_error_code(); @@ -110,7 +127,7 @@ ChunkCache::Prefetch(const std::string& filepath) { LOG_WARN( "failed to madvise to the data file {}, addr {}, size {}, err: {}", filepath, - column->MmappedData(), + static_cast(column->MmappedData()), column->ByteSize(), strerror(errno)); } diff --git a/internal/core/src/storage/ChunkCache.h b/internal/core/src/storage/ChunkCache.h index 2af89386fe..91c37b13a1 100644 --- a/internal/core/src/storage/ChunkCache.h +++ b/internal/core/src/storage/ChunkCache.h @@ -45,7 +45,9 @@ class ChunkCache { public: std::shared_ptr - Read(const std::string& filepath, const MmapChunkDescriptorPtr& descriptor); + Read(const std::string& filepath, + const MmapChunkDescriptorPtr& descriptor, + const bool mmap_rss_not_need = false); void Remove(const std::string& filepath);