Repository navigation
perf(app): avoid full catalogue copies for model metadata lookups - #1927
Merged
Merged
Conversation
Search the immutable sorted catalogue directly for context and modality metadata while preserving defensive list and modality copies. Co-Authored-By: mecatl <[email protected]>
Merged
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace full-catalogue copies in two single-model metadata lookups with a read-only binary search over the catalogue's existing sorted model slice.
Provider.Model(id) (Model, bool)using the already-importedsort.Search.catalogContextWindowandcatalogModalities.Models()andInputModalities().No new cache, dependency, engine/public SDK API, or user-facing semantic change.
Measured impact
Paired uncached
internal/appCPU/heap profiles on the same baseline, with only the catalogue optimization toggled:The allocation reduction is about 90%. This is cumulative allocation churn, not peak RAM, and is not a claim of 90% wall-time improvement. Timing is one paired profiled run; host load can affect it.
Median microbenchmarks (
-benchtime=200ms -count=3):The remaining modality-hit allocation is the intentional defensive copy of that model's modalities.
Benchmark command:
Verification
All final gates passed on commit
824950d59b5a90004fa9b5b4578023c493009b0b:task test GOPROXY=offtask linttask test:race GOPROXY=offgit diff --checkAdditional proof:
-race.PANEL: ship_blockers=0 important=0 advisory=0 reviewer_failures=0Scope
Routine: mechanical optimization of an immutable internal catalogue, with unchanged observable metadata behavior. No acceptance-plan or engine compatibility-snapshot changes are needed.
A separate GPT-6 Astra investigation recommended keeping further timer/recovery-worker and catalogue optimizations out of this PR. Those follow-ups should be independently measured.