tor-log-ratelim duration of summarisaion activity wrong under heavy load
If the task which runs the run
loop (ratelim.rs
) doesn't run promptly, the value duration
passed to flush
may be wrong: it's the time we intended to sleep for, but we may have slept for longer. (As I wrote in !1734 (comment 2966920).)
A correct approach would be to record the last Instant
, and subtract the instants to find the duration.
I had a look at doing this. I think Loggable::flush
ought to take an Instant
. However, I became confused by the interlocking state machines. There are appear to be higher-level abstract states that a LogState
can be in (eg, fn activity()
tests n_fail
for nonzeroness) but I didn't find the formal documentation for those abstract states. (Perhaps LogState
should have or contain a bespoke enum.) Anyway, I wasn't sure how to deal with my "last Instant
" and was loathe to add another Option
to LogState
, multiplying the number of concrete states by two, without understanding the abstract states.
So for now I'm going leave this bug unfixed and put it on the back burner.
I have put the Bug label on this ticket even though it will generate wrong log messages only in quite unusual situations.