Add consensus parameter for max synthetic quantile.

In case we decide that the timeout rate is now too high due to our
change of the max synthetic quantile value, this consensus parameter
will allow us to restore it to the previous value.
This commit is contained in:
Mike Perry 2010-05-06 14:53:05 -07:00
parent e84025bc2b
commit eecdd94dec
2 changed files with 14 additions and 6 deletions

View File

@ -105,6 +105,14 @@ circuit_build_times_quantile_cutoff(void)
return num/100.0;
}
static double
circuit_build_times_max_synthetic_quantile(void)
{
int32_t num = networkstatus_get_param(NULL, "cbtmaxsynthquantile",
CBT_DEFAULT_MAX_SYNTHETIC_QUANTILE);
return num/100.0;
}
static int32_t
circuit_build_times_test_frequency(void)
{
@ -733,7 +741,7 @@ circuit_build_times_add_timeout_worker(circuit_build_times_t *cbt,
double quantile_cutoff)
{
build_time_t gentime = circuit_build_times_generate_sample(cbt,
quantile_cutoff, CBT_MAX_SYNTHETIC_QUANTILE);
quantile_cutoff, circuit_build_times_max_synthetic_quantile());
if (gentime < (build_time_t)tor_lround(cbt->timeout_ms)) {
log_warn(LD_CIRC,
@ -788,7 +796,7 @@ circuit_build_times_count_pretimeouts(circuit_build_times_t *cbt)
((double)cbt->pre_timeouts)/
(cbt->pre_timeouts+cbt->total_build_times);
/* Make sure it doesn't exceed the synthetic max */
timeout_quantile *= CBT_MAX_SYNTHETIC_QUANTILE;
timeout_quantile *= circuit_build_times_max_synthetic_quantile();
cbt->Xm = circuit_build_times_get_xm(cbt);
tor_assert(cbt->Xm > 0);
/* Use current timeout to get an estimate on alpha */
@ -1060,7 +1068,7 @@ circuit_build_times_filter_timeouts(circuit_build_times_t *cbt)
timeout_rate = circuit_build_times_timeout_rate(cbt);
max_timeout = tor_lround(circuit_build_times_calculate_timeout(cbt,
CBT_MAX_SYNTHETIC_QUANTILE));
circuit_build_times_max_synthetic_quantile()));
for (i = 0; i < CBT_NCIRCUITS_TO_OBSERVE; i++) {
if (cbt->circuit_build_times[i] > max_timeout) {
@ -1069,7 +1077,7 @@ circuit_build_times_filter_timeouts(circuit_build_times_t *cbt)
cbt->circuit_build_times[i] =
MIN(circuit_build_times_generate_sample(cbt,
circuit_build_times_quantile_cutoff(),
CBT_MAX_SYNTHETIC_QUANTILE),
circuit_build_times_max_synthetic_quantile()),
CBT_BUILD_TIME_MAX);
log_debug(LD_CIRC, "Replaced timeout %d with %d", replaced,

View File

@ -3016,9 +3016,9 @@ void entry_guards_free_all(void);
#define CBT_NCIRCUITS_TO_OBSERVE 1000
/** Maximum quantile to use to generate synthetic timeouts.
* We want to stay a bit short of 1.0, because longtail is
* We want to stay a bit short of 100, because longtail is
* loooooooooooooooooooooooooooooooooooooooooooooooooooong. */
#define CBT_MAX_SYNTHETIC_QUANTILE 0.90
#define CBT_DEFAULT_MAX_SYNTHETIC_QUANTILE 90
/** Width of the histogram bins in milliseconds */
#define CBT_BIN_WIDTH ((build_time_t)50)