Skip to content

Commit

Permalink
Release 2.24.5
Browse files Browse the repository at this point in the history
- [FEATURE] Improve Delayed ACKs extension and turn it on by default.
- Limit receive history to a finite amount of memory.
  • Loading branch information
Dmitri Tikhonov committed Nov 24, 2020
1 parent 8e6b157 commit f38b395
Show file tree
Hide file tree
Showing 21 changed files with 526 additions and 114 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2020-11-24
- 2.24.5
- [FEATURE] Improve Delayed ACKs extension and turn it on by default.
- Limit receive history to a finite amount of memory.

2020-11-18
- 2.24.4
- [BUGFIX] Check whether ECN counts are set in ACK struct before using
Expand Down
40 changes: 40 additions & 0 deletions bin/test_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1857,6 +1857,11 @@ set_engine_option (struct lsquic_engine_settings *settings,
settings->es_base_plpmtu = atoi(val);
return 0;
}
if (0 == strncmp(name, "ptpc_target", 11))
{
settings->es_ptpc_target = atof(val);
return 0;
}
break;
case 12:
if (0 == strncmp(name, "idle_conn_to", 12))
Expand Down Expand Up @@ -1921,6 +1926,11 @@ set_engine_option (struct lsquic_engine_settings *settings,
settings->es_ext_http_prio = atoi(val);
return 0;
}
if (0 == strncmp(name, "ptpc_int_gain", 13))
{
settings->es_ptpc_int_gain = atof(val);
return 0;
}
break;
case 14:
if (0 == strncmp(name, "max_streams_in", 14))
Expand All @@ -1933,6 +1943,11 @@ set_engine_option (struct lsquic_engine_settings *settings,
settings->es_progress_check = atoi(val);
return 0;
}
if (0 == strncmp(name, "ptpc_prop_gain", 14))
{
settings->es_ptpc_prop_gain = atof(val);
return 0;
}
break;
case 15:
if (0 == strncmp(name, "allow_migration", 15))
Expand All @@ -1945,6 +1960,16 @@ set_engine_option (struct lsquic_engine_settings *settings,
settings->es_grease_quic_bit = atoi(val);
return 0;
}
if (0 == strncmp(name, "ptpc_dyn_target", 15))
{
settings->es_ptpc_dyn_target = atoi(val);
return 0;
}
if (0 == strncmp(name, "ptpc_err_thresh", 15))
{
settings->es_ptpc_err_thresh = atof(val);
return 0;
}
break;
case 16:
if (0 == strncmp(name, "proc_time_thresh", 16))
Expand All @@ -1957,6 +1982,21 @@ set_engine_option (struct lsquic_engine_settings *settings,
settings->es_qpack_experiment = atoi(val);
return 0;
}
if (0 == strncmp(name, "ptpc_periodicity", 16))
{
settings->es_ptpc_periodicity = atoi(val);
return 0;
}
if (0 == strncmp(name, "ptpc_max_packtol", 16))
{
settings->es_ptpc_max_packtol = atoi(val);
return 0;
}
if (0 == strncmp(name, "ptpc_err_divisor", 16))
{
settings->es_ptpc_err_divisor = atof(val);
return 0;
}
break;
case 18:
if (0 == strncmp(name, "qpack_enc_max_size", 18))
Expand Down
5 changes: 1 addition & 4 deletions docs/apiref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -743,9 +743,6 @@ settings structure:

Enable delayed ACKs extension. Allowed values are 0 and 1.

**Warning**: this is an experimental feature. Using it will most likely
lead to degraded performance.

Default value is :macro:`LSQUIC_DF_DELAYED_ACKS`

.. member:: int es_timestamps
Expand Down Expand Up @@ -1036,7 +1033,7 @@ out of date. Please check your :file:`lsquic.h` for actual values.*

.. macro:: LSQUIC_DF_DELAYED_ACKS

Delayed ACKs are off by default.
The Delayed ACKs extension is on by default.

