Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance: reduce mmap_rss after chunkcache warmup #35974

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
enhance: reduce mmap_rss after chunkcache warmup
Signed-off-by: cqy123456 <qianya.cheng@zilliz.com>
  • Loading branch information
cqy123456 committed Sep 4, 2024
commit f465e3cce2fb6cfac1a10e7bb20d8967fcac3281
8 changes: 6 additions & 2 deletions internal/core/src/segcore/SegmentSealedImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,13 @@
auto field_info = it->second;

auto cc = storage::MmapManager::GetInstance().GetChunkCache();
bool mmap_rss_not_need = true;

Check warning on line 155 in internal/core/src/segcore/SegmentSealedImpl.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/segcore/SegmentSealedImpl.cpp#L155

Added line #L155 was not covered by tests
for (const auto& data_path : field_info.insert_files) {
auto column =
cc->Read(data_path, mmap_descriptor_, field_meta, mmap_enabled);
auto column = cc->Read(data_path,
mmap_descriptor_,

Check warning on line 158 in internal/core/src/segcore/SegmentSealedImpl.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/segcore/SegmentSealedImpl.cpp#L157-L158

Added lines #L157 - L158 were not covered by tests
field_meta,
mmap_enabled,
mmap_rss_not_need);

Check warning on line 161 in internal/core/src/segcore/SegmentSealedImpl.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/segcore/SegmentSealedImpl.cpp#L161

Added line #L161 was not covered by tests
}
}

Expand Down
21 changes: 19 additions & 2 deletions internal/core/src/storage/ChunkCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
ChunkCache::Read(const std::string& filepath,
const MmapChunkDescriptorPtr& descriptor,
const FieldMeta& field_meta,
bool mmap_enabled) {
bool mmap_enabled,
bool mmap_rss_not_need) {
// use rlock to get future
{
std::shared_lock lck(mutex_);
Expand Down Expand Up @@ -64,6 +65,22 @@
field_data = DownloadAndDecodeRemoteFile(cm_.get(), filepath);
column = Mmap(
field_data->GetFieldData(), descriptor, field_meta, mmap_enabled);
if (mmap_enabled && mmap_rss_not_need) {
auto ok = madvise(reinterpret_cast<void*>(
const_cast<char*>(column->MmappedData())),
column->ByteSize(),
ReadAheadPolicy_Map["dontneed"]);
if (ok != 0) {
LOG_WARN(

Check warning on line 74 in internal/core/src/storage/ChunkCache.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/storage/ChunkCache.cpp#L69-L74

Added lines #L69 - L74 were not covered by tests
"failed to madvise to the data file {}, addr {}, size {}, "
"err: "
"{}",
filepath,
static_cast<const void*>(column->MmappedData()),
column->ByteSize(),
strerror(errno));
}
}
allocate_success = true;
} catch (const SegcoreError& e) {
err_code = e.get_error_code();
Expand Down Expand Up @@ -113,7 +130,7 @@
LOG_WARN(
"failed to madvise to the data file {}, addr {}, size {}, err: {}",
filepath,
column->MmappedData(),
static_cast<const void*>(column->MmappedData()),
column->ByteSize(),
strerror(errno));
}
Expand Down
3 changes: 2 additions & 1 deletion internal/core/src/storage/ChunkCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class ChunkCache {
Read(const std::string& filepath,
const MmapChunkDescriptorPtr& descriptor,
const FieldMeta& field_meta,
bool mmap_enabled);
bool mmap_enabled,
bool mmap_rss_not_need = false);

void
Remove(const std::string& filepath);
Expand Down
Loading