perf: 降低 lru_cache 上限并限制流式响应块内存占用

- 缩减 model_permissions / tiktoken / formula_engine 的 lru_cache maxsize
- StreamUsageTracker 响应块增加 4MB 大小限制,超限后只计数不存储
- raw_chunks 改用 deque(maxlen=50) 避免无限增长
- HardwareTooltip 导入路径修正、tooltip 延迟归零、文案中文化
This commit is contained in:
fawney19
2026-02-12 11:41:42 +08:00
parent 483d536e2c
commit be430ebdde
5 changed files with 41 additions and 21 deletions

View File

@@ -71,7 +71,7 @@ def _iter_ast_nodes(node: ast.AST) -> Iterable[ast.AST]:
yield from _iter_ast_nodes(child)
@lru_cache(maxsize=2048)
@lru_cache(maxsize=256)
def _validate_expression_cached(expression: str) -> ast.Expression:
"""
Parse + validate an expression and cache the resulting AST.