Skip to content

Should --cpuprofile/--memprofile pprof flags ship? (split from #1196) #1200

Open

Description

@VictorLowther

Summary

Add root CLI flags --cpuprofile <path> and --memprofile <path> to capture CPU and heap profiles from a Zero session (previously bundled into #1196, split out per review). Decision needed on whether these ship as user-facing flags.

Proposed behavior

  • Profiles written on session exit: CPU collection starts at run start; the heap profile is written at finish after a runtime.GC(), matching go test -memprofile semantics.
  • Wired into runWithDeps with correct start/finish/reconfigure lifecycle; documented in docs/PERFORMANCE.md.
  • No live-sampling signal handling ships in this cut.

Open questions for maintainer decision

  1. Do these ship? They are new user-facing flags on the root command and imply a support surface (users will attach profiles to issues).
  2. Live sampling. Sampling a running TUI session without quitting is valuable — it is what made the Reasoning/thinking stream rendering is quadratic in the TUI (per-delta full re-render, O(n^2) append, per-frame whole-string preview) #1195/perf(tui): cache transcript row renders, grow caches with the live tail, and scan the provider catalog without cloning #1196 diagnosis possible — but SIGUSR2 does not exist on Windows, a supported target. Options: a cross-platform trigger (control-file watch, named pipe, an out-of-process zero debug pprof subcommand talking to an in-session listener), POSIX-only signal sampling with exit-time profiles on Windows, or no live sampling. This issue ships exit-time profiles only; it can also track whether/when live sampling returns.
  3. If a live-sampling listener is chosen, what guards apply (loopback only? disabled by default in zero serve/ACP modes?) so it can't expose a profiling endpoint.

References

Activity

  1. Vasanthdev2004 commented on Nov 9, 2026

    @Vasanthdev2004
    Collaborator

    Thanks for splitting this out. My vote is to ship the exit-time flags only. They are opt-in, they write to a path the user names, and they make performance reports like #1195 much easier to act on.

    I would leave live sampling out for now. A profiling listener inside a process that runs model-chosen commands is new attack surface even on loopback, and Windows has no signal to hang it on. If it comes back, it should be its own issue with the guards from your third question decided up front.

    @kevincodex1, new root flags are your call.

  2. added
    enhancement
    on Nov 20, 2026
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions