Skip to content

feat(knowledgeBase): 为日记批处理入库引入分段耗时(Phase Breakdown)可观测性日志 - #464

Closed
infinite-vector wants to merge 1 commit into
lioensky:mainfrom
infinite-vector:feat/ingestion-phase-breakdown-logging
Closed

feat(knowledgeBase): 为日记批处理入库引入分段耗时(Phase Breakdown)可观测性日志#464
infinite-vector wants to merge 1 commit into
lioensky:mainfrom
infinite-vector:feat/ingestion-phase-breakdown-logging

Conversation

@infinite-vector

Copy link
Copy Markdown
Contributor

背景与意图

在排查日记并发批处理引发事件循环阻塞过程中,发现 _flushBatch 内部从 SQLite 事务提交、Rust 原子索引差分发布、Tag/日期元数据维护到矩阵重排判定,缺乏细粒度的分段可观测性指标。

当现场出现长时间挂起时,单纯依赖外层的看门狗仅能感知到 lag 发生,无法在不打桩的情况下快速界定到底是底层事务锁表、原生 Rust 邻居挂接、还是日期元数据正则扫盘所致。

改动内容
在 modules/knowledgeBase/ingestionPipeline.js 的 _flushBatch() 执行主干中植入零额外 I/O 开销的微秒级时间戳标尺:

SQLite: 统计 this.db.transaction() 执行纯物理写入与索引维护的时间;
applyChunkDelta: 统计 Rust 原生向量图差分挂接与旧节点删除的总耗时;
Tag&Date: 统计全局 Tag usearch 增量与日记日期元数据缓存维护耗时;
scheduleMatrix: 统计 1% 阈值与共现网络重排调度开销。
并在批次完成时打出结构化结算单:

[KnowledgeBase] ⏱️ Phase Breakdown: SQLite=xx ms, applyChunkDelta=xxx ms, Tag&Date=xxx ms, scheduleMatrix=xxx ms (Total=xxx ms)
验证与开销
使用原生 Date.now()(仅纳秒级 rdtsc 读取),只在批次结束汇总打印单行,不侵入任何内部循环热路径;

添加的日志log加都加了,干脆pr了

@lioensky

lioensky commented Sep 5, 2026

Copy link
Copy Markdown
Owner

这个现在感觉没必要了吧?

@lioensky lioensky closed this Sep 5, 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