Skip to content

perf(model-info): incrementally aggregate session metrics - #210

Merged
somewan820 merged 6 commits into
openpi-dev:mainfrom
Sun-GLiang:fix/issue-188-model-info-incremental-metrics
Aug 29, 2026
Merged

somewan820 merged 6 commits into
openpi-dev:mainfrom
Sun-GLiang:fix/issue-188-model-info-incremental-metrics

Conversation

@Sun-GLiang

Copy link
Copy Markdown
Contributor

Summary

  • cache active-branch usage prefixes by Pi session entry id so repeated model-info refreshes no longer rescan the full branch
  • synchronize cumulative metrics only at persisted-history lifecycle edges while keeping live context/UI refreshes history-free
  • cover branch changes, session resets, lifecycle ordering, and repeated ordinary refreshes with deterministic tests
  • add a real SessionManager benchmark for 1k/10k/100k entries and 1/10/100 tool turns

Verification

  • node --test --experimental-strip-types tests/extensions/model-info/session-metrics.test.ts tests/extensions/model-info/index.test.ts — 13 passed
  • bun run check — passed
  • bun run test — 917 Node tests and 30 Vitest tests passed
  • bun benchmarks/model-info-session-metrics.ts — full default matrix completed
  • 100k entries / 100 tool turns: 20,220,200 full-scan visits vs 100,200 prefix-tracker visits, including the 100,000-entry cold start

Manual TUI smoke was not run because the local pi list had no package installed; no unconfigured model call was made.

Closes #188

@Sun-GLiang

Copy link
Copy Markdown
Contributor Author

Hi maintainers — this PR is ready for review.

It addresses #188 by incrementally aggregating model-info session metrics while preserving correct behavior across branch changes, session resets, and lifecycle events. The full check and test suites pass, and the benchmark shows a substantial reduction in history traversal.

When you have time, I’d appreciate a maintainer review, particularly of the cache invalidation and lifecycle synchronization design. Thank you!

@somewan820 somewan820 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已完成静态审查。incremental session metrics tracker 覆盖初始化、suffix append、branch/sibling/ancestor 切换、compaction、reset 和 session id reuse,并保持 usage 类型范围;未发现 P0-P2 或死代码问题。P3:可补真实 SessionManager/AgentSession 生命周期集成测试。未运行测试。

@somewan820
somewan820 force-pushed the fix/issue-188-model-info-incremental-metrics branch from 9c1cc46 to d581f89 Compare August 29, 2026 12:35
@somewan820
somewan820 force-pushed the fix/issue-188-model-info-incremental-metrics branch from d581f89 to 78ee4f1 Compare August 29, 2026 12:45
@somewan820
somewan820 merged commit 5cb19c5 into openpi-dev:main Aug 29, 2026
3 checks passed
agnitum2009 pushed a commit to agnitum2009/openpi that referenced this pull request Aug 29, 2026
…#210)

* feat(model-info): add session metrics tracker

* test(model-info): cover cached prefix traversal

* feat(model-info): sync metrics on lifecycle edges

* test(model-info): cover repeated ordinary refreshes

* bench(model-info): compare session metric scans

* fix(bench): model each tool loop as a turn

(cherry picked from commit 5cb19c5)
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.

perf(model-info): 每次生命周期 refresh 都完整扫描 Session branch

2 participants