From 0e5d2dc87c4d78135280ba083224456d173bd7ce Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 16 Jan 2023 17:25:13 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=A1=8C=E9=9D=A2=E7=AB=AF=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=90=9C=E7=B4=A2=E5=9B=BE=E7=89=87=20OCR=20=E6=96=87?= =?UTF-8?q?=E6=9C=AC=20https://github.com/siyuan-note/siyuan/issues/3470?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/util/ocr.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/util/ocr.go b/kernel/util/ocr.go index 9eef498d5..2fe001f83 100644 --- a/kernel/util/ocr.go +++ b/kernel/util/ocr.go @@ -24,6 +24,7 @@ import ( "os/exec" "path/filepath" "regexp" + "runtime" "runtime/debug" "strings" "sync" @@ -117,8 +118,12 @@ func autoOCRAssets() { assetsPath := GetDataAssetsAbsPath() assets := getUnOCRAssetsAbsPaths() + poolSize := runtime.NumCPU() + if 4 < poolSize { + poolSize = 4 + } waitGroup := &sync.WaitGroup{} - p, _ := ants.NewPoolWithFunc(4, func(arg interface{}) { + p, _ := ants.NewPoolWithFunc(poolSize, func(arg interface{}) { defer waitGroup.Done() assetAbsPath := arg.(string)