Skip to content

Commit

Permalink
dpif-netdev: includes microsecond delta in meter bucket calculation
Browse files Browse the repository at this point in the history
When dp-netdev meter rate is higher than 200Mbps, observe
more than 10% bias from configured rate value with UDP traffic.

In dp-netdev meter, millisecond delta between now and last used
is taken into bucket size calcualtion, while sub-millisecond part
is truncated.

If traffic rate is pretty high, time delta can be few milliseconds,
its ratio to truncated part is less than 10:1, the loss of bucket
size caused by truncated can be observed obviously by commited
traffic rate.

In this patch, microsend delta part is included in calculation
of meter bucket to make it more precise.

Signed-off-by: Jiang Lidong <[email protected]>
Signed-off-by: William Tu <[email protected]>
  • Loading branch information
winter4ling authored and williamtu committed Apr 9, 2020
1 parent e5a9931 commit 5c41c31
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/dpif-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -5735,6 +5735,7 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_,
struct dp_packet *packet;
long long int long_delta_t; /* msec */
uint32_t delta_t; /* msec */
uint32_t delta_in_us; /* usec */
const size_t cnt = dp_packet_batch_size(packets_);
uint32_t bytes, volume;
int exceeded_band[NETDEV_MAX_BURST];
Expand Down Expand Up @@ -5765,6 +5766,9 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_,
Assuming that all racing threads received packets at the same time
to avoid overflow. */
long_delta_t = 0;
delta_in_us = 0;
} else {
delta_in_us = (now - meter->used) % 1000;
}

/* Make sure delta_t will not be too large, so that bucket will not
Expand Down Expand Up @@ -5800,6 +5804,7 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_,

/* Update band's bucket. */
band->bucket += delta_t * band->up.rate;
band->bucket += delta_in_us * band->up.rate / 1000;
if (band->bucket > band->up.burst_size) {
band->bucket = band->up.burst_size;
}
Expand Down

0 comments on commit 5c41c31

Please sign in to comment.