Skip to content

Commit

Permalink
reduce initial micro bursts (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
GIC-de committed Oct 2, 2024
1 parent cc6699d commit 0522f17
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 12 deletions.
26 changes: 23 additions & 3 deletions code/bngblaster/src/bbl_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,22 @@ bbl_stream_io_send(bbl_stream_s *stream)
return PROTOCOL_SUCCESS;
}

/**
* bbl_stream_io_stop
*
* @param io IO handle
*/
void
bbl_stream_io_stop(io_handle_s *io)
{
io_bucket_s *io_bucket = io->bucket_head;
while(io_bucket) {
io_bucket->base = 0;
io_bucket->stream_cur = NULL;
io_bucket = io_bucket->next;
}
}

/**
* bbl_stream_io_send_iter
*
Expand All @@ -1510,9 +1526,13 @@ bbl_stream_io_send_iter(io_handle_s *io, uint64_t now)
} else {
stream = io_bucket->stream_head;
io_bucket->stream_cur = stream;
io_bucket->base += io_bucket->nsec;
if(io_bucket->base < min) {
io_bucket->base = min;
if(io_bucket->base) {
io_bucket->base += io_bucket->nsec;
if(io_bucket->base < min) {
io_bucket->base = min;
}
} else {
io_bucket->base = now - io_bucket->nsec;
}
}
if(io_bucket->base >= now) {
Expand Down
3 changes: 3 additions & 0 deletions code/bngblaster/src/bbl_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ bbl_stream_init();
void
bbl_stream_final();

void
bbl_stream_io_stop(io_handle_s *io);

bbl_stream_s *
bbl_stream_io_send_iter(io_handle_s *io, uint64_t now);

Expand Down
4 changes: 4 additions & 0 deletions code/bngblaster/src/io/io_dpdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ io_dpdk_tx_job(timer_s *timer)
burst = 0;
}
}
} else {
bbl_stream_io_stop(io);
}
if(pcap) {
pcapng_fflush();
Expand Down Expand Up @@ -477,6 +479,8 @@ io_dpdk_thread_tx_run_fn(io_thread_s *thread)
burst = 0;
}
}
} else {
bbl_stream_io_stop(io);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions code/bngblaster/src/io/io_packet_mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ io_packet_mmap_tx_job(timer_s *timer)
}
} else {
if(!(g_traffic && g_init_phase == false && interface->state == INTERFACE_UP)) {
bbl_stream_io_stop(io);
break;
}
stream = bbl_stream_io_send_iter(io, now);
Expand Down Expand Up @@ -342,6 +343,7 @@ io_packet_mmap_thread_tx_run_fn(io_thread_s *thread)
}
} else {
if(!(g_traffic && g_init_phase == false && interface->state == INTERFACE_UP)) {
bbl_stream_io_stop(io);
break;
}
/* Send traffic streams up to allowed burst. */
Expand Down
4 changes: 4 additions & 0 deletions code/bngblaster/src/io/io_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ io_raw_tx_job(timer_s *timer)
}
}
}
} else {
bbl_stream_io_stop(io);
}
if(unlikely(pcap)) {
pcapng_fflush();
Expand Down Expand Up @@ -287,6 +289,8 @@ io_raw_thread_tx_run_fn(io_thread_s *thread)
}
}
}
} else {
bbl_stream_io_stop(io);
}
}
}
Expand Down
13 changes: 4 additions & 9 deletions code/bngblaster/src/io/io_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ bucket_shuffle(io_bucket_s *io_bucket)
}

static void
bucket_smear(io_bucket_s *io_bucket, uint64_t start_nsec)
bucket_smear(io_bucket_s *io_bucket)
{
uint64_t nsec = 0;
uint64_t step_nsec;
bbl_stream_s *stream;

if(io_bucket && io_bucket->stream_count) {
step_nsec = io_bucket->nsec / io_bucket->stream_count;
io_bucket->base = start_nsec - io_bucket->nsec;

io_bucket->base = 0;
io_bucket->stream_cur = NULL;
stream = io_bucket->stream_head;
while(stream) {
nsec += step_nsec;
Expand Down Expand Up @@ -124,14 +124,9 @@ void
io_stream_smear(io_handle_s *io)
{
io_bucket_s *io_bucket = io->bucket_head;
struct timespec now;
uint64_t now_nsec;

clock_gettime(CLOCK_MONOTONIC, &now);
now_nsec = timespec_to_nsec(&now);
while(io_bucket) {
bucket_shuffle(io_bucket);
bucket_smear(io_bucket, now_nsec);
bucket_smear(io_bucket);
io_bucket = io_bucket->next;
}
}
Expand Down

0 comments on commit 0522f17

Please sign in to comment.