Skip to content

perf: avoid discarded replay and scrollback splice results - #361

Open
onmax wants to merge 2 commits into
devframes:mainfrom
onmax:perf/replay-buffer-eviction
Open

perf: avoid discarded replay and scrollback splice results#361
onmax wants to merge 2 commits into
devframes:mainfrom
onmax:perf/replay-buffer-eviction

Conversation

@onmax

@onmax onmax commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

After their buffers fill, RPC replay and terminal scrollback discard an array returned by splice on each new chunk. Use shift when exactly one entry must be removed. Keep splice for other overflows, including fractional replay windows and oversized supplied scrollback buffers.

 buffer exceeds its limit by one
-  splice(0, 1), discard the returned array
+  shift()
 other overflow values
   keep splice()

For each buffer, 10,000 writes with a 1,000-entry limit produce 9,000 discarded splice results before and 0 after. The retained entries, order, and buffer identity stay the same.

Reproduction Before After
RPC replay Before After
Terminal scrollback Before After

Run locally on Node 24.19.0 with Corepack. Each pair tests the same published package version with and without a committed package patch. The terminal fixture drives the real stream pump with a recording sink; it does not spawn a PTY.

Copy and run both comparisons
for repro in devframe-replay-buffer-eviction devframe-terminal-scrollback; do
  (
    set -e
    git clone --depth 1 --filter=blob:none --sparse --branch "repro/$repro" https://github.com/onmax/repros.git "$repro-repro"
    cd "$repro-repro"
    git sparse-checkout set "$repro" "$repro-fix"
    cd "$repro"
    corepack pnpm install --frozen-lockfile --ignore-scripts
    corepack pnpm verify
    cd "../$repro-fix"
    corepack pnpm install --frozen-lockfile --ignore-scripts
    corepack pnpm verify
  ) || exit 1
done

@coldtea-pr-lens

coldtea-pr-lens Bot commented Sep 5, 2026

Copy link
Copy Markdown

◈ PR Lens

🟢 +0 new · 🟠 ~2 changed · 🔴 -0 removed · 1 flow · 4 files · commit 618e1cb


Architecture

Architecture diagram for devframes/devframe at 618e1cb

2 components touched across 3 lanes.

Open full size


Data flow

Data flow diagram for devframes/devframe at 618e1cb

Terminal stream output and buffer eviction

Open full size


Drill down
Hub Orchestration — 1 component
🟡 CHANGED Hub Terminals Subsystem

Drains terminal process and PTY output into session scrollback buffers and RPC streaming channels, using shift for single-chunk eviction.

Devframe Core — 1 component
🟡 CHANGED Streaming Channel Sink

Implements server-side stream sinks with bounded replay buffers, evicting single overflow chunks via shift to prevent splice allocations.


View

  • Architecture lens
  • Data flow lens
  • Expand every detail
  • Show unchanged neighbours

Tip

GitHub will not let you zoom an image in a comment. The link under each diagram opens it full size on a page of its own, where you can.

🪧 More tips
  • Run PR Lens on your own machine: npx skills add coldteadotai/pr-lens installs the agent skill. Then tell your coding agent: "Diagram the change you just made with PR Lens and attach it to the pull request."
  • Draw a diff before it is even a pull request: npx @coldtea/pr-lens-cli analyze --base origin/main reads the diff with your own model key, and npx @coldtea/pr-lens-cli render .pr-lens/graph.json draws the same lenses on your machine.
  • The boxes under View are live. Tick Architecture lens or Data flow lens to choose which diagrams appear, or Expand every detail to open every drill-down at once. The comment redraws in place a few seconds later.
  • Show unchanged neighbours lists the components this change did not touch alongside the ones it did, so the drill-down shows what the changed code sits next to.
  • The CLI's render picks up .github/pr-lens.yml automatically and applies your corrections (renames, exclusions, lane pins) at draw time.
  • Would you rather run it from CI on a key of your own? Add .github/workflows/pr-lens.yml with coldteadotai/pr-lens/packages/action@v0 and a model key in your repository secrets, say GEMINI_API_KEY. The Action asks Gemini by default, or OpenAI and any endpoint speaking /chat/completions through its provider input.
  • PR Lens is free for open source. A star on the repository is what keeps it going.
  • Push a new commit and the whole comment re-renders for the new head. An older run never overwrites a newer one, so a slow render cannot put a stale diagram back.
  • The diagrams follow your GitHub theme, so dark mode gets the dark render and light mode the light one, and the moving dots show this pull request's data in motion.

◈ Rendered by PR Lens · crafted with ❤️ by the Coldtea team · Come say hi on Discord

@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
devframe Skipped Skipped Sep 5, 2026 6:40am UTC

@onmax onmax changed the title perf: avoid discarded replay splice results perf: avoid discarded replay and scrollback splice results 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.

1 participant