Skip to content

perf(knowledge): avoid duplicate startup chunk scans - #87

Merged
1 commit merged into
Soren-ABT:mainfrom
kakashiii-ex:fix/startup-recovery-chunk-counts
Nov 24, 2026
Merged

1 commit merged into
Soren-ABT:mainfrom
kakashiii-ex:fix/startup-recovery-chunk-counts

Conversation

@kakashiii-ex

Copy link
Copy Markdown
Contributor

问题

Windows 上使用 DSH Desktop 0.2.2-rc.5 和 dsh-knowledge 0.5.4,单库约 12.5 万个分块。按启动顺序只读执行 SQLite 查询,两遍合计分别约 62.1 秒和 61.3 秒。开库和服务初始化分别查询了一次分块的向量覆盖率,恢复流程实际只需要判断文档是否已有分块。

这与 #73 的启动慢现象相关。#74 已将产物目录清理移到后台。本次改动集中在 SQLite 启动查询。

改动

  • 开库时统计一次每篇文档的分块数,供中断恢复和计数校对共用,服务初始化直接使用开库产生的恢复列表。
  • 保留恢复开关、存储写入异常时的回退,以及已有分块和待确认提交的处理。校对后的空文档仍保持完成状态。
  • 沿用现有 SQLite 表结构和分块索引。

验证

  • 在原库上以 DSH 自带 Node 24.21.0 只读执行保留下来的计数查询,首遍约 7.0 秒,第二遍约 0.36 秒。两遍均为 4,087 篇有分块的文档,与元数据零差异。这些数字只覆盖所列 SQLite 查询。
  • 新增真实 SQLite 启动回归,覆盖单次分块计数、过时计数修复、已完成空文档和中断标记。
  • Windows 本地 720 项测试通过,类型检查、构建、检索基准、包校验、工作区策略检查及生产依赖审计通过。其他平台交给仓库 CI 验证。

@Soren-ABT Soren-ABT closed this pull request by merging all changes into Soren-ABT:main in e7e291e Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants