Skip to content

Commit

Permalink
Fix spawn too many threads (milvus-io#26293)
Browse files Browse the repository at this point in the history
- Low the thread pool cap
- Limit CGO calls concurrency

Signed-off-by: yah01 <[email protected]>
  • Loading branch information
yah01 authored Aug 11, 2023
1 parent a0198ce commit 48422dd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# The checks defined here will be run and will display by default as warnings.
Checks: >
-*, clang-diagnostic-*, -clang-diagnostic-error,
clang-analyzer-*, -clang-analyzer-alpha*,
clang-analyzer-*,
google-*, -google-runtime-references, -google-readability-todo,
modernize-*, -modernize-use-trailing-return-type, -modernize-use-nodiscard,
performance-*,
Expand Down
6 changes: 3 additions & 3 deletions configs/milvus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,9 @@ common:
entityExpiration: -1 # Entity expiration in seconds, CAUTION make sure entityExpiration >= retentionDuration and -1 means never expire
indexSliceSize: 16 # MB
threadCoreCoefficient:
highPriority: 100 # This parameter specify how many times the number of threads is the number of cores in high priority thread pool
middlePriority: 50 # This parameter specify how many times the number of threads is the number of cores in middle priority thread pool
lowPriority: 10 # This parameter specify how many times the number of threads is the number of cores in low priority thread pool
highPriority: 10 # This parameter specify how many times the number of threads is the number of cores in high priority thread pool
middlePriority: 5 # This parameter specify how many times the number of threads is the number of cores in middle priority thread pool
lowPriority: 1 # This parameter specify how many times the number of threads is the number of cores in low priority thread pool
DiskIndex:
MaxDegree: 56
SearchListSize: 100
Expand Down
6 changes: 3 additions & 3 deletions internal/querynodev2/segments/segment_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ func (loader *segmentLoader) notifyLoadFinish(segments ...*querypb.SegmentLoadIn
func (loader *segmentLoader) requestResource(ctx context.Context, infos ...*querypb.SegmentLoadInfo) (LoadResource, int, error) {
resource := LoadResource{}

loader.mut.Lock()
defer loader.mut.Unlock()

memoryUsage := hardware.GetUsedMemoryCount()
totalMemory := hardware.GetMemoryCount()

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

loader.mut.Lock()
defer loader.mut.Unlock()

poolCap := runtime.NumCPU() * paramtable.Get().CommonCfg.HighPriorityThreadCoreCoefficient.GetAsInt()
if loader.committedResource.WorkNum >= poolCap {
return resource, 0, merr.WrapErrServiceRequestLimitExceeded(int32(poolCap))
Expand Down

0 comments on commit 48422dd

Please sign in to comment.