🎨 改进内核任务调度机制提升稳定性 https://github.com/siyuan-note/siyuan/issues/7113

This commit is contained in:
Liang Ding 2023-01-25 11:32:09 +08:00
parent e44bf92c63
commit 1fec9323de
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -103,7 +103,8 @@ func FlushQueue() {
}
context := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
for _, op := range ops {
execOps := 0
for i, op := range ops {
if util.IsExiting {
break
}
@ -131,16 +132,36 @@ func FlushQueue() {
err = upsertRefs(tx, op.upsertTree)
default:
logging.LogErrorf("unknown operation [%s]", op.action)
break
}
op.renameTree = nil
op.upsertTree = nil
execOps++
if nil != err {
logging.LogErrorf("queue operation failed: %s", err)
break
}
}
if 0 < i && 0 == i%64 {
if err = commitTx(tx); nil != err {
logging.LogErrorf("commit tx failed: %s", err)
break
}
execOps = 0
tx, err = beginTx()
if nil != err {
break
}
}
}
if 0 < execOps {
if err = commitTx(tx); nil != err {
logging.LogErrorf("commit tx failed: %s", err)
}
}
elapsed := time.Now().Sub(start).Milliseconds()
if 5000 < elapsed {