From 3ce38012e84ffd53096be2f459ae9b1ebd40f4ef Mon Sep 17 00:00:00 2001 From: Andrey Kononov Date: Sat, 23 Sep 2023 19:58:02 +0400 Subject: [PATCH] Fix and customization of internal queue size --- CHANGELOG.md | 8 ++++++++ Cargo.toml | 8 +------- src/builder.rs | 20 +++++++++++++++++++- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3af3c2..de5fa2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.0.9] - 2023-09-23 +### Added + - `dispatcher_internal_queue_size` parameter to builder, allowing to customize size of internal queue between dispatcher and connection. + +### Fixed + - Increased size of internal queue between dispatcher and connection, which should significantly increase performance (previously it was degrading rapidly with a lot of parallel requests). + + ## [0.0.8] - 2023-09-05 ### Added - Data-manipulation operations (insert, update, upsert, replace, delete) now return `DmoResponse` with row, returned by operation ([#7](https://github.com/Flowneee/tarantool-rs/issues/7)); diff --git a/Cargo.toml b/Cargo.toml index 9515634..a83e41b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tarantool-rs" description = "Asyncronous tokio-based client for Tarantool" -version = "0.0.8" +version = "0.0.9" edition = "2021" authors = ["Andrey Kononov flowneee3@gmail.com"] license = "MIT" @@ -40,7 +40,6 @@ serde_json = "1" tokio = { version = "1", features = ["full"] } tracing-test = { version = "0.2", features = ["no-env-filter"] } tarantool-test-container = { path = "tarantool-test-container" } -rusty_tarantool = "*" [[example]] name = "cli_client" @@ -61,8 +60,3 @@ harness = false [[bench]] name = "compare" harness = false - -[workspace] -members = [ - "tarantool-test-container", -] diff --git a/src/builder.rs b/src/builder.rs index d045c54..aa75ee5 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -10,6 +10,9 @@ use crate::{ transport::Dispatcher, }; +const DEFAULT_DISPATCHER_INTERNAL_QUEUE_SIZE: usize = 500; +const DEFAULT_SQL_STATEMENT_CACHE_CAPACITY: usize = 500; + /// Interval parameters for background reconnection. #[derive(Clone, Debug, PartialEq)] pub enum ReconnectInterval { @@ -64,6 +67,7 @@ pub struct ConnectionBuilder { connect_timeout: Option, reconnect_interval: Option, sql_statement_cache_capacity: usize, + dispatcher_internal_queue_size: usize, } impl Default for ConnectionBuilder { @@ -76,7 +80,8 @@ impl Default for ConnectionBuilder { transaction_isolation_level: Default::default(), connect_timeout: None, reconnect_interval: Some(ReconnectInterval::default()), - sql_statement_cache_capacity: 100, + sql_statement_cache_capacity: DEFAULT_SQL_STATEMENT_CACHE_CAPACITY, + dispatcher_internal_queue_size: DEFAULT_DISPATCHER_INTERNAL_QUEUE_SIZE, } } } @@ -188,4 +193,17 @@ impl ConnectionBuilder { self.sql_statement_cache_capacity = capacity; self } + + /// Sets size of the internal queue between connection and dispatcher. + /// + /// This queue contains all requests, made from [`Connection`]s/[`Stream`]s/etc. + /// Increasing its size can help if you have a lot of requests, made concurrently + /// and frequently, however this will increase memory consumption slightly. + /// + /// By default set to 500, which should be reasonable compromise between memory + /// (about 50 KB) and performance. + pub fn dispatcher_internal_queue_size(&mut self, size: usize) -> &mut Self { + self.dispatcher_internal_queue_size = size; + self + } }