Przeglądaj źródła

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

Liang Ding 2 lat temu
rodzic
commit
07ad00ec95
2 zmienionych plików z 8 dodań i 4 usunięć
  1. 5 3
      kernel/model/block.go
  2. 3 1
      kernel/sql/queue.go

+ 5 - 3
kernel/model/block.go

@@ -391,11 +391,13 @@ func getBlock(id string) (ret *Block, err error) {
 		return
 	}
 
-	waitForIndexing()
-
 	tree, err := loadTreeByBlockID(id)
 	if nil != err {
-		return
+		waitForIndexing()
+		tree, err = loadTreeByBlockID(id)
+		if nil != err {
+			return
+		}
 	}
 
 	node := treenode.GetNodeInTree(tree, id)

+ 3 - 1
kernel/sql/queue.go

@@ -21,6 +21,7 @@ import (
 	"errors"
 	"fmt"
 	"path"
+	"runtime/debug"
 	"sync"
 	"time"
 
@@ -121,7 +122,7 @@ func FlushQueue() {
 			return
 		}
 
-		if 0 < i && 0 == execOps%64 {
+		if 0 < i && 0 == execOps%128 {
 			if err = commitTx(tx); nil != err {
 				logging.LogErrorf("commit tx failed: %s", err)
 				return
@@ -132,6 +133,7 @@ func FlushQueue() {
 			if nil != err {
 				return
 			}
+			debug.FreeOSMemory()
 		}
 	}