Skip to content

Commit

Permalink
⚡ Reduce exit time when sync is enabled siyuan-note/siyuan#13604
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Dec 25, 2024
1 parent 205805f commit d441b99
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ func (repo *Repo) getFullLatest(latest *entity.Index) (ret *FullIndex) {
return
}

for _, f := range ret.Files {
repo.store.cacheFile(f)
}

logging.LogInfof("got local full latest [files=%d, size=%s], cost [%s]", len(ret.Files), humanize.Bytes(uint64(len(data))), time.Since(start))
return
}
Expand Down
4 changes: 4 additions & 0 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,3 +483,7 @@ var indexCache, _ = ristretto.NewCache[string, any](&ristretto.Config[string, an
MaxCost: 1000 * 1000 * 128, // 1 个文件按 300K 字节(大约 1.5W 个文件)计算,128MB 大概可以缓存 400 个索引
BufferItems: 64,
})

func (store *Store) cacheFile(file *entity.File) {
fileCache.Set(file.ID, file, 256 /* 直接使用合理的均值以免进行实际计算消耗性能 */)
}

0 comments on commit d441b99

Please sign in to comment.