-
Notifications
You must be signed in to change notification settings - Fork 114
fix: make pb image downloads random, remove prewarm from pb protocol #2784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -280,6 +280,10 @@ impl ImageDownloadHandler { | |
let image_size = self.download_inner(ctx, image_config).await?; | ||
let download_duration = download_start_instant.elapsed().as_secs_f64(); | ||
|
||
crate::metrics::DOWNLOAD_IMAGE_RATE | ||
.with_label_values(&[&(start_instant.elapsed().as_nanos() % 100).to_string()]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There appears to be a variable name inconsistency in this code. The metric is using crate::metrics::DOWNLOAD_IMAGE_RATE
.with_label_values(&[&(start_instant.elapsed().as_nanos() % 100).to_string()])
.set(image_size as f64 / download_duration); Spotted by Diamond |
||
.set(image_download_size as f64 / download_duration); | ||
|
||
let convert_start_instant = Instant::now(); | ||
self.convert(ctx, image_config).await?; | ||
let convert_duration = convert_start_instant.elapsed().as_secs_f64(); | ||
|
@@ -531,12 +535,16 @@ impl ImageDownloadHandler { | |
ctx: &Ctx, | ||
image_config: &protocol::Image, | ||
) -> Result<Vec<String>> { | ||
// Get hash from image id | ||
let mut hasher = DefaultHasher::new(); | ||
hasher.write(image_config.id.as_bytes()); | ||
let hash = hasher.finish(); | ||
// // Get hash from image id | ||
// let mut hasher = DefaultHasher::new(); | ||
// hasher.write(image_config.id.as_bytes()); | ||
// let hash = hasher.finish(); | ||
|
||
// let mut rng = ChaCha12Rng::seed_from_u64(hash); | ||
|
||
let mut rng = ChaCha12Rng::seed_from_u64(hash); | ||
// TODO: Replaced hash based randomizer with complete randomness for now | ||
let mut rng = | ||
rand::rngs::StdRng::from_rng(&mut rand::thread_rng()).context("failed creating rng")?; | ||
|
||
// Shuffle based on hash | ||
let mut addresses = self | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current implementation silently continues execution even if all prewarming HTTP requests fail. While errors are logged, there's no mechanism to report the overall success/failure rate or propagate errors to the caller. This could lead to a situation where the system believes prewarming occurred successfully when it actually failed completely.
Consider enhancing the error handling by:
This would provide better visibility into the prewarming process and allow callers to make informed decisions based on the actual outcome.
Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.