An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:zap: 改进数据量较大时的启动速度 https://github.com/siyuan-note/siyuan/issues/6574
Liang Dingcdf2b796782a
diff --git a/kernel/conf/stat.go b/kernel/conf/stat.goindex 55778ab5c0..29825026c8 100644--- a/kernel/conf/stat.go+++ b/kernel/conf/stat.go@@ -23,6 +23,8 @@ type Stat struct {CBlockCount int `json:"cBlockCount"`DataSize int64 `json:"dataSize"`CDataSize int64 `json:"cDataSize"`+ AssetsSize int64 `json:"assetsSize"`+ CAssetsSize int64 `json:"cAssetsSize"`}func NewStat() *Stat {diff --git a/kernel/model/box.go b/kernel/model/box.goindex 173d2e2bbd..f37a44878c 100644--- a/kernel/model/box.go+++ b/kernel/model/box.go@@ -26,11 +26,13 @@ import ("path/filepath""sort""strings"+ "sync""time""github.com/88250/gulu""github.com/88250/lute/ast""github.com/88250/lute/parse"+ "github.com/dustin/go-humanize""github.com/facette/natsort""github.com/siyuan-note/filelock""github.com/siyuan-note/logging"@@ -52,20 +54,29 @@ type Box struct {}func AutoStat() {+ time.Sleep(time.Minute)autoStat()- for range time.Tick(10 * time.Minute) {+ for range time.Tick(2 * time.Hour) {autoStat()}}+var statLock = sync.Mutex{}+func autoStat() {+ statLock.Lock()+ defer statLock.Unlock()+Conf.Stat.TreeCount = treenode.CountTrees()Conf.Stat.CTreeCount = treenode.CeilCount(Conf.Stat.TreeCount)Conf.Stat.BlockCount = treenode.CountBlocks()Conf.Stat.CBlockCount = treenode.CeilCount(Conf.Stat.BlockCount)- Conf.Stat.DataSize, _ = util.SizeOfDirectory(util.DataDir)+ Conf.Stat.DataSize, Conf.Stat.AssetsSize = util.DataSize()Conf.Stat.CDataSize = util.CeilSize(Conf.Stat.DataSize)+ Conf.Stat.CAssetsSize = util.CeilSize(Conf.Stat.AssetsSize)Conf.Save()++ logging.LogInfof("auto stat [trees=%d, blocks=%d, dataSize=%s, assetsSize=%s]", Conf.Stat.TreeCount, Conf.Stat.BlockCount, humanize.Bytes(uint64(Conf.Stat.DataSize)), humanize.Bytes(uint64(Conf.Stat.AssetsSize)))}func ListNotebooks() (ret []*Box, err error) {diff --git a/kernel/util/file.go b/kernel/util/file.goindex c1d7886925..f40c1eab45 100644--- a/kernel/util/file.go+++ b/kernel/util/file.go@@ -17,6 +17,7 @@package utilimport (+ "io""os""path""path/filepath"@@ -194,6 +195,27 @@ func SizeOfDirectory(path string) (size int64, err error) {return}+func DataSize() (dataSize, assetsSize int64) {+ filepath.Walk(DataDir, func(path string, info os.FileInfo, err error) error {+ if nil != err {+ logging.LogErrorf("size of data failed: %s", err)+ return io.EOF+ }+ if !info.IsDir() {+ s := info.Size()+ dataSize += s++ if strings.Contains(strings.TrimPrefix(path, DataDir), "assets") {+ assetsSize += s+ }+ } else {+ dataSize += 4096+ }+ return nil+ })+ return+}+func CeilSize(size int64) int64 {if 100*1024*1024 > size {return 100 * 1024 * 1024diff --git a/kernel/util/runtime.go b/kernel/util/runtime.goindex e9de5cdc90..412bc0ff63 100644--- a/kernel/util/runtime.go+++ b/kernel/util/runtime.go@@ -25,7 +25,6 @@ import ("github.com/88250/gulu""github.com/denisbrodbeck/machineid"- "github.com/dustin/go-humanize""github.com/siyuan-note/logging")@@ -41,9 +40,6 @@ const ()func logBootInfo() {- s, _ := SizeOfDirectory(DataDir)- dataDirSize := humanize.Bytes(uint64(s))-logging.LogInfof("kernel is booting:\n"+" * ver [%s]\n"+" * arch [%s]\n"+@@ -53,8 +49,8 @@ func logBootInfo() {" * read only [%v]\n"+" * container [%s]\n"+" * database [ver=%s]\n"+- " * workspace directory [%s, data %s]",- Ver, runtime.GOARCH, os.Getpid(), Mode, WorkingDir, ReadOnly, Container, DatabaseVer, WorkspaceDir, dataDirSize)+ " * workspace directory [%s]",+ Ver, runtime.GOARCH, os.Getpid(), Mode, WorkingDir, ReadOnly, Container, DatabaseVer, WorkspaceDir)}func IsMutexLocked(m *sync.Mutex) bool {