Conversation
timkpaine
reviewed
Jul 7, 2026
| # Struct channels (and with the host core count), every DuckDBState shares a single process-wide DuckDB | ||
| # instance -- each state operates on its own cursor -- so the pool is created once and its size is a | ||
| # single global knob. See https://github.com/Point72/csp-gateway/issues/292 | ||
| _DUCKDB_THREADS_ORIGINAL = 1 |
Member
There was a problem hiding this comment.
I think we should probably initialize to something like min(os.cpu_count(), 4) or something
State created one DuckDB connection per Struct channel, and DuckDB sizes its worker pool to the core count per instance, so threads scaled as channels x (cores - 1) and could exhaust the host thread limit. All DuckDBState objects now share one process-wide instance (each with its own cursor); the pool defaults to threads=1 and is tunable via modify_duckdb_threads / restore_duckdb_threads. Signed-off-by: Arham Chopra <arham.chopra@cubistsystematic.com>
Contributor
Test Results652 tests 644 ✅ 7m 37s ⏱️ Results for commit e670421. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #299 +/- ##
==========================================
+ Coverage 87.55% 87.64% +0.09%
==========================================
Files 143 143
Lines 14849 14943 +94
==========================================
+ Hits 13001 13097 +96
+ Misses 1848 1846 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Description
State created one DuckDB connection per Struct channel, and DuckDB sizes its worker pool to the core count per instance, so threads scaled as channels x (cores - 1) and could exhaust the host thread limit. All DuckDBState objects now share one process-wide instance (each with its own cursor); the pool defaults to threads=1 and is tunable via modify_duckdb_threads / restore_duckdb_threads.
This fixes #292.
Type of Change
Checklist
make lint)make test)