@@ -10,6 +10,7 @@ use mountpoint_s3_client::{ObjectClient, S3CrtClient};
1010use mountpoint_s3_fs:: data_cache:: { DataCacheConfig , ManagedCacheDir } ;
1111use mountpoint_s3_fs:: fuse:: session:: FuseSession ;
1212use mountpoint_s3_fs:: logging:: init_logging;
13+ use mountpoint_s3_fs:: memory:: PagedPool ;
1314use mountpoint_s3_fs:: s3:: S3Personality ;
1415use mountpoint_s3_fs:: s3:: config:: { ClientConfig , S3Path } ;
1516use 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
216227impl < F , C > ClientBuilder for F
217228where
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
234246pub 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