An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: 改进内核任务调度机制提升稳定性 https://github.com/siyuan-note/siyuan/issues/7113
Liang Dingc130b01f281f
diff --git a/kernel/model/index.go b/kernel/model/index.goindex 080a7a25b2..4c8490ce1f 100644--- a/kernel/model/index.go+++ b/kernel/model/index.go@@ -18,18 +18,21 @@ package modelimport ("fmt"- "github.com/siyuan-note/siyuan/kernel/task"+ "runtime""strings"+ "sync""time""github.com/88250/lute/parse""github.com/dustin/go-humanize""github.com/emirpasic/gods/sets/hashset"+ "github.com/panjf2000/ants/v2""github.com/siyuan-note/eventbus""github.com/siyuan-note/logging""github.com/siyuan-note/siyuan/kernel/cache""github.com/siyuan-note/siyuan/kernel/filesys""github.com/siyuan-note/siyuan/kernel/sql"+ "github.com/siyuan-note/siyuan/kernel/task""github.com/siyuan-note/siyuan/kernel/treenode""github.com/siyuan-note/siyuan/kernel/util")@@ -82,15 +85,20 @@ func index(boxID string) {var treeSize int64i := 0util.PushStatusBar(fmt.Sprintf("["+box.Name+"] "+Conf.Language(64), len(files)))- for _, file := range files {- if file.isdir || !strings.HasSuffix(file.name, ".sy") {- continue- }+ poolSize := runtime.NumCPU()+ if 4 < poolSize {+ poolSize = 4+ }+ waitGroup := &sync.WaitGroup{}+ p, _ := ants.NewPoolWithFunc(poolSize, func(arg interface{}) {+ defer waitGroup.Done()++ file := arg.(*FileInfo)tree, err := filesys.LoadTree(box.ID, file.path, luteEngine)if nil != err {logging.LogErrorf("read box [%s] tree [%s] failed: %s", box.ID, file.path, err)- continue+ return}docIAL := parse.IAL2MapUnEsc(tree.Root.KramdownIAL)@@ -114,7 +122,17 @@ func index(boxID string) {util.PushStatusBar(fmt.Sprintf(Conf.Language(88), i, len(files)-i))}i+++ })+ for _, file := range files {+ if file.isdir || !strings.HasSuffix(file.name, ".sy") {+ continue+ }++ waitGroup.Add(1)+ p.Invoke(file)}+ waitGroup.Wait()+ p.Release()box.UpdateHistoryGenerated() // 初始化历史生成时间为当前时间end := time.Now()