🎨 Monitor the search performance and suggest solutions Fix https://github.com/siyuan-note/siyuan/issues/7873
This commit is contained in:
parent
813de05019
commit
97c6bb9273
6 changed files with 36 additions and 11 deletions
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1157,6 +1157,7 @@
|
|||
"196": "請勿將工作空間設置在第三方同步盤路徑下,否則數據會被損壞(iCloud/OneDrive/Dropbox/Google Drive/堅果雲/百度網盤/騰訊微雲等)",
|
||||
"197": "目前編輯器正處於只讀模式狀態,如果需要編輯內容,請切換到編輯模式",
|
||||
"198": "這不是一個有效的 Data 壓縮包。如果該數據包是從 [文檔樹] 導出的,請從 [文檔樹] 導入",
|
||||
"199": "這不是一個有效的 .sy.zip 壓縮包。如果該數據包是從 [設置] 中導出的,請從 [設置] 中導入"
|
||||
"199": "這不是一個有效的 .sy.zip 壓縮包。如果該數據包是從 [設置] 中導出的,請從 [設置] 中導入",
|
||||
"200": "全局搜索響應時間較慢,建議將 [設置 - 搜索 - 搜索結果顯示數] 調整為 64 或更小的值,更多建議請參考用戶指南性能優化章節"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 或更小的值,更多建议请参考用户指南性能优化章节"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ package model
|
|||
|
||||
import (
|
||||
"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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue