Support mmap on QueryNodeV2 (#23073)

Signed-off-by: yah01 <yang.cen@zilliz.com>
pull/23082/head
yah01 2023-03-28 21:30:05 +08:00 committed by GitHub
parent d0510210df
commit 826c1fb850
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 4 deletions

View File

@ -643,11 +643,19 @@ func (s *LocalSegment) LoadField(rowCount int64, data *schemapb.FieldData) error
return err
}
var mmapDirPath *C.char = nil
path := paramtable.Get().QueryNodeCfg.MmapDirPath.GetValue()
if len(path) > 0 {
mmapDirPath = C.CString(path)
defer C.free(unsafe.Pointer(mmapDirPath))
}
loadInfo := C.CLoadFieldDataInfo{
field_id: C.int64_t(fieldID),
blob: (*C.uint8_t)(unsafe.Pointer(&dataBlob[0])),
blob_size: C.uint64_t(len(dataBlob)),
row_count: C.int64_t(rowCount),
field_id: C.int64_t(fieldID),
blob: (*C.uint8_t)(unsafe.Pointer(&dataBlob[0])),
blob_size: C.uint64_t(len(dataBlob)),
row_count: C.int64_t(rowCount),
mmap_dir_path: mmapDirPath,
}
status := C.LoadFieldData(s.ptr, loadInfo)

View File

@ -323,6 +323,33 @@ func (suite *SegmentLoaderSuite) TestLoadDeltaLogs() {
}
}
func (suite *SegmentLoaderSuite) TestLoadWithMmap() {
key := paramtable.Get().QueryNodeCfg.MmapDirPath.Key
paramtable.Get().Save(key, "/tmp/mmap-test")
defer paramtable.Get().Reset(key)
ctx := context.Background()
// Load sealed
binlogs, statsLogs, err := SaveBinLog(ctx,
suite.collectionID,
suite.partitionID,
suite.segmentID,
100,
suite.schema,
suite.chunkManager,
)
suite.NoError(err)
_, err = suite.loader.Load(ctx, suite.collectionID, SegmentTypeSealed, 0, &querypb.SegmentLoadInfo{
SegmentID: suite.segmentID,
PartitionID: suite.partitionID,
CollectionID: suite.collectionID,
BinlogPaths: binlogs,
Statslogs: statsLogs,
})
suite.NoError(err)
}
func TestSegmentLoader(t *testing.T) {
suite.Run(t, &SegmentLoaderSuite{})
}

View File

@ -202,6 +202,11 @@ func (node *QueryNode) InitSegcore() {
C.InitCpuNum(cCPUNum)
initcore.InitLocalStorageConfig(paramtable.Get())
mmapDirPath := paramtable.Get().QueryNodeCfg.MmapDirPath.GetValue()
if len(mmapDirPath) > 0 {
log.Info("mmap enabled", zap.String("dir", mmapDirPath))
}
}
// Init function init historical and streaming module to manage segments