Skip to content

perf(registry): reduce scan allocation and duplicate evidence work - #1345

Merged
Gajesh2007 merged 5 commits into
masterfrom
codex/registry-hot-path-optimization
Oct 5, 2026
Merged

Gajesh2007 merged 5 commits into
masterfrom
codex/registry-hot-path-optimization

Conversation

@Gajesh2007

@Gajesh2007 Gajesh2007 commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

Summary

Replaces #1341 at the author's request so the head branch lives in Layr-Labs/d-inference, not the personal fork. Preserves the original signed optimization, both concurrent cleanup commits, and their report/comment improvements. Signed merges integrate both histories and current master bc1ee1629 (including #1342 and #1343), without rewriting history. The personal branch is unchanged.

  • Reuse bounded private candidate storage, retain compact detached snapshots, borrow immutable forecast inputs, project pending/service evidence once, and project alternate selection inputs once.
  • Preserve public/decorated preparation ownership and current-state locked admission plus pending debit. Retained dispatch plans hold copied quotes and provider identities and revalidate before later reservation.
  • Remove four obsolete scheduler helpers that caused perf(registry): reduce scan allocation and duplicate evidence work #1341's Coordinator Lint failure; update comments and the canonical profiler reference to the active implementations.
  • No HTTP, protocol, configuration, migration, or ledger contract changes.

Before

flowchart TD
  B0([Request]) --> B1["ReservationPlanner: scan providers"]
  B1 --> B2["Allocate full candidate snapshots; copy forecast inputs"]
  B2 --> B3["Repeat pending/service and alternate projections"]
  B3 --> B4["Rank and select candidate"]
  B4 --> B5{"Locked current-state admission"}
  B5 -->|Admit and debit| B6(["Provider and detached decision / plan"])
  B5 -->|Reject| B7["Retry or existing failure policy"]
  classDef entry fill:#dbeafe,stroke:#2563eb,color:#172554
  classDef work fill:#fef3c7,stroke:#d97706,color:#451a03
  classDef safety fill:#dcfce7,stroke:#16a34a,color:#14532d
  classDef failure fill:#fee2e2,stroke:#dc2626,color:#450a0a
  class B0 entry
  class B1,B2,B3,B4 work
  class B5,B6 safety
  class B7 failure
Loading

After

flowchart TD
  A0([Request]) --> A1["reservationCandidateStorage: private bounded reuse"]
  A1 --> A2["candidateSnapshot: retain compact values"]
  A2 --> A3["fillPendingSnapshot / ServiceReport: project once"]
  A3 --> A4["Borrow immutable forecasts; unchanged selection"]
  A4 --> A5{"Locked current-state admission"}
  A5 -->|Admit and debit| A6["RetainRanked: project alternates once"]
  A6 --> A7(["Provider and detached decision / plan"])
  A5 -->|Reject| A8["Retry or existing failure policy"]
  A7 --> A9["Clear private chunks after synchronous readers finish"]
  A8 --> A9
  A0 --> A10["Public / decorated preparations keep owned storage"]
  classDef entry fill:#dbeafe,stroke:#2563eb,color:#172554
  classDef work fill:#e0e7ff,stroke:#4f46e5,color:#1e1b4b
  classDef safety fill:#dcfce7,stroke:#16a34a,color:#14532d
  classDef failure fill:#fee2e2,stroke:#dc2626,color:#450a0a
  class A0 entry
  class A1,A2,A3,A4,A6,A9,A10 work
  class A5,A7 safety
  class A8 failure
Loading

Blue marks incoming work, amber/indigo computation, green preserved admission/results, and red existing failure behavior. Public scans do not borrow private candidate storage. Later dispatch-plan claims still require current locked revalidation. Shadow occupancy estimates remain confined to candidateSnapshot.shadowTTFT, outside live admission ceilings.

Measurements

The original six paired fresh-process runs reported standard 350-provider reserve latency of 313.661 to 267.959 microseconds (-14.57%), allocation bytes of 435,152 to 8,370 (-98.08%), and 19 to 6 allocations. Candidate size falls from 1,448 to 592 bytes. Retained storage is capped at 64 chunks per pooled object, not globally; indexed scans over 3,520 providers use owned storage.

These are original local microbenchmark results, not a new production latency claim or measurements rerun during this review. The measurement report includes raw samples, methodology, tradeoffs, and comparison with pre-#1324 performance.

Review And Refactor

Two independent correctness reviewers traced storage lifetime/concurrency and projection/selection equivalence. No additional introduced defect was found. A dedicated refactor subagent reviewed the whole optimization and cleanup after focused tests passed, and explicitly found no further changes warranted: the new storage, snapshot, pending projection, service validation, and ranking responsibilities have cohesive owners. It also checked the final merge resolutions and confirmed no lost semantics. The preexisting large scheduler was not broadly rewritten.

