Skip to content

Commit

Permalink
enhance: Use a separate mmap config for chunk cache (#36276)
Browse files Browse the repository at this point in the history
issue: #35273

Signed-off-by: bigsheeper <[email protected]>
  • Loading branch information
bigsheeper authored Sep 15, 2024
1 parent 517f8b3 commit 763fd0d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions configs/milvus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion internal/querynodev2/segments/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
10 changes: 6 additions & 4 deletions internal/querynodev2/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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),
)
})

Expand Down
10 changes: 10 additions & 0 deletions pkg/util/paramtable/component_param.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions pkg/util/paramtable/component_param_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 763fd0d

Please sign in to comment.