Skip to content

fix(symbol_ref_tool): 修复符号搜索性能灾难及文本往返反模式 (#132)#137

Merged
SunYanbox merged 1 commit intodevelopfrom
fix/132-symbol_ref_tool-performance-catastrophe-text-round-trip-anti-pattern-symbol_ref_tool
May 4, 2026
Merged

fix(symbol_ref_tool): 修复符号搜索性能灾难及文本往返反模式 (#132)#137
SunYanbox merged 1 commit intodevelopfrom
fix/132-symbol_ref_tool-performance-catastrophe-text-round-trip-anti-pattern-symbol_ref_tool

Conversation

@SunYanbox
Copy link
Copy Markdown
Owner

  • 修复问题: 消除多模式搜索导致的文件系统重复遍历与 I/O 瓶颈
    • 移除 _search_single_pattern_search_patterns_concurrent,引入 _search_all_patterns 实现单次文件遍历匹配所有正则
    • 调用 Workspace.search_content_multi_pattern API 替代旧版 search_content,避免 N 次 (N=模式数量) 重复打开文件
    • 优化 _build_results_with_context 逻辑,按需读取文件行缓存而非全量加载,解决大文件内存溢出风险
  • 重构优化: 修正上下文行获取逻辑与数据格式处理
    • 将匹配结果从非结构化文本字符串解析重构为原生 list[dict] 数据结构,消除“格式化→正则解析”的反模式
    • 修复上下文行计算逻辑,支持精确获取匹配行前后指定行数 (context_lines) 的原始内容
    • 增加正则预编译与无效模式过滤机制,提升搜索执行效率
  • 破坏性变更: 底层搜索接口返回结构变更
    • symbol_ref_tool 不再依赖 Workspace.search_content 的格式化字符串输出,转而使用 search_content_multi_pattern 的结构化字典列表
    • 移除了对 [文件] path\n----\n 文本格式的解析代码,下游需适配新的 file, line_num, content, pattern_type 字段

- 修复问题: 消除多模式搜索导致的文件系统重复遍历与 I/O 瓶颈
  * 移除 `_search_single_pattern` 和 `_search_patterns_concurrent`,引入 `_search_all_patterns` 实现单次文件遍历匹配所有正则
  * 调用 `Workspace.search_content_multi_pattern` API 替代旧版 `search_content`,避免 N 次 (N=模式数量) 重复打开文件
  * 优化 `_build_results_with_context` 逻辑,按需读取文件行缓存而非全量加载,解决大文件内存溢出风险
- 重构优化: 修正上下文行获取逻辑与数据格式处理
  * 将匹配结果从非结构化文本字符串解析重构为原生 `list[dict]` 数据结构,消除“格式化→正则解析”的反模式
  * 修复上下文行计算逻辑,支持精确获取匹配行前后指定行数 (`context_lines`) 的原始内容
  * 增加正则预编译与无效模式过滤机制,提升搜索执行效率
- 破坏性变更: 底层搜索接口返回结构变更
  * `symbol_ref_tool` 不再依赖 `Workspace.search_content` 的格式化字符串输出,转而使用 `search_content_multi_pattern` 的结构化字典列表
  * 移除了对 `[文件] path\n----\n` 文本格式的解析代码,下游需适配新的 `file`, `line_num`, `content`, `pattern_type` 字段
@SunYanbox SunYanbox added the bug Something isn't working label May 4, 2026
@SunYanbox SunYanbox merged commit d644e37 into develop May 4, 2026
3 checks passed
@SunYanbox SunYanbox deleted the fix/132-symbol_ref_tool-performance-catastrophe-text-round-trip-anti-pattern-symbol_ref_tool branch May 4, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] symbol_ref_tool — Performance Catastrophe + Text Round-Trip Anti-Pattern / symbol_ref_tool — 性能灾难 + 文本往返反模式

1 participant