Non-blocking coverage opportunities remain: deterministically force a pooled private rescan, test borrowed calibration with a nonempty competitor slice, and exercise a content-commit transition during projection. Existing lifetime, overflow, public/decorated ownership, differential ranking, pending/service, admission and retirement tests pass.

Validation

Rerun in an isolated worktree with Go 1.25.0 and empty EIGENINFERENCE_DATABASE_URL / TEST_DATABASE_URL:

  • make coordinator-test: all 20 runner guard tests and the full coordinator suite pass (82.550 seconds after the final master integration).
  • go test ./coordinator/tests/registry/... -count=1: all eight packages pass; independently repeated by reviewers and the refactor subagent.
  • go test -race ./coordinator/tests/registry/... -count=1: all eight packages pass, no race report.
  • golangci-lint run using CI-pinned v2.1.6: zero issues, including a rerun after the refactor pass.
  • make coordinator-build coordinator-build-linux: both pass.
  • make docs-impact-check BASE=origin/master: canonical coverage passes.
  • make docs-check: all 331 committed documents pass after initializing the pinned documentation dependency libs/mlx-swift-lm.
  • git diff --check: passes.

PostgreSQL-dependent local cases are skipped without a database; credential/provider-dependent E2E and performance measurements were not rerun locally. Exact-head CI, protected integration/benchmark gates, and automated review status must be evaluated separately before merge. No merge, release, or production deployment is authorized by this PR.

Reuse bounded private candidate storage, retain compact detached evidence, borrow forecast inputs, project alternates once, and aggregate pending/service evidence. Preserve public quote ownership and locked reservation admission/debits. Include differential/lifetime/boundary tests and measured local validation.
Remove unused routingSnapshot decode and shadow-TTFT wrappers after compact candidate snapshots took over their callers. Preserve live admission and shadow behavior; update comments and measurement provenance.

Validated full registry race suite, coordinator vet, macOS and Linux builds, docs impact and docs lint.
@vercel

vercel Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
d-inference Ready Ready Preview Oct 4, 2026 11:39pm UTC
d-inference-console-ui-dev Ready Ready Preview Oct 4, 2026 11:39pm UTC
d-inference-landing Ready Ready Preview Oct 4, 2026 11:39pm UTC
eigen-homepages-darkbloom Ready Ready Preview Oct 4, 2026 11:39pm UTC

Request Review

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Threat model review — advisory

Reviewed head abf6b84ac81c against base 34f0e6dde6a8.

Review not completed for this head. Previous findings are superseded, not confirmed resolved.
Ten-PR pilot complete; maintainer evaluation required

Models: budgeted Sonnet / selective Opus / selective Sol 6.1. Findings require human validation; this review never requests changes or blocks merging.

Coverage: 0/0 source units; cross-file integration pending. 0 selected depth batch(es) pending. All threat definitions indexed; relevant full definitions selected. Unchanged callers are not scanned.

Cost this run: $0.0000 reported, $0.0000 reserved with unknown cost; 0 paid request(s), 0 reused batch(es), 0 provider cache-hit tokens.

Saved findings and earlier report · Historical findings are not confirmed resolved.

@Gajesh2007

Copy link
Copy Markdown
Member Author

Review checkpoint for abf6b84: the original blocking finding was four unused scheduler helpers; both concurrent cleanup histories are preserved and the dead code is removed. Two independent correctness reviews plus a dedicated structure/refactor pass found no additional introduced defect. The new responsibilities remain separated into storage, retained snapshots, pending projection, report validation, and detached ranking. Before/after Mermaid diagrams were verified rendered on GitHub.

Final local full coordinator tests, registry race tests, lint, macOS/Linux builds and documentation checks passed. Exact-head GitHub CI now passes Coordinator Tests, Coordinator Lint, Release Integrity, Docs Lint/Impact, Commit Signatures, all three CodeQL analyses and all four Vercel previews. All five PR commits are Verified.

Remaining gates: E2E Integration Tests are running; E2E Benchmarks await approval of the benchmarks environment (reviewer Gajesh2007); a required PR approval is still missing. The advisory threat-review pilot reports that it did not review this head and needs maintainer evaluation, despite its workflow succeeding. No inline review findings are currently open. No merge or production deployment performed.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-04T23:45:15.889080Z abf6b84 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@davidtai davidtai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just verify the ChunkSize change to 55 is intended.

@Gajesh2007
Gajesh2007 merged commit 5b7a675 into master Oct 5, 2026
36 of 38 checks passed
@Gajesh2007
Gajesh2007 deleted the codex/registry-hot-path-optimization branch October 5, 2026 00:17

This branch was successfully deployed

4 active deployments
Preview – d-inference — abf6b84a Deployed Oct 4, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — abf6b84a Deployed Oct 4, 2026 by vercel[bot]
benchmarks — abf6b84a Deployed Oct 4, 2026 by Gajesh2007 via E2E Benchmarks #2220
Preview – d-inference-landing — abf6b84a Deployed Oct 4, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — abf6b84a Deployed Oct 4, 2026 by vercel[bot]
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.

3 participants