Skip to content

Commit 2eae615

Browse files
committed
instrument max valid block size
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
1 parent c668011 commit 2eae615

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lading_payload/src/block.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ where
479479
R: Rng + ?Sized,
480480
{
481481
let mut min_block_size = 0;
482+
let mut max_valid_block_size = 0;
482483
let mut rejectset = RejectSet::new((max_block_size * 4).min(1));
483484

484485
info!(
@@ -514,7 +515,11 @@ where
514515
match construct_block(&mut rng, serializer, block_size) {
515516
Ok(block) => {
516517
block_sizes_used += 1;
517-
bytes_remaining = bytes_remaining.saturating_sub(block.total_bytes.get());
518+
let total_bytes = block.total_bytes.get();
519+
if total_bytes > max_valid_block_size {
520+
max_valid_block_size = total_bytes;
521+
}
522+
bytes_remaining = bytes_remaining.saturating_sub(total_bytes);
518523
block_cache.push(block);
519524
}
520525
Err(SpinError::EmptyBlock) => {
@@ -579,8 +584,11 @@ where
579584
let min_block_str = Byte::from_u64(min_block_size.into())
580585
.get_appropriate_unit(byte_unit::UnitType::Binary)
581586
.to_string();
587+
let max_valid_block_str = Byte::from_u64(max_valid_block_size.into())
588+
.get_appropriate_unit(byte_unit::UnitType::Binary)
589+
.to_string();
582590
info!(
583-
"Filled {filled_sum_str} of requested {capacity_sum_str}. Discovered minimum block size of {min_block_str}"
591+
"Filled {filled_sum_str} of requested {capacity_sum_str}. Discovered minimum block size of {min_block_str}, maximum valid {max_valid_block_str}"
584592
);
585593

586594
Ok(block_cache)

0 commit comments

Comments
 (0)