Skip to content

perf: vmk port stack — VirtualList, quick wins y height-skip (22 commits) - #1

Open
LuisAlbertoMK wants to merge 23 commits into
devfrom
port-vmk-perf
Open

perf: vmk port stack — VirtualList, quick wins y height-skip (22 commits)#1
LuisAlbertoMK wants to merge 23 commits into
devfrom
port-vmk-perf

Conversation

@LuisAlbertoMK

Copy link
Copy Markdown
Owner

Base: ef2792511d (fork/dev)

Highlights

  • VirtualList Fase 5.1 y 5.3
  • prefix-sum O(log n)
  • recycle scopes
  • height-skip ciclo 2
  • quick wins core
  • lazy CLI
  • truncateLimit MCP
  • Fixes lsp/plugin

Evidencia

  • Tests TUI: 204 passed / 1 pre-existente (docs/vmk/mejora-log.md, ADR-001..005)
  • Typecheck verde (30/30 packages)

Nota

  • wal-mmap y bytecode fueron rejected con evidencia; no se incluyen en este PR.

LuisAlbertoMK and others added 22 commits September 2, 2026 13:32
…concurrency unbounded

- Internal plugins (10 auth plugins): for...of secuencial → Effect.forEach
  concurrency:unbounded. Seguro porque son auth plugins independientes
  sin shared state durante init.
- Config hooks: for...of secuencial → Effect.forEach concurrency:unbounded.
  Cada hook recibe el mismo config, sin dependencias entre sí.
- External plugins mantienen carga secuencial (determinismo de hooks).
- Triple verify: typecheck 0 errors in file ✅ / static review PASS ✅ /
  build binary 130.5MB smoke test PASS ✅

(cherry picked from commit d2f49d8)
- tool_output global: 500 lines/10KB
- truncateLimit added to V1+V2 config schema (Local + Remote)
- MCP.toolTruncateLimit() exposed in mcp/index.ts
- Used in session/tools.ts to override global maxBytes per server
- Config: codebase-memory=8KB, engram=4KB
- AGENTS.md: new MCP Token Budget Rules section
- BACKLOG: anomalyco#2 Parallel Plugin Loading -> Skip (already parallel)
- CYCLE: removed empty Cycle 6
- METRICAS/BITACORA/VMK-MANIFEST: session tracking

(cherry picked from commit 8a144ec)
…essages

Create VirtualList component that reduces SolidJS/Yoga overhead by
rendering only items in the visible viewport + overscan buffer (3-5 items)
instead of all messages.

Key design decisions:
- Poll scroll position at 10fps (no scroll events in opentui)
- Use estimated heights (3 lines per item) — no reactive layout events
- Integrates into session component replacing <For each={messages()}>
- Maintains all existing rendering logic (revert, user/assistant message types)

Build and lint clean (pre-existing error in error-component.tsx only).
- 1 new file: packages/tui/src/component/virtual-list.tsx

(cherry picked from commit aef949d)
Add real height measurement of rendered items via polling refs.
- Yoga-computed heights read in the same 100ms polling loop as scroll tracking
- Cache Map<index, lines> accumulated over time, fallback to estimate (5 lines)
- Range calculation uses cached heights for accurate padding/scroll positioning
- Extra box wrapper per item captures total height including margins/borders

Build and lint clean (pre-existing error-component.tsx only).

(cherry picked from commit a0e463e)
…ast --help/--version paths

Ported from vMK-dev commits 84c6784 + 533fa4a, adapted to current
upstream entrypoint. Uses a cmdLoaders map of static import() specifiers so
Bun bundles command modules at build time without evaluating their top-level
code until invocation (compiled-binary safe). First-argument --help/--version
take fast paths; subcommand flags keep the original scoped-help behavior.
…ng buffer

- VirtualList: two-tier polling (100ms active → 500ms idle) reduces CPU
  60-80% when not scrolling
- registry.ts: generation-counter cache on materialize() — returns cached
  Materialization when tool registrations haven't changed, avoiding
  per-turn Map rebuild + permission filtering
- compaction.ts: LRU cache 10→100 entries + WeakMap for fast identity
  lookup on repeated estimate() calls with same object reference
- message-updater.ts: incremental index shift on eviction instead of
  O(n) rebuildIndex() — shifts Maps by evictCount, re-scans only tail
- build.ts: fix post-build rename to handle .exe extension on Windows
- script/index.ts: fix package.json path (packages/opencode → packages/cli)
- web/package.json: fix workspace dependency (opencode → @opencode-ai/cli)

Build verified: opencode-vMK.exe (122MB) created successfully.
All 13 bash-parser tests pass. Typecheck clean. Lint 0 errors.

(cherry picked from commit 7eca550)
No behavior change — the 4-pass O(n) scan moves verbatim into a pure,
Solid-free function so it can be unit-tested and benchmarked in isolation.
Prepares Ciclo 1 of experimento/mejora-autonoma-2026-09-03.
Ciclo 1 of experimento/mejora-autonoma-2026-09-03. 3 approaches evaluated
with equivalence-verified benchmark (2500 random queries each):
- A prefix-sum+binary search (WINNER): 82-91% faster at n=100/1000/5000
- B two-pointer: discarded — amortized pointer helps but O(n) padding remains
- C chunked K=32: discarded — within-chunk walks + O(n) padding

The prefix structure rebuilds only when the heights cache changes (memo),
never per scroll tick. Baseline algorithm kept exported for regression
comparison. Tests: exact equivalence + boundary pinning (7/7 green).
…M growth

Ciclo 2 of experimento/mejora-autonoma-2026-09-03. itemRefs retained one
stale entry (and its Zig-backed BoxRenderable) per ever-rendered item with
no cleanup — growth proportional to scroll distance. 3 approaches evaluated:
- A onCleanup guard (winner): releases on row disposal, el-identity check
  guards against re-mount ordering
- B isDestroyed skip in tick (kept as defense-in-depth)
- C WeakRef: discarded — the Map is the sole retainer, plain delete is
  simpler and deterministic

Simulation metrics (2000 window shifts): retained entries 2005 -> 18
(-99.1%); tick measurement loop CPU -48.9% for long-scroll sessions.
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

Hey! Your PR title perf: vmk port stack — VirtualList, quick wins y height-skip (22 commits) doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant