-
Notifications
You must be signed in to change notification settings - Fork 131
feat: add pending request channel size configuration to ConnectionConfig #1328
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
base: main
Are you sure you want to change the base?
Conversation
See the following report for details: cargo semver-checks output
|
@dhvll CI is failing. |
It's not that important feature, but cpp-rust-driver requires it. See the issue: #1313 |
I'll look into it. |
|
||
/// Set the size of the pending request channel for each connection. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `size` - The maximum number of pending requests per connection. | ||
/// | ||
/// # Notes | ||
/// | ||
/// - This is different from cpp-driver's implementation, which uses a per-RequestProcessor queue. | ||
/// - The default is 2048, a balanced value between performance and memory usage. | ||
/// - Adjust based on your specific workload and system resources. | ||
/// | ||
/// # Example | ||
/// | ||
/// ``` | ||
/// let session = SessionBuilder::new() | ||
/// .connection_config( | ||
/// ConnectionConfig::new() | ||
/// .with_pending_request_channel_size(4096) | ||
/// ) | ||
/// .build() | ||
/// .await?; | ||
/// ``` |
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.
I think it is worth describing what a "pending request" is. I think users may think that it is a request that was sent, but we did not yet receive response to (while in reality it is a request that has not yet been sent).
|
||
// TODO: What should be the size of the channel? | ||
let (sender, receiver) = mpsc::channel(1024); | ||
let (sender, receiver) = mpsc::channel(config.pending_request_channel_size.unwrap_or(1024)); | ||
let (error_sender, error_receiver) = tokio::sync::oneshot::channel(); |
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.
Please remove the TODO comment.
Also you are doing unwrap_or(1024)
, but you wrote in PR description that you changes the default to 2048 - it looks like a mistake.
tablet_sender: None, | ||
|
||
identity: SelfIdentity::default(), | ||
pending_request_channel_size: Some(2048), | ||
} | ||
} | ||
} |
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.
The fact that in connection you wrote .unwrap_or(1024)
(which is a bug) tells me that this approach is too error-prone.
Why use an option here? I don't see anything optional - we need to create the channel, and it needs to have some size. Let's make it just usize.
|
||
identity: SelfIdentity::default(), | ||
pending_request_channel_size: Some(2048), | ||
} | ||
} |
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.
ditto
Make pending request channel size configurable
Changes
Rationale
Usage
Pre-review checklist
./docs/source/
.Fixes:
annotations to PR description.