mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 改进内核任务调度机制提升稳定性 https://github.com/siyuan-note/siyuan/issues/7113
This commit is contained in:
parent
c40355e47f
commit
2d94fd2b76
4 changed files with 9 additions and 7 deletions
|
|
@ -52,7 +52,7 @@ func main() {
|
||||||
util.PushClearAllMsg()
|
util.PushClearAllMsg()
|
||||||
go model.AutoRefreshCheck()
|
go model.AutoRefreshCheck()
|
||||||
go model.AutoFlushTx()
|
go model.AutoFlushTx()
|
||||||
go sql.AutoFlushQueue()
|
go sql.AutoFlushTx()
|
||||||
go treenode.AutoFlushBlockTree()
|
go treenode.AutoFlushBlockTree()
|
||||||
go cache.LoadAssets()
|
go cache.LoadAssets()
|
||||||
go model.AutoFixIndex()
|
go model.AutoFixIndex()
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ func StartKernel(container, appDir, workspaceBaseDir, timezoneID, localIPs, lang
|
||||||
util.PushClearAllMsg()
|
util.PushClearAllMsg()
|
||||||
go model.AutoRefreshCheck()
|
go model.AutoRefreshCheck()
|
||||||
go model.AutoFlushTx()
|
go model.AutoFlushTx()
|
||||||
go sql.AutoFlushQueue()
|
go sql.AutoFlushTx()
|
||||||
go treenode.AutoFlushBlockTree()
|
go treenode.AutoFlushBlockTree()
|
||||||
go cache.LoadAssets()
|
go cache.LoadAssets()
|
||||||
go model.AutoFixIndex()
|
go model.AutoFixIndex()
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/dustin/go-humanize"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -12,9 +11,11 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/88250/gulu"
|
"github.com/88250/gulu"
|
||||||
|
"github.com/dustin/go-humanize"
|
||||||
"github.com/panjf2000/ants/v2"
|
"github.com/panjf2000/ants/v2"
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
"github.com/siyuan-note/siyuan/kernel/cache"
|
"github.com/siyuan-note/siyuan/kernel/cache"
|
||||||
|
"github.com/siyuan-note/siyuan/kernel/task"
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -24,7 +25,7 @@ func AutoOCRAssets() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
autoOCRAssets()
|
task.AppendTask(task.OCRImage, autoOCRAssets)
|
||||||
time.Sleep(7 * time.Second)
|
time.Sleep(7 * time.Second)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import (
|
||||||
"github.com/emirpasic/gods/sets/hashset"
|
"github.com/emirpasic/gods/sets/hashset"
|
||||||
"github.com/siyuan-note/eventbus"
|
"github.com/siyuan-note/eventbus"
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
|
"github.com/siyuan-note/siyuan/kernel/task"
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -50,10 +51,10 @@ type treeQueueOperation struct {
|
||||||
renameTreeOldHPath string // rename
|
renameTreeOldHPath string // rename
|
||||||
}
|
}
|
||||||
|
|
||||||
func AutoFlushTreeQueue() {
|
func AutoFlushTx() {
|
||||||
for {
|
for {
|
||||||
flushTreeQueue()
|
|
||||||
time.Sleep(util.SQLFlushInterval)
|
time.Sleep(util.SQLFlushInterval)
|
||||||
|
task.PrependTask(task.DatabaseIndex, FlushQueue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,7 +92,7 @@ func ClearQueue() {
|
||||||
operationQueue = nil
|
operationQueue = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func flushTreeQueue() {
|
func FlushQueue() {
|
||||||
ops := mergeUpsertTrees()
|
ops := mergeUpsertTrees()
|
||||||
if 1 > len(ops) {
|
if 1 > len(ops) {
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue