Consolidate random sleeps in periodic scripts
Multiple periodic scripts sleep for a random amount of time in order to
mitigate the thundering herd problem. This is bad, because the sum of multiple
uniformly distributed random variables approaches a normal distribution, so the
problem isn't mitigated as effectively as it would be with a single sleep.
This change creates a single configurable anticongestion sleep. periodic will
only sleep if at least one script requires it, and it will never sleep more
than once per invocation. It also won't sleep if periodic was run
interactively, fixing an unrelated longstanding bug.
PR: 217055
PR: 210188