configurable dynamic stream concurrency scalar

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-12-23 04:32:28 +00:00 committed by strawberry
parent b195107053
commit 7a6d657558
9 changed files with 144 additions and 20 deletions

View file

@ -1626,6 +1626,33 @@ pub struct Config {
#[serde(default = "default_db_pool_queue_mult")]
pub db_pool_queue_mult: usize,
/// Sets the initial value for the concurrency of streams. This value simply
/// allows overriding the default in the code. The default is 32, which is
/// the same as the default in the code. Note this value is itself
/// overridden by the computed stream_width_scale, unless that is disabled;
/// this value can serve as a fixed-width instead.
///
/// default: 32
#[serde(default = "default_stream_width_default")]
pub stream_width_default: usize,
/// Scales the stream width starting from a base value detected for the
/// specific system. The base value is the database pool worker count
/// determined from the hardware queue size (e.g. 32 for SSD or 64 or 128+
/// for NVMe). This float allows scaling the width up or down by multiplying
/// it (e.g. 1.5, 2.0, etc). The maximum result can be the size of the pool
/// queue (see: db_pool_queue_mult) as any larger value will stall the tokio
/// task. The value can also be scaled down (e.g. 0.5) to improve
/// responsiveness for many users at the cost of throughput for each.
///
/// Setting this value to 0.0 causes the stream width to be fixed at the
/// value of stream_width_default. The default is 1.0 to match the
/// capabilities detected for the system.
///
/// default: 1.0
#[serde(default = "default_stream_width_scale")]
pub stream_width_scale: f32,
/// Number of sender task workers; determines sender parallelism. Default is
/// '0' which means the value is determined internally, likely matching the
/// number of tokio worker-threads or number of cores, etc. Override by
@ -2436,3 +2463,7 @@ fn default_db_pool_workers() -> usize {
fn default_db_pool_workers_limit() -> usize { 64 }
fn default_db_pool_queue_mult() -> usize { 4 }
fn default_stream_width_default() -> usize { 32 }
fn default_stream_width_scale() -> f32 { 1.0 }