From 93d1a7d1a6172be96e5e3d0e5b008a8294e196ce Mon Sep 17 00:00:00 2001 From: Madhavendra Rathore Date: Mon, 25 May 2026 21:38:15 +0000 Subject: [PATCH 1/2] feat(napi): expose maxConnections on openSession ConnectionOptions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Surfaces the kernel's `HttpConfig::pool_max_idle_per_host` knob to the napi-rs JS surface as `maxConnections?: number` on the `ConnectionOptions` interface for `openSession()`. When absent, the kernel default of 100 (set in `c14c1ff` on this stack) applies. When present, the value flows through `SessionBuilder::http(...)` into the `reqwest` connection pool that the kernel uses for SEA HTTP transport. Mirrors the Python connector's `use_sea=True` backend, which accepts `max_connections` as a kwarg and forwards it to urllib3's `maxsize`. The NodeJS Thrift backend does NOT expose this knob, so this is a SEA-only extension; no parity break. Type round-trip: napi-rs serialises `Option` as JS `number | undefined`. Pool sizes up to `2^32 - 1` fit safely; typical values are in the 10-500 range. Kernel-side change is zero — `HttpConfig` already carries the field, the builder already accepts it. This commit is napi-only. Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore --- napi/src/database.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/napi/src/database.rs b/napi/src/database.rs index b94cafcc..13522020 100644 --- a/napi/src/database.rs +++ b/napi/src/database.rs @@ -28,7 +28,7 @@ use std::collections::HashMap; use std::sync::Arc; use tokio::sync::Mutex; -use databricks_sql_kernel::{AuthConfig, DefaultOpts, Session}; +use databricks_sql_kernel::{AuthConfig, DefaultOpts, HttpConfig, Session}; use crate::connection::Connection; use crate::error::napi_err_from_kernel; @@ -70,6 +70,17 @@ pub struct ConnectionOptions { /// query-tag presets, …). Forwarded verbatim to SEA /// `session_confs`. Unknown keys are rejected server-side. pub session_conf: Option>, + /// Maximum number of pooled HTTP connections per host. Routes + /// through the kernel's [`HttpConfig::pool_max_idle_per_host`]. + /// Tunes the underlying `reqwest` connection pool — higher values + /// reduce reconnect overhead when many statements run + /// concurrently against the same warehouse. `None` falls back to + /// the kernel default (100). Mirrors the Python connector's + /// `max_connections` kwarg on the SEA backend. + /// + /// Napi-rs serialises `u32` as JS `number`; values up to + /// `2^32 - 1` round-trip safely (any reasonable pool size fits). + pub max_connections: Option, } /// Open a Databricks SQL session over PAT auth and return an opaque @@ -115,6 +126,15 @@ pub async fn open_session(options: ConnectionOptions) -> napi::Result Date: Tue, 26 May 2026 10:07:53 +0000 Subject: [PATCH 2/2] fix(napi): always set napi-default pool_max_idle_per_host (100) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make the binding-specific default explicit instead of relying on the kernel core's HttpConfig::default() — that default stays at the conservative kernel value (10), and each binding chooses its own user-facing default when constructing the session. The napi binding's default is 100, matching the JDBC driver's HttpConnectionPoolSize and closing the throughput gap vs the NodeJS Thrift driver's maxSockets: Infinity for bursty workloads (concurrent executeStatement, parallel CloudFetch chunk downloads). Encoded as the public NAPI_DEFAULT_POOL_MAX_IDLE_PER_HOST constant so reviewers and downstream binding authors can see the per-binding default policy. The pyo3 binding inherits the kernel default of 10 (matching Python urllib3's maxsize=10). Supersedes the closed PR #30 which would have lifted the kernel default itself — that conflated 'napi wants 100' with 'every kernel consumer wants 100', and the per-binding split is the right shape. Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore --- napi/src/database.rs | 50 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/napi/src/database.rs b/napi/src/database.rs index 13522020..d2b8fac4 100644 --- a/napi/src/database.rs +++ b/napi/src/database.rs @@ -30,6 +30,20 @@ use tokio::sync::Mutex; use databricks_sql_kernel::{AuthConfig, DefaultOpts, HttpConfig, Session}; +/// NodeJS-driver-appropriate default for `pool_max_idle_per_host`. +/// +/// Applied by [`open_session`] when the JS caller does not pass +/// `maxConnections`. Matches the JDBC driver's `HttpConnectionPoolSize` +/// default (100) and closes the throughput gap vs the NodeJS Thrift +/// driver's `maxSockets: Infinity` pool for bursty workloads +/// (concurrent `executeStatement`, parallel CloudFetch chunk downloads). +/// +/// The kernel core's [`HttpConfig::pool_max_idle_per_host`] default +/// remains at the conservative kernel value (10) — each binding +/// chooses its own user-facing default. The pyo3 binding inherits +/// the kernel default; this constant is napi-specific. +pub const NAPI_DEFAULT_POOL_MAX_IDLE_PER_HOST: usize = 100; + use crate::connection::Connection; use crate::error::napi_err_from_kernel; use crate::runtime; @@ -74,9 +88,19 @@ pub struct ConnectionOptions { /// through the kernel's [`HttpConfig::pool_max_idle_per_host`]. /// Tunes the underlying `reqwest` connection pool — higher values /// reduce reconnect overhead when many statements run - /// concurrently against the same warehouse. `None` falls back to - /// the kernel default (100). Mirrors the Python connector's - /// `max_connections` kwarg on the SEA backend. + /// concurrently against the same warehouse. + /// + /// When the JS caller does NOT provide `maxConnections`, the napi + /// binding applies a NodeJS-driver-appropriate default of + /// [`NAPI_DEFAULT_POOL_MAX_IDLE_PER_HOST`] (100) — chosen to match + /// the JDBC driver's `HttpConnectionPoolSize` default and to close + /// the throughput gap vs the NodeJS Thrift driver's + /// `maxSockets: Infinity` pool for bursty workloads. The kernel + /// core's [`HttpConfig::pool_max_idle_per_host`] default remains + /// at the conservative kernel value (10); each binding chooses + /// its own user-facing default. Mirrors the Python connector's + /// `max_connections` kwarg on the SEA backend, which exposes the + /// knob but keeps its own urllib3-aligned default of 10. /// /// Napi-rs serialises `u32` as JS `number`; values up to /// `2^32 - 1` round-trip safely (any reasonable pool size fits). @@ -127,14 +151,18 @@ pub async fn open_session(options: ConnectionOptions) -> napi::Result