An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Monitor the search performance and suggest solutions Fix https://github.com/siyuan-note/siyuan/issues/7873
Liang Ding97c6bb92733d
diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.jsonindex f81ca111c8..013d3bdbac 100644--- a/app/appearance/langs/en_US.json+++ b/app/appearance/langs/en_US.json@@ -1157,6 +1157,7 @@"196": "Do not set the workspace under the path of a third-party sync disk, otherwise the data will be damaged (iCloud/OneDrive/Dropbox/Google Drive/Nutstore/Baidu Netdisk/Tencent Weiyun, etc.)","197": "Currently the editor is in read-only mode. If you need to edit content, please switch to edit mode","198": "This is not a valid Data archive. If the archive was exported from [Doc tree], please import it from [Doc tree]",- "199": "This is not a valid .sy.zip archive. If the archive was exported from [Settings], please import it from [Settings]"+ "199": "This is not a valid .sy.zip archive. If the archive was exported from [Settings], please import it from [Settings]",+ "200": "The response time of the global search is slow. It is recommended to adjust [Settings - Search - Number of search results displayed] to 64 or a smaller value. For more suggestions, please refer to the performance optimization chapter of the user guide"}}diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.jsonindex ead81d977f..de6f335ec9 100644--- a/app/appearance/langs/es_ES.json+++ b/app/appearance/langs/es_ES.json@@ -1157,6 +1157,7 @@"196": "No configure el espacio de trabajo bajo la ruta de un disco de sincronización de terceros, de lo contrario, los datos se dañarán (iCloud/OneDrive/Dropbox/Google Drive/Nutstore/Baidu Netdisk/Tencent Weiyun, etc.)","197": "Actualmente, el editor se encuentra en modo de solo lectura. Si necesita editar contenido, cambie al modo de edición","198": "Este no es un archivo data.zip válido. Si el archivo se exportó de [Árbol de documentos], importalo de [Árbol de documentos]",- "199": "Este no es un archivo .sy.zip válido. Si el archivo se exportó desde [Configuración], impórtelo desde [Configuración]"+ "199": "Este no es un archivo .sy.zip válido. Si el archivo se exportó desde [Configuración], impórtelo desde [Configuración]",+ "200": "El tiempo de respuesta de la búsqueda global es lento. Se recomienda ajustar [Configuración - Búsqueda - Número de resultados de búsqueda mostrados] a 64 o un valor menor. Para obtener más sugerencias, consulte el capítulo de optimización del rendimiento de la guía del usuario"}}diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.jsonindex 021bce334b..848c239887 100644--- a/app/appearance/langs/fr_FR.json+++ b/app/appearance/langs/fr_FR.json@@ -1157,6 +1157,7 @@"196": "Ne définissez pas l'espace de travail sous le chemin d'un disque de synchronisation tiers, sinon les données seront endommagées (iCloud/OneDrive/Dropbox/Google Drive/Nutstore/Baidu Netdisk/Tencent Weiyun, etc.)","197": "Actuellement, l'éditeur est en mode lecture seule. Si vous devez modifier le contenu, veuillez passer en mode édition","198": "Ceci n'est pas une archive data.zip valide. Si l'archive a été exportée depuis [Doc tree], veuillez l'importer depuis [Doc tree]",- "199": "Ceci n'est pas une archive .sy.zip valide. Si l'archive a été exportée depuis [Paramètres], veuillez l'importer depuis [Paramètres]"+ "199": "Ceci n'est pas une archive .sy.zip valide. Si l'archive a été exportée depuis [Paramètres], veuillez l'importer depuis [Paramètres]",+ "200": "Le temps de réponse de la recherche globale est lent. Il est recommandé d'ajuster [Paramètres - Recherche - Nombre de résultats de recherche affichés] à 64 ou à une valeur inférieure. Pour plus de suggestions, veuillez vous référer au chapitre sur l'optimisation des performances de la notice"}}diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.jsonindex 4f7d8957ec..8c59e099f4 100644--- a/app/appearance/langs/zh_CHT.json+++ b/app/appearance/langs/zh_CHT.json@@ -1157,6 +1157,7 @@"196": "請勿將工作空間設置在第三方同步盤路徑下,否則數據會被損壞(iCloud/OneDrive/Dropbox/Google Drive/堅果雲/百度網盤/騰訊微雲等)","197": "目前編輯器正處於只讀模式狀態,如果需要編輯內容,請切換到編輯模式","198": "這不是一個有效的 Data 壓縮包。如果該數據包是從 [文檔樹] 導出的,請從 [文檔樹] 導入",- "199": "這不是一個有效的 .sy.zip 壓縮包。如果該數據包是從 [設置] 中導出的,請從 [設置] 中導入"+ "199": "這不是一個有效的 .sy.zip 壓縮包。如果該數據包是從 [設置] 中導出的,請從 [設置] 中導入",+ "200": "全局搜索響應時間較慢,建議將 [設置 - 搜索 - 搜索結果顯示數] 調整為 64 或更小的值,更多建議請參考用戶指南性能優化章節"}}diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.jsonindex 1356edc4e7..6e0bad5db6 100644--- a/app/appearance/langs/zh_CN.json+++ b/app/appearance/langs/zh_CN.json@@ -956,6 +956,9 @@"openSource": "访问 GitHub 项目","resetWindow": "重置窗口并退出程序","quit": "退出程序"+ },+ "_performance": {+},"_kernel": {"0": "查询笔记本失败",@@ -1157,6 +1160,7 @@"196": "请勿将工作空间设置在第三方同步盘路径下,否则数据会被损坏(iCloud/OneDrive/Dropbox/Google Drive/坚果云/百度网盘/腾讯微云等)","197": "目前编辑器正处于只读模式状态,如果需要编辑内容,请切换到编辑模式","198": "这不是一个有效的 Data 压缩包。如果该数据包是从 [文档树] 导出的,请从 [文档树] 导入",- "199": "这不是一个有效的 .sy.zip 压缩包。如果该数据包是从 [设置] 中导出的,请从 [设置] 中导入"+ "199": "这不是一个有效的 .sy.zip 压缩包。如果该数据包是从 [设置] 中导出的,请从 [设置] 中导入",+ "200": "全局搜索响应时间较慢,建议将 [设置 - 搜索 - 搜索结果显示数] 调整为 64 或更小的值,更多建议请参考用户指南性能优化章节"}}diff --git a/kernel/model/session.go b/kernel/model/session.goindex fdf0c2858d..66a5351a1c 100644--- a/kernel/model/session.go+++ b/kernel/model/session.go@@ -18,6 +18,8 @@ package modelimport ("net/http"+ "os"+ "strconv""strings""time"@@ -232,18 +234,33 @@ func CheckAuth(c *gin.Context) {c.Next()}-var timingAPIs = map[string]bool{- "/api/search": true,+var timingAPIs = map[string]int{+ "/api/search/fullTextSearchBlock": 200, // Monitor the search performance and suggest solutions https://github.com/siyuan-note/siyuan/issues/7873}func Timing(c *gin.Context) {+ p := c.Request.URL.Path+ tip, ok := timingAPIs[p]+ if !ok {+ c.Next()+ return+ }++ timing := 15 * 1000+ if timingEnv := os.Getenv("SIYUAN_PERFORMANCE_TIMING"); "" != timingEnv {+ val, err := strconv.Atoi(timingEnv)+ if nil == err {+ timing = val+ }+ }now := time.Now().UnixMilli()c.Next()- elapsed := time.Now().UnixMilli() - now- //if 000 < elapsed {- logging.LogInfof("[%s] elapsed [%dms]", c.Request.RequestURI, elapsed)- //}+ elapsed := int(time.Now().UnixMilli() - now)+ if timing < elapsed {+ logging.LogWarnf("[%s] elapsed [%dms]", c.Request.RequestURI, elapsed)+ util.PushMsg(Conf.Language(tip), 7000)+ }}func Recover(c *gin.Context) {