mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
Fix bugs relating to not counting timeouts as circuit builds.
Also use bin midpoints for time values.
This commit is contained in:
parent
67cee75ca2
commit
742e08046f
@ -261,7 +261,7 @@ circuit_build_times_mode(circuit_build_times_t *cbt)
|
|||||||
|
|
||||||
tor_free(histogram);
|
tor_free(histogram);
|
||||||
|
|
||||||
return max_bin*BUILDTIME_BIN_WIDTH;
|
return max_bin*BUILDTIME_BIN_WIDTH+BUILDTIME_BIN_WIDTH/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -291,8 +291,8 @@ circuit_build_times_update_state(circuit_build_times_t *cbt,
|
|||||||
*next = line = tor_malloc_zero(sizeof(config_line_t));
|
*next = line = tor_malloc_zero(sizeof(config_line_t));
|
||||||
line->key = tor_strdup("CircuitBuildTimeBin");
|
line->key = tor_strdup("CircuitBuildTimeBin");
|
||||||
line->value = tor_malloc(25);
|
line->value = tor_malloc(25);
|
||||||
tor_snprintf(line->value, 25, "%d %d", i*BUILDTIME_BIN_WIDTH,
|
tor_snprintf(line->value, 25, "%d %d",
|
||||||
histogram[i]);
|
i*BUILDTIME_BIN_WIDTH+BUILDTIME_BIN_WIDTH/2, histogram[i]);
|
||||||
next = &(line->next);
|
next = &(line->next);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -548,10 +548,12 @@ circuit_build_times_initial_alpha(circuit_build_times_t *cbt,
|
|||||||
static void
|
static void
|
||||||
circuit_build_times_count_pretimeouts(circuit_build_times_t *cbt)
|
circuit_build_times_count_pretimeouts(circuit_build_times_t *cbt)
|
||||||
{
|
{
|
||||||
/* Store a timeout as a random position on this curve. */
|
/* Store a timeout as a random position past the current
|
||||||
|
* cutoff on the pareto curve */
|
||||||
if (cbt->pre_timeouts) {
|
if (cbt->pre_timeouts) {
|
||||||
double timeout_quantile = 1.0-
|
double timeout_quantile = 1.0-
|
||||||
((double)cbt->pre_timeouts)/cbt->total_build_times;
|
((double)cbt->pre_timeouts)/
|
||||||
|
(cbt->pre_timeouts+cbt->total_build_times);
|
||||||
cbt->Xm = circuit_build_times_min(cbt);
|
cbt->Xm = circuit_build_times_min(cbt);
|
||||||
// Use current timeout to get an estimate on alpha
|
// Use current timeout to get an estimate on alpha
|
||||||
circuit_build_times_initial_alpha(cbt, timeout_quantile,
|
circuit_build_times_initial_alpha(cbt, timeout_quantile,
|
||||||
@ -628,7 +630,7 @@ circuit_build_times_check_too_many_timeouts(circuit_build_times_t *cbt)
|
|||||||
double timeout;
|
double timeout;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (cbt->total_build_times < RECENT_CIRCUITS) {
|
if ((cbt->pre_timeouts+cbt->total_build_times) < RECENT_CIRCUITS) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -643,6 +645,7 @@ circuit_build_times_check_too_many_timeouts(circuit_build_times_t *cbt)
|
|||||||
timeout_rate++;
|
timeout_rate++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
timeout_rate += cbt->pre_timeouts;
|
||||||
timeout_rate /= RECENT_CIRCUITS;
|
timeout_rate /= RECENT_CIRCUITS;
|
||||||
|
|
||||||
/* If more than 80% of our recent circuits are timing out,
|
/* If more than 80% of our recent circuits are timing out,
|
||||||
|
Loading…
Reference in New Issue
Block a user