.. macro:: LSQUIC_DF_MAX_UDP_PAYLOAD_SIZE_RX

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# The short X.Y version
version = u'2.24'
# The full version, including alpha/beta/rc tags
release = u'2.24.4'
release = u'2.24.5'


# -- General configuration ---------------------------------------------------
Expand Down
55 changes: 49 additions & 6 deletions include/lsquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern "C" {

#define LSQUIC_MAJOR_VERSION 2
#define LSQUIC_MINOR_VERSION 24
#define LSQUIC_PATCH_VERSION 4
#define LSQUIC_PATCH_VERSION 5

/**
* Engine flags:
Expand Down Expand Up @@ -350,8 +350,21 @@ typedef struct ssl_ctx_st * (*lsquic_lookup_cert_f)(
/** Turn spin bit on by default */
#define LSQUIC_DF_SPIN 1

/** Turn off delayed ACKs extension by default */
#define LSQUIC_DF_DELAYED_ACKS 0
/** Turn on delayed ACKs extension by default */
#define LSQUIC_DF_DELAYED_ACKS 1

/**
* Defaults for the Packet Tolerance PID Controller (PTPC) used by the
* Delayed ACKs extension:
*/
#define LSQUIC_DF_PTPC_PERIODICITY 3
#define LSQUIC_DF_PTPC_MAX_PACKTOL 150
#define LSQUIC_DF_PTPC_DYN_TARGET 1
#define LSQUIC_DF_PTPC_TARGET 1.0
#define LSQUIC_DF_PTPC_PROP_GAIN 0.8
#define LSQUIC_DF_PTPC_INT_GAIN 0.35
#define LSQUIC_DF_PTPC_ERR_THRESH 0.05
#define LSQUIC_DF_PTPC_ERR_DIVISOR 0.05

/** Turn on timestamp extension by default */
#define LSQUIC_DF_TIMESTAMPS 1
Expand Down Expand Up @@ -847,9 +860,6 @@ struct lsquic_engine_settings {
/**
* Enable delayed ACKs extension. Allowed values are 0 and 1.
*
* Warning: this is an experimental feature. Using it will most likely
* lead to degraded performance.
*
* Default value is @ref LSQUIC_DF_DELAYED_ACKS
*/
int es_delayed_acks;
Expand Down Expand Up @@ -962,6 +972,39 @@ struct lsquic_engine_settings {
* Default value is @ref LSQUIC_DF_QPACK_EXPERIMENT.
*/
int es_qpack_experiment;

/**
* Settings for the Packet Tolerance PID Controller (PTPC) used for
* the Delayed ACKs logic. Periodicity is how often the number of
* incoming ACKs is sampled. Periodicity's units is the number of
* RTTs. Target is the average number of incoming ACKs per RTT we
* want to achieve. Error threshold defines the range of error values
* within which no action is taken. For example, error threshold of
* 0.03 means that adjustment actions will be taken only when the
* error is outside of the [-0.03, 0.03] range. Proportional and
* integral gains have their usual meanings described here:
* https://en.wikipedia.org/wiki/PID_controller#Controller_theory
*
* The average is normalized as follows:
* AvgNormalized = Avg * e / Target # Where 'e' is 2.71828...
*
* The error is then calculated as ln(AvgNormalized) - 1. This gives
* us a logarithmic scale that is convenient to use for adjustment
* calculations. The error divisor is used to calculate the packet
* tolerance adjustment:
* Adjustment = Error / ErrorDivisor
*
* WARNING. The library comes with sane defaults. Only fiddle with
* these knobs if you know what you are doing.
*/
unsigned es_ptpc_periodicity; /* LSQUIC_DF_PTPC_PERIODICITY */
unsigned es_ptpc_max_packtol; /* LSQUIC_DF_PTPC_MAX_PACKTOL */
int es_ptpc_dyn_target; /* LSQUIC_DF_PTPC_DYN_TARGET */
float es_ptpc_target, /* LSQUIC_DF_PTPC_TARGET */
es_ptpc_prop_gain, /* LSQUIC_DF_PTPC_PROP_GAIN */
es_ptpc_int_gain, /* LSQUIC_DF_PTPC_INT_GAIN */
es_ptpc_err_thresh, /* LSQUIC_DF_PTPC_ERR_THRESH */
es_ptpc_err_divisor; /* LSQUIC_DF_PTPC_ERR_DIVISOR */
};

/* Initialize `settings' to default values */
Expand Down
1 change: 1 addition & 0 deletions src/liblsquic/lsquic_alarmset.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const char *const lsquic_alid2str[] =
[AL_SESS_TICKET] = "SESS_TICKET",
[AL_BLOCKED_KA] = "BLOCKED_KA",
[AL_MTU_PROBE] = "MTU_PROBE",
[AL_PACK_TOL] = "PACK_TOL",
};


Expand Down
5 changes: 5 additions & 0 deletions src/liblsquic/lsquic_alarmset.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ enum alarm_id {
AL_PATH_CHAL_3,
AL_SESS_TICKET,
AL_BLOCKED_KA, /* Blocked Keep-Alive */
AL_PACK_TOL, /* Calculate packet tolerance */
MAX_LSQUIC_ALARMS
};

Expand All @@ -59,6 +60,7 @@ enum alarm_id_bit {
ALBIT_SESS_TICKET = 1 << AL_SESS_TICKET,
ALBIT_BLOCKED_KA = 1 << AL_BLOCKED_KA,
ALBIT_MTU_PROBE = 1 << AL_MTU_PROBE,
ALBIT_PACK_TOL = 1 << AL_PACK_TOL,
};


Expand Down Expand Up @@ -92,6 +94,9 @@ lsquic_alarmset_init_alarm (lsquic_alarmset_t *, enum alarm_id,
#define lsquic_alarmset_are_set(alarmset, flags) \
((alarmset)->as_armed_set & (flags))

#define lsquic_alarmset_is_inited(alarmset_, al_id_) ( \
(alarmset_)->as_alarms[al_id_].callback)

/* Timers "fire," alarms "ring." */
void
lsquic_alarmset_ring_expired (lsquic_alarmset_t *, lsquic_time_t now);
Expand Down
19 changes: 17 additions & 2 deletions src/liblsquic/lsquic_enc_sess_ietf.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,10 @@ gen_trans_params (struct enc_sess_iquic *enc_sess, unsigned char *buf,
}
if (settings->es_delayed_acks)
{
params.tp_numerics[TPI_MIN_ACK_DELAY] = 10000; /* TODO: make into a constant? make configurable? */
params.tp_numerics[TPI_MIN_ACK_DELAY] = TP_MIN_ACK_DELAY;
params.tp_set |= 1 << TPI_MIN_ACK_DELAY;
params.tp_numerics[TPI_MIN_ACK_DELAY_02] = TP_MIN_ACK_DELAY;
params.tp_set |= 1 << TPI_MIN_ACK_DELAY_02;
}
if (settings->es_timestamps)
{
Expand Down Expand Up @@ -1687,6 +1689,17 @@ get_peer_transport_params (struct enc_sess_iquic *enc_sess)
}

LSQ_DEBUG("have peer transport parameters (%zu bytes)", bufsz);
if (LSQ_LOG_ENABLED(LSQ_LOG_DEBUG))
{
params_str = lsquic_mm_get_4k(&enc_sess->esi_enpub->enp_mm);
if (params_str)
{
lsquic_hexdump(params_buf, bufsz, params_str, 0x1000);
LSQ_DEBUG("transport parameters (%zd bytes):\n%s", bufsz,
params_str);
lsquic_mm_put_4k(&enc_sess->esi_enpub->enp_mm, params_str);
}
}
if (0 > (version == LSQVER_ID27 ? lsquic_tp_decode_27
: lsquic_tp_decode)(params_buf, bufsz,
!(enc_sess->esi_flags & ESI_SERVER),
Expand Down Expand Up @@ -3343,8 +3356,10 @@ lsquic_enc_sess_ietf_gen_quic_ctx (
}
if (settings->es_delayed_acks)
{
params.tp_numerics[TPI_MIN_ACK_DELAY] = 10000; /* TODO: make into a constant? make configurable? */
params.tp_numerics[TPI_MIN_ACK_DELAY] = TP_MIN_ACK_DELAY;
params.tp_set |= 1 << TPI_MIN_ACK_DELAY;
params.tp_numerics[TPI_MIN_ACK_DELAY_02] = TP_MIN_ACK_DELAY;
params.tp_set |= 1 << TPI_MIN_ACK_DELAY_02;
}
if (settings->es_timestamps)
{
Expand Down
8 changes: 8 additions & 0 deletions src/liblsquic/lsquic_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,14 @@ lsquic_engine_init_settings (struct lsquic_engine_settings *settings,
settings->es_cc_rtt_thresh = LSQUIC_DF_CC_RTT_THRESH;
settings->es_optimistic_nat = LSQUIC_DF_OPTIMISTIC_NAT;
settings->es_ext_http_prio = LSQUIC_DF_EXT_HTTP_PRIO;
settings->es_ptpc_periodicity= LSQUIC_DF_PTPC_PERIODICITY;
settings->es_ptpc_max_packtol= LSQUIC_DF_PTPC_MAX_PACKTOL;
settings->es_ptpc_dyn_target = LSQUIC_DF_PTPC_DYN_TARGET;
settings->es_ptpc_target = LSQUIC_DF_PTPC_TARGET;
settings->es_ptpc_prop_gain = LSQUIC_DF_PTPC_PROP_GAIN;
settings->es_ptpc_int_gain = LSQUIC_DF_PTPC_INT_GAIN;
settings->es_ptpc_err_thresh = LSQUIC_DF_PTPC_ERR_THRESH;
settings->es_ptpc_err_divisor= LSQUIC_DF_PTPC_ERR_DIVISOR;
}


Expand Down
7 changes: 5 additions & 2 deletions src/liblsquic/lsquic_full_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ enum stream_if { STREAM_IF_STD, STREAM_IF_HSK, STREAM_IF_HDR, N_STREAM_IFS };
#define MAX_RETR_PACKETS_SINCE_LAST_ACK 2
#define ACK_TIMEOUT 25000

/* Maximum number of ACK ranges that can fit into gQUIC ACK frame */
#define MAX_ACK_RANGES 256

/* IMPORTANT: Keep values of FC_SERVER and FC_HTTP same as LSENG_SERVER
* and LSENG_HTTP.
*/
Expand Down Expand Up @@ -661,7 +664,7 @@ new_conn_common (lsquic_cid_t cid, struct lsquic_engine_public *enpub,
conn->fc_pub.all_streams = lsquic_hash_create();
if (!conn->fc_pub.all_streams)
goto cleanup_on_error;
lsquic_rechist_init(&conn->fc_rechist, 0);
lsquic_rechist_init(&conn->fc_rechist, 0, MAX_ACK_RANGES);
if (conn->fc_flags & FC_HTTP)
{
conn->fc_pub.u.gquic.hs = lsquic_headers_stream_new(
Expand Down Expand Up @@ -4411,7 +4414,7 @@ lsquic_gquic_full_conn_srej (struct lsquic_conn *lconn)

/* Reset receive history */
lsquic_rechist_cleanup(&conn->fc_rechist);
lsquic_rechist_init(&conn->fc_rechist, 0);
lsquic_rechist_init(&conn->fc_rechist, 0, MAX_ACK_RANGES);

/* Reset send controller state */
lsquic_send_ctl_cleanup(&conn->fc_send_ctl);
Expand Down
Loading

0 comments on commit f38b395

Please sign in to comment.