Skip to content

perf: trim hot-path allocations in indexing and TUI render#77

Merged
amittamari merged 1 commit into
masterfrom
oxc-inspired-phase2
Jul 13, 2026
Merged

perf: trim hot-path allocations in indexing and TUI render#77
amittamari merged 1 commit into
masterfrom
oxc-inspired-phase2

Conversation

@amittamari

Copy link
Copy Markdown
Owner

Concrete, std-only allocation cleanups in the indexing parse loop and the TUI render path. No new dependencies.

Stacked on top of #76 (base = oxc-inspired-phase1). Rebase onto master once #76 merges.

Changes

  • Adapters: reuse one decode buffer per file instead of allocating a fresh Vec<u8> for every JSONL line (clear + extend_from_slice). Applies to the Claude, Codex, and Cursor parse loops.
  • Results list: compute each visible cell's (text, style) once per frame (compute_cells), then feed the same grid to both the width solver (layout_from_cells) and the row builder (session_row). Previously every non-flex cell string was built twice per frame (measure pass + build pass). This also halves the per-frame document_key() probes for the PR column and lets cell()/enrichment_cell() take &RowCtx, dropping the too_many_arguments allow.
  • Footer: build the status line once and size its region from it instead of rebuilding it just to measure the width (line_display_width).
  • Cow<str> for the no-op-common text transforms so they borrow when the input is unchanged (the common case): strip_codex_wrappers, strip_redacted (now fully allocation-free), and index sanitize.

Note

Full elimination of the per-frame document_key() format! was intentionally not pursued: the resolved map's (String, &'static str) tuple key can't be probed with a borrowed key, so even a cached key would still clone into the tuple. Removing it entirely would require restructuring the map type across its construction sites and ~15 tests for negligible gain. The grid change above already halves the calls.

Verification

  • cargo fmt --all -- --check clean
  • cargo clippy --all-targets --all-features -- -D warnings clean
  • cargo test — 277 pass. Adapter/index integration suites cover the parse-path and Cow changes; results_list unit tests and view.rs render-to-buffer snapshots cover the render-path changes.

🤖 Generated with Claude Code

@amittamari
amittamari force-pushed the oxc-inspired-phase2 branch from 6ef08ea to 671fb41 Compare July 12, 2026 14:00
@amittamari
amittamari force-pushed the oxc-inspired-phase1 branch from 88d922a to 32e0099 Compare July 12, 2026 14:17
@amittamari
amittamari force-pushed the oxc-inspired-phase2 branch from 671fb41 to b4346ed Compare July 12, 2026 14:18
Base automatically changed from oxc-inspired-phase1 to master July 12, 2026 14:24
Concrete, std-only allocation cleanups (no new dependencies):

- Adapters: reuse one decode buffer per file instead of allocating a fresh
  Vec<u8> for every JSONL line (clear + extend_from_slice). Applies to the
  Claude, Codex, and Cursor parse loops.
- Results list: compute each visible cell's (text, style) once per frame via
  `compute_cells`, then feed the same grid to both the width solver
  (`layout_from_cells`) and the row builder (`session_row`). Previously every
  non-flex cell string was built twice per frame (measure pass + build pass).
  This also halves the per-frame `document_key()` probes for the PR column and
  lets `cell()`/`enrichment_cell()` take `&RowCtx`, dropping the
  `too_many_arguments` allow.
- Footer: build the status line once and size its region from it instead of
  rebuilding it just to measure the width (`line_display_width`).
- Return `Cow<str>` from the no-op-common text transforms so they borrow when
  the input is unchanged (the common case): `strip_codex_wrappers`,
  `strip_redacted` (now fully allocation-free), and index `sanitize`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@amittamari
amittamari force-pushed the oxc-inspired-phase2 branch from b4346ed to f6a452e Compare July 13, 2026 05:46
@amittamari
amittamari merged commit f6a1f12 into master Jul 13, 2026
1 check passed
@amittamari
amittamari deleted the oxc-inspired-phase2 branch July 13, 2026 06:17
@amittamari amittamari mentioned this pull request Jul 12, 2026
amittamari added a commit that referenced this pull request Jul 13, 2026
## 🤖 New release

* `hop`: 0.2.8 -> 0.2.9

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## [0.2.9](v0.2.8...v0.2.9) -
2026-07-13

### Added

- capture session model/commit and skip non-interactive threads
([#75](#75))
- harden Codex session parsing
([#74](#74))
- simple/raw search modes with guided toolbar
([#73](#73))
- hook-based session metadata enrichment
([#65](#65))

### Other

- trim hot-path allocations in indexing and TUI render
([#77](#77))
- adopt edition 2024, in-tree lint policy, and rustfmt config
([#76](#76))
- add DESIGN.md, codex-inspired review, and no-local-paths rule
- *(readme)* update demo
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
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