From 763fd0dfc59b0552b4bd07ddb5f1a769b3d1e807 Mon Sep 17 00:00:00 2001 From: "yihao.dai" Date: Sun, 15 Sep 2024 16:23:09 +0800 Subject: [PATCH] enhance: Use a separate mmap config for chunk cache (#36276) issue: https://github.com/milvus-io/milvus/issues/35273 Signed-off-by: bigsheeper --- configs/milvus.yaml | 1 + internal/querynodev2/segments/segment.go | 3 ++- internal/querynodev2/server.go | 10 ++++++---- pkg/util/paramtable/component_param.go | 10 ++++++++++ pkg/util/paramtable/component_param_test.go | 2 ++ 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/configs/milvus.yaml b/configs/milvus.yaml index 00037d0958..987c30ecd6 100644 --- a/configs/milvus.yaml +++ b/configs/milvus.yaml @@ -412,6 +412,7 @@ queryNode: vectorIndex: false # Enable mmap for loading vector index scalarField: false # Enable mmap for loading scalar data scalarIndex: false # Enable mmap for loading scalar index + chunkCache: true # Enable mmap for chunk cache (raw vector retrieving). # Enable memory mapping (mmap) to optimize the handling of growing raw data. # By activating this feature, the memory overhead associated with newly added or modified data will be significantly minimized. # However, this optimization may come at the cost of a slight decrease in query latency for the affected data segments. diff --git a/internal/querynodev2/segments/segment.go b/internal/querynodev2/segments/segment.go index a8790a1b54..8d0c3d7ab8 100644 --- a/internal/querynodev2/segments/segment.go +++ b/internal/querynodev2/segments/segment.go @@ -1172,7 +1172,8 @@ func (s *LocalSegment) LoadIndex(ctx context.Context, indexInfo *querypb.FieldIn } // 4. - s.WarmupChunkCache(ctx, indexInfo.GetFieldID(), isDataMmapEnable(fieldSchema)) + mmapChunkCache := paramtable.Get().QueryNodeCfg.MmapChunkCache.GetAsBool() + s.WarmupChunkCache(ctx, indexInfo.GetFieldID(), mmapChunkCache) warmupChunkCacheSpan := tr.RecordSpan() log.Info("Finish loading index", zap.Duration("newLoadIndexInfoSpan", newLoadIndexInfoSpan), diff --git a/internal/querynodev2/server.go b/internal/querynodev2/server.go index 60b81cbae4..19ac5e7a96 100644 --- a/internal/querynodev2/server.go +++ b/internal/querynodev2/server.go @@ -376,8 +376,9 @@ func (node *QueryNode) Start() error { growingmmapEnable := paramtable.Get().QueryNodeCfg.GrowingMmapEnabled.GetAsBool() mmapVectorIndex := paramtable.Get().QueryNodeCfg.MmapVectorIndex.GetAsBool() mmapVectorField := paramtable.Get().QueryNodeCfg.MmapVectorField.GetAsBool() - mmapScarlarIndex := paramtable.Get().QueryNodeCfg.MmapScalarIndex.GetAsBool() - mmapScarlarField := paramtable.Get().QueryNodeCfg.MmapScalarField.GetAsBool() + mmapScalarIndex := paramtable.Get().QueryNodeCfg.MmapScalarIndex.GetAsBool() + mmapScalarField := paramtable.Get().QueryNodeCfg.MmapScalarField.GetAsBool() + mmapChunkCache := paramtable.Get().QueryNodeCfg.MmapChunkCache.GetAsBool() node.UpdateStateCode(commonpb.StateCode_Healthy) @@ -389,8 +390,9 @@ func (node *QueryNode) Start() error { zap.Bool("growingmmapEnable", growingmmapEnable), zap.Bool("mmapVectorIndex", mmapVectorIndex), zap.Bool("mmapVectorField", mmapVectorField), - zap.Bool("mmapScarlarIndex", mmapScarlarIndex), - zap.Bool("mmapScarlarField", mmapScarlarField), + zap.Bool("mmapScalarIndex", mmapScalarIndex), + zap.Bool("mmapScalarField", mmapScalarField), + zap.Bool("mmapChunkCache", mmapChunkCache), ) }) diff --git a/pkg/util/paramtable/component_param.go b/pkg/util/paramtable/component_param.go index 67fa810ca1..70d7f914e2 100644 --- a/pkg/util/paramtable/component_param.go +++ b/pkg/util/paramtable/component_param.go @@ -2337,6 +2337,7 @@ type queryNodeConfig struct { MmapVectorIndex ParamItem `refreshable:"false"` MmapScalarField ParamItem `refreshable:"false"` MmapScalarIndex ParamItem `refreshable:"false"` + MmapChunkCache ParamItem `refreshable:"false"` GrowingMmapEnabled ParamItem `refreshable:"false"` FixedFileSizeForMmapManager ParamItem `refreshable:"false"` MaxMmapDiskPercentageForMmapManager ParamItem `refreshable:"false"` @@ -2663,6 +2664,15 @@ This defaults to true, indicating that Milvus creates temporary index for growin } p.MmapScalarIndex.Init(base.mgr) + p.MmapChunkCache = ParamItem{ + Key: "queryNode.mmap.chunkCache", + Version: "2.4.12", + DefaultValue: "true", + Doc: "Enable mmap for chunk cache (raw vector retrieving).", + Export: true, + } + p.MmapChunkCache.Init(base.mgr) + p.GrowingMmapEnabled = ParamItem{ Key: "queryNode.mmap.growingMmapEnabled", Version: "2.4.6", diff --git a/pkg/util/paramtable/component_param_test.go b/pkg/util/paramtable/component_param_test.go index 165e6697cd..03a7014d67 100644 --- a/pkg/util/paramtable/component_param_test.go +++ b/pkg/util/paramtable/component_param_test.go @@ -454,6 +454,8 @@ func TestComponentParam(t *testing.T) { assert.Equal(t, 4, Params.BloomFilterApplyParallelFactor.GetAsInt()) assert.Equal(t, "/var/lib/milvus/data/mmap", Params.MmapDirPath.GetValue()) + + assert.Equal(t, true, Params.MmapChunkCache.GetAsBool()) }) t.Run("test dataCoordConfig", func(t *testing.T) {