fix(tui): allocate graph history lazily #63

Merged
Lochnair merged 1 commits from fix/tui-lazy-graph-history into main 2026-08-10 16:59:11 +00:00
Lochnair commented 2026-08-10 16:43:42 +00:00 (Migrated from github.com)
No description provided.
chatgpt-codex-connector[bot] (Migrated from github.com) reviewed 2026-08-10 16:46:55 +00:00
chatgpt-codex-connector[bot] (Migrated from github.com) left a comment

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 61ed029988

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `61ed029988` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
@@ -552,3 +552,3 @@
negotiated: None,
graph_history: VecDeque::with_capacity(HISTORY_LIMIT),
graph_history: VecDeque::new(),
last_sample: None,
chatgpt-codex-connector[bot] (Migrated from github.com) commented 2026-08-10 16:46:56 +00:00

P2 Badge Cap lazy growth at the history limit

For a target receiving at least 65,537 replies, VecDeque's geometric growth increases this buffer's capacity from 65,536 to 131,072; push_bounded later limits its length to 100,000 but never releases the 31,072 excess slots. Long-running active targets therefore retain more graph-history heap than the previous exact-limit allocation, with the overhead multiplied in multi-target runs, so grow the queue in capped increments or reserve only the final remainder as it approaches HISTORY_LIMIT.

AGENTS.md reference: AGENTS.md:L53-L58

Useful? React with 👍 / 👎.

**<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Cap lazy growth at the history limit** For a target receiving at least 65,537 replies, `VecDeque`'s geometric growth increases this buffer's capacity from 65,536 to 131,072; `push_bounded` later limits its length to 100,000 but never releases the 31,072 excess slots. Long-running active targets therefore retain more graph-history heap than the previous exact-limit allocation, with the overhead multiplied in multi-target runs, so grow the queue in capped increments or reserve only the final remainder as it approaches `HISTORY_LIMIT`. AGENTS.md reference: [AGENTS.md:L53-L58](https://github.com/Lochnair/irtt-rs/blob/61ed029988b39caec1b7fad1850c038c01ac4a06/AGENTS.md#L53-L58) Useful? React with 👍 / 👎.
chatgpt-codex-connector[bot] (Migrated from github.com) commented 2026-08-10 16:46:55 +00:00

P1 Badge Test the allocation bound instead of exact zero capacity

A future implementation could reserve a small initial buffer while still avoiding the problematic HISTORY_LIMIT preallocation, but this exact-capacity assertion would reject it despite preserving the intended memory invariant. Assert the meaningful upper bound, or remove/consolidate this test, rather than pinning VecDeque's private allocation mechanism.

AGENTS.md reference: AGENTS.md:L104-L106

Useful? React with 👍 / 👎.

**<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Test the allocation bound instead of exact zero capacity** A future implementation could reserve a small initial buffer while still avoiding the problematic `HISTORY_LIMIT` preallocation, but this exact-capacity assertion would reject it despite preserving the intended memory invariant. Assert the meaningful upper bound, or remove/consolidate this test, rather than pinning `VecDeque`'s private allocation mechanism. AGENTS.md reference: [AGENTS.md:L104-L106](https://github.com/Lochnair/irtt-rs/blob/61ed029988b39caec1b7fad1850c038c01ac4a06/AGENTS.md#L104-L106) Useful? React with 👍 / 👎.
Lochnair (Migrated from github.com) reviewed 2026-08-10 16:55:03 +00:00
Lochnair (Migrated from github.com) commented 2026-08-10 16:55:03 +00:00

Removed the test — swapped for a plain upper-bound assertion (capacity() < HISTORY_LIMIT + HISTORY_LIMIT / 10) added to echo_reply_appends_bounded_primary_history instead of pinning VecDeque's private allocation mechanism.

🤖 Addressed by Claude Code

Removed the test — swapped for a plain upper-bound assertion (`capacity() < HISTORY_LIMIT + HISTORY_LIMIT / 10`) added to `echo_reply_appends_bounded_primary_history` instead of pinning `VecDeque`'s private allocation mechanism. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
Lochnair (Migrated from github.com) reviewed 2026-08-10 16:55:08 +00:00
@@ -552,3 +552,3 @@
negotiated: None,
graph_history: VecDeque::with_capacity(HISTORY_LIMIT),
graph_history: VecDeque::new(),
last_sample: None,
Lochnair (Migrated from github.com) commented 2026-08-10 16:55:08 +00:00

Fixed in push_bounded: once capacity reaches half of limit, we now reserve_exact up to limit instead of letting the next geometric doubling overshoot it, so long-running targets no longer retain the extra ~31k slots.

🤖 Addressed by Claude Code

Fixed in `push_bounded`: once capacity reaches half of `limit`, we now `reserve_exact` up to `limit` instead of letting the next geometric doubling overshoot it, so long-running targets no longer retain the extra ~31k slots. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
Sign in to join this conversation.