Skip to content

Heap: evidence-driven second-pass optimization after incident collection #365

Description

@Juliusolsson05

Problem

The newly merged incident/heap collection work gives Agent Code much better crash evidence, but it does not by itself reduce the remaining heap pressure. We should use that evidence to drive the next optimization pass instead of guessing.

This is deliberately narrower than the broad perf sweep (#103) and complementary to the current post-#288 OOM tracker (#327). The goal is to turn the new heap.pressure, shared appRunId, Crashpad minidump correlation, and adaptive heap sampling from #363/#364 into concrete memory reductions.

Context from existing work

Why now

Before #363/#364, a crash often left us manually timestamp-matching logs, snapshots, minidumps, debug bundles, and perf runs. Now a bad run should leave a single run id and clearer evidence. The next heap work should consume that evidence and answer:

  1. What retained owner still grows with heavy orchestration?
  2. Is the remaining pressure in the Electron main process, the renderer, or both?
  3. Which long-lived structures still retain full transcript/tool/debug bodies when they only need derived state or bounded previews?

Investigation plan

Expected fix shapes

Acceptance

  • A fresh issue/PR comment records before/after heap evidence from at least one main-process snapshot and, if relevant, one renderer snapshot.
  • The top remaining retained owner(s) are named with dominator evidence, not inferred from symptoms.
  • Heavy orchestration no longer shows unbounded main-process heap growth in the reproduced scenario.
  • Long resumed transcripts do not retain full bodies in renderer memory unless the visible UI actually needs them.
  • Any new retention/capping rule has a focused regression test or a documented measurement fixture.
  • The existing incident/Crashpad/heap snapshot paths still work after optimization.

Non-goals

Related: #48, #76, #86, #87, #103, #288, #310, #317, #318, #319, #320, #321, #322, #327, #355, #363, #364.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions