Skip to content

Commit ae41e99

Browse files
committed
Use the paged memory pool in Mountpoint
Signed-off-by: Alessandro Passaro <alexpax@amazon.co.uk>
1 parent d07ea37 commit ae41e99

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

mountpoint-s3-fs/examples/mount_from_config.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use mountpoint_s3_fs::{
1919
},
2020
logging::{LoggingConfig, LoggingHandle, error_logger::FileErrorLogger, init_logging},
2121
manifest::{Manifest, ingest_manifest},
22+
memory::PagedPool,
2223
metrics::{self, MetricsSinkHandle},
2324
prefix::Prefix,
2425
s3::config::{ClientConfig, PartConfig, Region, S3Path, TargetThroughputSetting},
@@ -234,8 +235,9 @@ fn mount_filesystem(
234235

235236
// Create the client and runtime
236237
let client_config = config.build_client_config()?;
238+
let pool = PagedPool::new([client_config.part_config.read_size_bytes]);
237239
let client = client_config
238-
.create_client(None)
240+
.create_client(pool.clone(), None)
239241
.context("Failed to create S3 client")?;
240242
let runtime = Runtime::new(client.event_loop_group());
241243

mountpoint-s3-fs/src/s3/config.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use mountpoint_s3_client::{ObjectClient, S3CrtClient, S3RequestError};
1111
use regex::Regex;
1212
use thiserror::Error;
1313

14+
use crate::memory::PagedPool;
1415
use crate::prefix::{Prefix, PrefixError};
1516

1617
/// Configuration for the S3 Client to use in Mountpoint.
@@ -273,15 +274,20 @@ const INITIAL_READ_WINDOW_SIZE: usize = 1024 * 1024 + 128 * 1024;
273274

274275
impl ClientConfig {
275276
/// Create an [S3CrtClient]
276-
pub fn create_client(self, validate_on_s3_path: Option<&S3Path>) -> anyhow::Result<S3CrtClient> {
277+
pub fn create_client(
278+
self,
279+
memory_pool: PagedPool,
280+
validate_on_s3_path: Option<&S3Path>,
281+
) -> anyhow::Result<S3CrtClient> {
277282
let mut client_config = S3ClientConfig::new()
278283
.auth_config(self.auth_config)
279284
.throughput_target_gbps(self.throughput_target.value())
280285
.read_part_size(self.part_config.read_size_bytes)
281286
.write_part_size(self.part_config.write_size_bytes)
282287
.read_backpressure(true)
283288
.initial_read_window(INITIAL_READ_WINDOW_SIZE)
284-
.user_agent(self.user_agent);
289+
.user_agent(self.user_agent)
290+
.memory_pool(memory_pool);
285291
if let Some(interfaces) = self.bind {
286292
client_config = client_config.network_interface_names(interfaces);
287293
}

mountpoint-s3/src/bin/mock-mount-s3.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use mountpoint_s3_client::mock_client::throughput_client::ThroughputMockClient;
1919
use mountpoint_s3_client::mock_client::{MockClient, MockObject};
2020
use mountpoint_s3_client::types::ETag;
2121
use mountpoint_s3_fs::Runtime;
22+
use mountpoint_s3_fs::memory::PagedPool;
2223
use mountpoint_s3_fs::s3::S3Personality;
2324
use mountpoint_s3_fs::s3::config::{ClientConfig, S3Path, TargetThroughputSetting};
2425

@@ -29,6 +30,7 @@ fn main() -> anyhow::Result<()> {
2930

3031
pub fn create_mock_client(
3132
client_config: ClientConfig,
33+
_pool: PagedPool,
3234
s3_path: &S3Path,
3335
personality: Option<S3Personality>,
3436
) -> anyhow::Result<(Arc<ThroughputMockClient>, Runtime, S3Personality)> {

mountpoint-s3/src/run.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use mountpoint_s3_client::{ObjectClient, S3CrtClient};
1010
use mountpoint_s3_fs::data_cache::{DataCacheConfig, ManagedCacheDir};
1111
use mountpoint_s3_fs::fuse::session::FuseSession;
1212
use mountpoint_s3_fs::logging::init_logging;
13+
use mountpoint_s3_fs::memory::PagedPool;
1314
use mountpoint_s3_fs::s3::S3Personality;
1415
use mountpoint_s3_fs::s3::config::{ClientConfig, S3Path};
1516
use mountpoint_s3_fs::{MountpointConfig, Runtime, metrics};
@@ -174,8 +175,17 @@ fn mount(args: CliArgs, client_builder: impl ClientBuilder) -> anyhow::Result<Fu
174175

175176
let client_config = args.client_config(build_info::FULL_VERSION);
176177

178+
// Set up a paged memory pool
179+
let pool = PagedPool::new([
180+
1024 * 1024,
181+
client_config.part_config.read_size_bytes,
182+
client_config.part_config.write_size_bytes,
183+
]);
184+
pool.schedule_trim(Duration::from_secs(60));
185+
177186
let s3_path = args.s3_path()?;
178-
let (client, runtime, s3_personality) = client_builder.build(client_config, &s3_path, args.personality())?;
187+
let (client, runtime, s3_personality) =
188+
client_builder.build(client_config, pool.clone(), &s3_path, args.personality())?;
179189

180190
let bucket_description = args.bucket_description()?;
181191
tracing::debug!("using S3 personality {s3_personality:?} for {bucket_description}");
@@ -208,36 +218,39 @@ pub trait ClientBuilder {
208218
fn build(
209219
self,
210220
client_config: ClientConfig,
221+
pool: PagedPool,
211222
s3_path: &S3Path,
212223
personality: Option<S3Personality>,
213224
) -> anyhow::Result<(Self::Client, Runtime, S3Personality)>;
214225
}
215226

216227
impl<F, C> ClientBuilder for F
217228
where
218-
F: FnOnce(ClientConfig, &S3Path, Option<S3Personality>) -> anyhow::Result<(C, Runtime, S3Personality)>,
229+
F: FnOnce(ClientConfig, PagedPool, &S3Path, Option<S3Personality>) -> anyhow::Result<(C, Runtime, S3Personality)>,
219230
C: ObjectClient + Clone + Send + Sync + 'static,
220231
{
221232
type Client = C;
222233

223234
fn build(
224235
self,
225236
client_config: ClientConfig,
237+
pool: PagedPool,
226238
s3_path: &S3Path,
227239
personality: Option<S3Personality>,
228240
) -> anyhow::Result<(Self::Client, Runtime, S3Personality)> {
229-
self(client_config, s3_path, personality)
241+
self(client_config, pool, s3_path, personality)
230242
}
231243
}
232244

233245
// Create a real S3 client
234246
pub fn create_s3_client(
235247
client_config: ClientConfig,
248+
pool: PagedPool,
236249
s3_path: &S3Path,
237250
personality: Option<S3Personality>,
238251
) -> anyhow::Result<(S3CrtClient, Runtime, S3Personality)> {
239252
let client = client_config
240-
.create_client(Some(s3_path))
253+
.create_client(pool, Some(s3_path))
241254
.context("Failed to create S3 client")?;
242255

243256
let runtime = Runtime::new(client.event_loop_group());

0 commit comments

Comments
 (0)