Skip to content

Commit 48422dd

Browse files
authored
Fix spawn too many threads (milvus-io#26293)
- Low the thread pool cap - Limit CGO calls concurrency Signed-off-by: yah01 <[email protected]>
1 parent a0198ce commit 48422dd

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

.clang-tidy

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# The checks defined here will be run and will display by default as warnings.
1919
Checks: >
2020
-*, clang-diagnostic-*, -clang-diagnostic-error,
21-
clang-analyzer-*, -clang-analyzer-alpha*,
21+
clang-analyzer-*,
2222
google-*, -google-runtime-references, -google-readability-todo,
2323
modernize-*, -modernize-use-trailing-return-type, -modernize-use-nodiscard,
2424
performance-*,

configs/milvus.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,9 @@ common:
453453
entityExpiration: -1 # Entity expiration in seconds, CAUTION make sure entityExpiration >= retentionDuration and -1 means never expire
454454
indexSliceSize: 16 # MB
455455
threadCoreCoefficient:
456-
highPriority: 100 # This parameter specify how many times the number of threads is the number of cores in high priority thread pool
457-
middlePriority: 50 # This parameter specify how many times the number of threads is the number of cores in middle priority thread pool
458-
lowPriority: 10 # This parameter specify how many times the number of threads is the number of cores in low priority thread pool
456+
highPriority: 10 # This parameter specify how many times the number of threads is the number of cores in high priority thread pool
457+
middlePriority: 5 # This parameter specify how many times the number of threads is the number of cores in middle priority thread pool
458+
lowPriority: 1 # This parameter specify how many times the number of threads is the number of cores in low priority thread pool
459459
DiskIndex:
460460
MaxDegree: 56
461461
SearchListSize: 100

internal/querynodev2/segments/segment_loader.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ func (loader *segmentLoader) notifyLoadFinish(segments ...*querypb.SegmentLoadIn
301301
func (loader *segmentLoader) requestResource(ctx context.Context, infos ...*querypb.SegmentLoadInfo) (LoadResource, int, error) {
302302
resource := LoadResource{}
303303

304+
loader.mut.Lock()
305+
defer loader.mut.Unlock()
306+
304307
memoryUsage := hardware.GetUsedMemoryCount()
305308
totalMemory := hardware.GetMemoryCount()
306309

@@ -310,9 +313,6 @@ func (loader *segmentLoader) requestResource(ctx context.Context, infos ...*quer
310313
}
311314
diskCap := paramtable.Get().QueryNodeCfg.DiskCapacityLimit.GetAsUint64()
312315

313-
loader.mut.Lock()
314-
defer loader.mut.Unlock()
315-
316316
poolCap := runtime.NumCPU() * paramtable.Get().CommonCfg.HighPriorityThreadCoreCoefficient.GetAsInt()
317317
if loader.committedResource.WorkNum >= poolCap {
318318
return resource, 0, merr.WrapErrServiceRequestLimitExceeded(int32(poolCap))

0 commit comments

Comments
 (0)