Skip to content

perf(platform): read an organization's default credentials once per request - #4595

Merged
yannickmonney merged 1 commit into
mainfrom
perf/credential-reads-once
Oct 9, 2026
Merged

yannickmonney merged 1 commit into
mainfrom
perf/credential-reads-once

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

What

GET /api/app/chat/composer/models runs on every app boot. It looked up each provider's default credential separately: the transcription check walks every OpenAI-format provider, and the credential resolver asks again for each one with a key. That came to 14 credential reads per listing.

In the load harness's 3,000-user mixed run (#4589), provider_credentials was the fourth most frequent statement, at 0.63 reads per HTTP request. The composer listing's p50 under that load was 2.4 s.

credentialShimHandlers is built for one shim, so it lives for one request or one turn. It now answers every getDefaultCredentialInternal for an organization from one read (is_default AND status = 'active', same rows as before). It drops that read whenever a broker write (selectBrokerAccount, recordBrokerFailure) runs in the same shim, so a retry after a failed account sees the rows as they are now. A failed read is not remembered. Nothing is cached across requests.

Evidence

Main against this branch, same backend configuration and data, 20 sequential listings after a warm-up, run twice each:

credential reads per listing p50 (idle)
main 14 23 / 24 ms
this branch 3 18 / 15 ms

Testing

  • service.default-reads.test.ts (4 tests) checks that:
    • every provider of an organization is answered from one read, and a provider without a default reads as null;
    • each organization is read once per shim, and a new shim reads again;
    • a broker write drops the read;
    • a failed read is not remembered.
  • The provider-credential, chat, providers, knowledge, sandbox-shim, dispatch and agent-run suites pass: 1,183 tests.

@yannickmonney
yannickmonney added this pull request to the merge queue Oct 9, 2026
@yannickmonney
yannickmonney removed this pull request from the merge queue due to the queue being cleared Oct 9, 2026
@yannickmonney
yannickmonney force-pushed the perf/credential-reads-once branch from 7069daf to 8d1dcd3 Compare October 9, 2026 04:28
…equest

The composer's model listing, which every app boot fetches, looked up
each shipped provider's default credential one by one: 14 reads a
call, 0.63 credential reads per request across a 3,000-user mixed run.
The shim handlers live for one request or turn; they now answer every
provider of an organization from one read and drop it when a broker
write runs in the same shim. 14 reads a listing become 3.
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