Skip to content

perf(sessions): preview 在截取前完整加载 JSONL 并缓存大历史 #186

Closed

Description

@tt-a1i

问题

Sessions 浏览器选择一个历史 Session 时,会同步打开并解析完整 JSONL、构建完整 branch context,然后才截取最多 80 条 preview message。访问过的 preview 又进入内存 cache。大型 Session 会造成明显事件循环停顿与 heap 峰值,多个大型 preview 会累积驻留。

证据

  • extensions/sessions/index.ts:443-449:选择时同步 load/build;
  • Pi dist/core/session-manager.js:277-317,617-636:完整 JSONL 读取、entry index 与 context 构建;
  • extensions/sessions/sessions.ts:345-356:完整处理之后才限制 80 messages;
  • extensions/sessions/index.ts:554,671-678:preview cache;
  • extensions/sessions/index.ts:159-175,232:collapsed output 扫描。

期望

  • preview 使用有界 streaming/index path,不构建完整 SessionManager;
  • cache 有 aggregate byte/entry bound,并能释放大型 preview;
  • malformed/truncated JSONL 有明确失败,不为性能跳过完整性边界;
  • 打开真实 Session 的 canonical 行为保持 Pi-native;优化只作用于 preview projection;
  • benchmark:冷选 10/100/500 MiB JSONL,再依次访问 20 个大 preview,记录 event-loop stall、RSS/heap、读取 bytes 和 cache eviction。

Activity

  1. added
    bug
    on Aug 25, 2026
  2. Sun-GLiang commented on Aug 26, 2026

    @Sun-GLiang
    Contributor

    Hi! I’d like to work on this issue. I’ve investigated the current session preview path and plan to implement bounded, asynchronous preview loading with cancellation and a size-limited cache. I’ll also add regression tests and benchmarks. Please let me know if anyone is already working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions