Skip to content

Commit

Permalink
Consider backoff configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Mallets committed Jun 7, 2024
1 parent 73cf5ed commit bd08a09
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions io/zenoh-transport/src/common/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ use zenoh_protocol::{
type NanoSeconds = u32;

const RBLEN: usize = QueueSizeConf::MAX;
const TSLOT: NanoSeconds = 100;

// Inner structure to reuse serialization batches
struct StageInRefill {
Expand Down Expand Up @@ -347,15 +346,17 @@ enum Pull {
// Inner structure to keep track and signal backoff operations
#[derive(Clone)]
struct Backoff {
tslot: NanoSeconds,
retry_time: NanoSeconds,
last_bytes: BatchSize,
bytes: Arc<AtomicU16>,
backoff: Arc<AtomicBool>,
}

impl Backoff {
fn new(bytes: Arc<AtomicU16>, backoff: Arc<AtomicBool>) -> Self {
fn new(tslot: NanoSeconds, bytes: Arc<AtomicU16>, backoff: Arc<AtomicBool>) -> Self {
Self {
tslot,
retry_time: 0,
last_bytes: 0,
bytes,
Expand All @@ -365,7 +366,7 @@ impl Backoff {

fn next(&mut self) {
if self.retry_time == 0 {
self.retry_time = TSLOT;
self.retry_time = self.tslot;
self.backoff.store(true, Ordering::Relaxed);
} else {
match self.retry_time.checked_mul(2) {
Expand Down Expand Up @@ -553,7 +554,7 @@ impl TransmissionPipeline {
s_in: StageOutIn {
s_out_r,
current,
backoff: Backoff::new(bytes, backoff),
backoff: Backoff::new(config.backoff.as_nanos() as NanoSeconds, bytes, backoff),
},
s_ref: StageOutRefill { n_ref_w, s_ref_w },
});
Expand Down

0 comments on commit bd08a09

Please sign in to comment.