Skip to content

perf: parallelize provider resolution and eagerly init SQLite pool - #8899

Merged
baxen merged 7 commits into
mainfrom
perf-list-all-providers
Apr 29, 2026
Merged

perf: parallelize provider resolution and eagerly init SQLite pool#8899
baxen merged 7 commits into
mainfrom
perf-list-all-providers

Conversation

@matt2e

@matt2e matt2e commented Apr 29, 2026

Copy link
Copy Markdown
Collaborator

Stats

Initial call to get all providers: 3.3s -> 1.0s
Subsequent calls to get all providers: 1.6s -> 244ms

Summary

  • Parallelize provider inventory entries loop using tokio::spawn for concurrent provider resolution
  • Eagerly initialize the SQLite connection pool at startup so the ~1.6s schema check overlaps less with provider resolution

Test plan

  • Verify _goose/providers/list returns the same results as before
  • Confirm startup time improvement via timing logs
  • Run existing test suite to check for regressions

🤖 Generated with Claude Code

matt2e and others added 3 commits April 29, 2026 16:29
Replace the sequential `for` loop in `entries()` with
`futures::future::join_all` so all 47 providers resolve their
identity and configuration concurrently. Each `entry_for_provider`
call is read-only (registry read lock, config reads, SQLite SELECT),
so parallel execution is safe. This should reduce per-call time from
~1.6s to ~200ms (bounded by the slowest single provider at ~208ms).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…solution

The SQLite pool uses connect_lazy_with, so initialization (schema check,
migrations) only triggers on first use — currently inside read_snapshot
during provider inventory. This adds ~1.6s to the critical path.

Spawn a background task to call pool() immediately after SessionManager
creation, so the pool initializes concurrently with provider resolution
(~811ms) and describe_provider work. By the time read_snapshot or
listSessions actually needs the pool, the OnceCell should already be
resolved. This is safe because pool() uses get_or_try_init which handles
concurrent callers correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
join_all runs all futures on the same tokio task, only interleaving at
.await points. Since describe_provider does blocking work (config reads,
hash computation) between awaits, the futures executed sequentially.
Use tokio::spawn to dispatch each provider onto a separate thread from
the tokio thread pool, enabling actual concurrent execution across all
47 providers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2ed8c7d459

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/goose/src/providers/inventory/mod.rs Outdated
matt2e and others added 2 commits April 29, 2026 16:47
Remove implementation detail lines from the comment about eager SQLite
pool initialization, keeping only the intent description per code review
feedback.

Signed-off-by: Matt Toohey <contact@matttoohey.com>
The filter_map chain silently discarded JoinErrors (task panics) and
anyhow::Errors (SQLite/config failures), only filtering Ok(None).
Replace with explicit error handling that propagates JoinError and
inner errors with ?, matching the original sequential behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: be152ca359

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/goose/src/acp/server.rs
Store the pool warmup JoinHandle and abort it in Drop, preventing the
fire-and-forget task from outliving the agent (causing nondeterministic
cleanup failures in tests). Also log a warning if eager init fails,
instead of silently discarding the error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e24e758cf5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/goose/src/acp/server.rs Outdated
@baxen
baxen merged commit 6d873f1 into main Apr 29, 2026
22 of 23 checks passed
@baxen
baxen deleted the perf-list-all-providers branch April 29, 2026 17:23
lifeizhou-ap added a commit that referenced this pull request Apr 30, 2026
* main: (24 commits)
  fix: copy and content improvements in goose2 (#8886)
  feat: make ollama host configurable in goose2 (#8912)
  polish sidebar navigation and project icons (#8896)
  fix: model picker stays usable during provider loading (#8900)
  feat: update provider row after saving credentials (#8914)
  feat: support google model inventory refresh (#8913)
  chore: Added goose 2 UI refactor review skill (#8903)
  blog: goose with peekaboo (#8884)
  blog: Built-in Local Inference blogpost. (#8808)
  perf: parallelize provider resolution and eagerly init SQLite pool (#8899)
  refactor: update goose2 credential management behind provider-scoped ACP/core API (#8887)
  fix: handle acp requests concurrently (#8781)
  build: set LLAMA_STATIC_CRT for Windows CUDA (#8901)
  perf: deduplicate _goose/providers/list RPC call at startup (#8873)
  chore: add a bit more instructions in the release pr (#8890)
  chore: disable spellcheck in model search (#8889)
  add skills to the chat composer (#8881)
  mergeable configs + cleanup (#8378)
  refactor: agent provider to use explicit type states (#8879)
  [goose2] MCP Apps: hydrate and replay app payloads in Goose2 (#8632)
  ...
shafqatevo pushed a commit to shafqatevo/goose that referenced this pull request Aug 7, 2026
…aif-goose#8899)

Signed-off-by: Matt Toohey <contact@matttoohey.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants