summaryrefslogtreecommitdiffstats
path: root/src/vnet/session/transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/session/transport.c')
-rw-r--r--src/vnet/session/transport.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/vnet/session/transport.c b/src/vnet/session/transport.c
index 967ff5d9cba..a7fd85f5f2e 100644
--- a/src/vnet/session/transport.c
+++ b/src/vnet/session/transport.c
@@ -632,9 +632,9 @@ format_transport_pacer (u8 * s, va_list * args)
now = transport_us_time_now (thread_index);
diff = now - pacer->last_update;
- s = format (s, "rate %lu bucket %lu t/p %.3f last_update %U idle %u",
+ s = format (s, "rate %lu bucket %lu t/p %.3f last_update %U burst %u",
pacer->bytes_per_sec, pacer->bucket, pacer->tokens_per_period,
- format_clib_us_time, diff, pacer->idle_timeout_us);
+ format_clib_us_time, diff, pacer->max_burst);
return s;
}
@@ -644,26 +644,18 @@ spacer_max_burst (spacer_t * pacer, clib_us_time_t time_now)
u64 n_periods = (time_now - pacer->last_update);
u64 inc;
- if (PREDICT_FALSE (n_periods > pacer->idle_timeout_us))
- {
- pacer->last_update = time_now;
- pacer->bucket = TRANSPORT_PACER_MIN_BURST;
- return TRANSPORT_PACER_MIN_BURST;
- }
-
if ((inc = (f32) n_periods * pacer->tokens_per_period) > 10)
{
pacer->last_update = time_now;
- pacer->bucket = clib_min (pacer->bucket + inc, pacer->bytes_per_sec);
+ pacer->bucket = clib_min (pacer->bucket + inc, pacer->max_burst);
}
- return clib_min (pacer->bucket, TRANSPORT_PACER_MAX_BURST);
+ return pacer->bucket > 0 ? pacer->max_burst : 0;
}
static inline void
spacer_update_bucket (spacer_t * pacer, u32 bytes)
{
- ASSERT (pacer->bucket >= bytes);
pacer->bucket -= bytes;
}
@@ -671,11 +663,26 @@ static inline void
spacer_set_pace_rate (spacer_t * pacer, u64 rate_bytes_per_sec,
clib_us_time_t rtt)
{
+ clib_us_time_t max_time;
+
ASSERT (rate_bytes_per_sec != 0);
pacer->bytes_per_sec = rate_bytes_per_sec;
pacer->tokens_per_period = rate_bytes_per_sec * CLIB_US_TIME_PERIOD;
- pacer->idle_timeout_us = clib_max (rtt * TRANSPORT_PACER_IDLE_FACTOR,
- TRANSPORT_PACER_MIN_IDLE);
+
+ /* Allow a min number of bursts per rtt, if their size is acceptable. Goal
+ * is to spread the sending of data over the rtt but to also allow for some
+ * coalescing that can potentially
+ * 1) reduce load on session layer by reducing scheduling frequency for a
+ * session and
+ * 2) optimize sending when tso if available
+ *
+ * Max "time-length" of a burst cannot be less than 1us or more than 1ms.
+ */
+ max_time = rtt / TRANSPORT_PACER_BURSTS_PER_RTT;
+ max_time = clib_clamp (max_time, 1 /* 1us */ , 1000 /* 1ms */ );
+ pacer->max_burst = (rate_bytes_per_sec * max_time) * CLIB_US_TIME_PERIOD;
+ pacer->max_burst = clib_clamp (pacer->max_burst, TRANSPORT_PACER_MIN_BURST,
+ TRANSPORT_PACER_MAX_BURST);
}
static inline u64