Skip to content

Commit 59caeec

Browse files
committed
make connection pool size configurable and add throughput logging
1 parent 47107e9 commit 59caeec

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

storage/src/backend/connection.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::str::FromStr;
1010
use std::sync::atomic::{AtomicBool, AtomicI16, AtomicU8, Ordering};
1111
use std::sync::Arc;
1212
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
13-
use std::{fmt, thread};
13+
use std::{env, fmt, thread};
1414

1515
use log::{max_level, Level};
1616

@@ -626,14 +626,19 @@ impl Connection {
626626
} else {
627627
None
628628
};
629+
// get pool size from envvar
630+
let pool_max_idle_per_host = match env::var("REGISTRY_CLIENT_POOL_MAX_IDLE_PER_HOST") {
631+
Ok(val) => val.parse::<usize>().unwrap_or(20),
632+
Err(_) => 20,
633+
};
629634

630635
let mut cb = Client::builder()
631636
.timeout(timeout)
632637
.connect_timeout(connect_timeout)
633638
.redirect(Policy::none())
634639
.use_rustls_tls()
635640
.tcp_keepalive(Some(Duration::from_secs(5 * 60)))
636-
.pool_max_idle_per_host(20);
641+
.pool_max_idle_per_host(pool_max_idle_per_host);
637642

638643
if config.skip_verify {
639644
cb = cb.danger_accept_invalid_certs(true);

storage/src/cache/mod.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,17 @@ pub trait BlobCache: Send + Sync {
270270
)));
271271
}
272272
let duration = Instant::now().duration_since(start).as_millis();
273+
let duration_s = duration as f64 / 1000.0;
274+
let throughput_mbps = blob_size as f64 / duration_s / 1_000_000.0;
275+
273276
debug!(
274-
"read_chunks_from_backend: {} {} {} bytes at {}, duration {}ms",
277+
"read_chunks_from_backend: {} {} {} bytes at {}, duration {}ms, throughput {:.4}Mbps",
275278
std::thread::current().name().unwrap_or_default(),
276279
if prefetch { "prefetch" } else { "fetch" },
277280
blob_size,
278281
blob_offset,
279-
duration
282+
duration,
283+
throughput_mbps
280284
);
281285

282286
let chunks = chunks.iter().map(|v| v.as_ref()).collect();
@@ -328,12 +332,15 @@ pub trait BlobCache: Send + Sync {
328332
}
329333

330334
let duration = Instant::now().duration_since(start).as_millis();
335+
let duration_s = duration as f64 / 1000.0;
336+
let throughput_mbps = chunk.compressed_size() as f64 / duration_s / 1_000_000.0;
331337
debug!(
332-
"read_chunk_from_backend: {} {} bytes at {}, duration {}ms",
338+
"read_chunk_from_backend: {} {} bytes at {}, duration {}ms, throughput {:.4}Mbps",
333339
std::thread::current().name().unwrap_or_default(),
334340
chunk.compressed_size(),
335341
chunk.compressed_offset(),
336-
duration
342+
duration,
343+
throughput_mbps
337344
);
338345
self.validate_chunk_data(chunk, buffer, false)
339346
.map_err(|e| {

0 commit comments

Comments
 (0)