-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release the GVL when executing a prepared statement. #884
Conversation
This change allows the Ruby VM to continue executing other Ruby threads while the DuckDB prepared statement is being executed.
WalkthroughThis PR introduces a new structure ( Changes
Sequence Diagram(s)sequenceDiagram
participant RubyThread as Ruby Thread
participant GVL as Ruby VM (GVL)
participant Exec as execute_nogvl
participant DB as DuckDB Statement
RubyThread->>GVL: Call execute prepared statement
GVL->>Exec: Release GVL via rb_thread_call_without_gvl
Exec->>DB: Execute prepared statement
DB-->>Exec: Return result or error
Exec-->>GVL: Return execution outcome
GVL-->>RubyThread: Resume with result/error
Assessment against linked issues
Possibly related issues
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
⏰ Context from checks skipped due to timeout of 90000ms (18)
🔇 Additional comments (7)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your great work!!!
This change allows the Ruby VM to continue executing other Ruby threads while the DuckDB prepared statement is being executed.
There are many other methods that are candidates for this same treatment. This PR addresses only execution of a prepared statement, which is also what
DuckDB::Connection#query
uses. If accepted, we could adopt a similar approach for other high-value functions.Ideally, we'd also be able to give Ruby the
duckdb_interrupt
function to handle signals, etc, but it seems there is nothing in the DuckDB C API that lets us interrupt a prepared statement, only a connection. (And it doesn't seem safe to interrupt a connection without reliably being able to know our given prepared statement is the active query on the connection.)Locally, this doesn't seem to have an effect on the performance of benchmarks, but presumably someone doing a whole lot of tiny transactions may be better able to detect it.
This fixes #873 specifically, but we'll want to follow up with more if we determine this is a path we want to take.
Summary by CodeRabbit
New Features
Chores