Skip to content

fix(code-index): shrink text builds to available memory headroom - #1782

Merged
ScriptedAlchemy merged 1 commit into
masterfrom
fix/flexible-text-build-budget
Sep 18, 2026
Merged

ScriptedAlchemy merged 1 commit into
masterfrom
fix/flexible-text-build-budget

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Live deadlock after #1777

The cgroup authority is now correctly 26 GiB, but text projection still retried BudgetExceeded ~1–2 times/sec:

  • old serving graph / live daemon RSS: 18–22 GiB,
  • preferred text builder budget: 26 GiB / 8 = 3.25 GiB,
  • supported builder floor: 1.5 GiB,
  • high-watermark reserve: 2.6 GiB.

At 21 GiB RSS, ~2.4 GiB is available below the watermark: enough for the supported builder, not the preferred ceiling. open_published_head_or_begin_build nevertheless reserved the preferred figure all-or-nothing, so the stale graph prevented the replacement build that would release it.

Checked existing open PRs first: none implement flexible resident admission; #1577 is codec/decode work.

Fix

  • reserve_resident_memory_up_to(preferred, minimum) computes available growth from the same modeled + observed + watermark ledger the atomic reservation uses and admits min(preferred, available) when it remains above the established 1.5 GiB floor.
  • Source batch width and SQLite builder budget derive from the admitted amount, so the smaller reservation is real, not accounting-only.
  • Reader and clone-successor reservations call the exact wrapper (minimum == preferred) and are unchanged.
  • If less than the floor remains, return AuthorityUnavailable naming minimum/available; if the atomic reserve loses a race, preserve its exact admission failure. Only real control deadlines remain BudgetExceeded.

Evidence

Concrete 26 GiB/21 GiB case returns the available 2.4 GiB; 22 GiB case stays unavailable below floor. Flexible-budget + existing watermark/reservation/subdivision tests 4/4; all text-artifact tests 20/20; rustfmt and IDE lints clean.

The host-scaled text build budget was treated as an all-or-nothing minimum. With a live 18-22 GiB serving graph under the 26 GiB cgroup allowance, the supported 1.5 GiB builder floor fit but the preferred 3.25 GiB ceiling did not, so the replacement that could release the old graph retried forever. Reserve any budget between the established floor and preferred ceiling, derive batch widths from the admitted amount, and keep fixed reader/clone reservations exact. Reservation failures now retain their typed detail instead of collapsing into BudgetExceeded.
@changeset-bot

changeset-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 0ae9fad

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@ScriptedAlchemy
ScriptedAlchemy merged commit 2a138f6 into master Sep 18, 2026
1 check passed
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