feat(runtime): make connection pooling configurable#3975
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
@dexhunter is attempting to deploy a commit to the Boundary Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughAdds opt-in HTTP connection pooling for supported BAML clients, provider-aware validation, runtime connection reuse tests, and documentation covering configuration and limitations. ChangesHTTP Connection Pooling
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant BAMLClient
participant create_http_client
participant ReqwestTCPServer
BAMLClient->>create_http_client: Configure enable_connection_pooling
create_http_client->>ReqwestTCPServer: Send requests
ReqwestTCPServer-->>create_http_client: Return HTTP responses
create_http_client-->>BAMLClient: Reuse or recreate connections
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
fern/03-reference/baml/clients/connection-pooling.mdx (1)
34-36: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd links to related documentation pages.
The coding guidelines state that documentation should include well-designed links to guide readers to relevant pages. This page mentions fallback, round-robin, and AWS Bedrock clients but does not link to their respective documentation pages.
🔗 Suggested links
-Connection pooling is not available for fallback or round-robin clients. Set it -on their leaf clients instead. It is also not available for AWS Bedrock clients, -whose HTTP transport is managed by the AWS SDK. +Connection pooling is not available for [fallback](/reference/baml/clients/strategy/fallback) or +[round-robin](/reference/baml/clients/strategy/round-robin) clients. Set it on their leaf +clients instead. It is also not available for [AWS Bedrock](/reference/baml/clients/providers/aws-bedrock) +clients, whose HTTP transport is managed by the AWS SDK.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@fern/03-reference/baml/clients/connection-pooling.mdx` around lines 34 - 36, Add inline links to the documentation pages for fallback clients, round-robin clients, and AWS Bedrock clients in the connection-pooling limitation paragraph. Preserve the existing wording while linking each referenced client type to its corresponding documentation page.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@fern/03-reference/baml/clients/connection-pooling.mdx`:
- Around line 1-3: Add the required subtitle field to the frontmatter of the
“Connection Pooling” document, preserving the existing title and matching the
specified frontmatter format used by other fern/**/*.mdx files.
---
Nitpick comments:
In `@fern/03-reference/baml/clients/connection-pooling.mdx`:
- Around line 34-36: Add inline links to the documentation pages for fallback
clients, round-robin clients, and AWS Bedrock clients in the connection-pooling
limitation paragraph. Preserve the existing wording while linking each
referenced client type to its corresponding documentation page.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e4f337d3-f5ba-4fe0-853d-918adcd9d41b
📒 Files selected for processing (8)
engine/baml-lib/baml/tests/validation_files/client/http_config_aws_pooling.bamlengine/baml-lib/baml/tests/validation_files/client/http_config_invalid_pooling.bamlengine/baml-lib/baml/tests/validation_files/client/http_config_regular_with_total.bamlengine/baml-lib/baml/tests/validation_files/client/http_config_valid.bamlengine/baml-lib/llm-client/src/clients/helpers.rsengine/baml-runtime/src/request/mod.rsfern/03-reference/baml/clients/connection-pooling.mdxfern/docs.yml
|
are you using AWS provider with baml? |
b6265f2 to
7c4a2fd
Compare
|
No, I am not using AWS Bedrock for this path. The target is the regular HTTP-based providers. I kept AWS explicitly unsupported because its HTTP transport is owned by the AWS SDK, so exposing this reqwest pooling option there would be misleading. The motivation is #3072 plus the reproduced connection-count result: 10 requests use 10 connections by default and 1 connection when pooling is explicitly enabled. I have also rebased onto current canary and addressed the documentation review. |
Issue Reference
Changes
Adds an explicit
http.enable_connection_poolingoption for regular HTTP-backed clients.false, preserving the current fork-safe default.fork()caveat, and unsupported client types.In a deterministic local HTTP/1.1 harness, ten sequential requests produced:
falsetrueThis is a 90% reduction in new connections for repeated calls while leaving existing behavior unchanged by default.
Testing
Validation performed:
cargo test -p internal-llm-clientcargo test -p baml-runtimeThe metric harness also verifies response payloads, streaming, retries, cancellation, concurrency, forced connection close, recovery, and a fresh forked child process.
Screenshots
Not applicable.
PR Checklist
Additional Notes
Applications using Python's
fork()start method should create the BAML runtime in each child process instead of inheriting a pooled client from the parent. The new option is disabled by default for this reason.Summary by CodeRabbit
New Features
http.enable_connection_pooling.Documentation
Bug Fixes / Validation
httpconfiguration (e.g., wrong types and unsupported fields liketotal_timeout_ms).Tests