Skip to content

Commit

Permalink
Update S3ClientConfig to support configurable EventLoop thread count
Browse files Browse the repository at this point in the history
For our use case, we run many mountpoint clients on a single machine and
want to restrict the number of threads each client uses in order to
reduce heap fragmentation and CPU contention.
  • Loading branch information
theworldsbestcoder committed Jan 21, 2025
1 parent d199f67 commit 0f70777
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mountpoint-s3-client/src/s3_crt_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ pub struct S3ClientConfig {
initial_read_window: usize,
network_interface_names: Vec<String>,
telemetry_callback: Option<Arc<dyn OnTelemetry>>,
event_loop_threads: Option<u16>,
}

impl Default for S3ClientConfig {
Expand All @@ -122,6 +123,7 @@ impl Default for S3ClientConfig {
initial_read_window: DEFAULT_PART_SIZE,
network_interface_names: vec![],
telemetry_callback: None,
event_loop_threads: None,
}
}
}
Expand Down Expand Up @@ -230,6 +232,13 @@ impl S3ClientConfig {
self.telemetry_callback = Some(telemetry_callback);
self
}

/// Override the number of threads used by the CRTs AwsEventLoop
#[must_use = "S3ClientConfig follows a builder pattern"]
pub fn event_loop_threads(mut self, event_loop_threads: u16) -> Self {
self.event_loop_threads = Some(event_loop_threads);
self
}
}

/// Authentication configuration for the CRT-based S3 client
Expand Down Expand Up @@ -304,7 +313,7 @@ impl S3CrtClientInner {
fn new(config: S3ClientConfig) -> Result<Self, NewClientError> {
let allocator = Allocator::default();

let mut event_loop_group = EventLoopGroup::new_default(&allocator, None, || {}).unwrap();
let mut event_loop_group = EventLoopGroup::new_default(&allocator, config.event_loop_threads, || {}).unwrap();

let resolver_options = HostResolverDefaultOptions {
max_entries: 8,
Expand Down

0 comments on commit 0f70777

Please sign in to comment.