-
Notifications
You must be signed in to change notification settings - Fork 715
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move clientCron onto a separate timer (#1387)
The `serverCron()` function contains a variety of maintenance functions and is set up as a timer job, configured to run at a certain rate (hz). The default rate is 10hz (every 100ms). One of the things that `serverCron()` does is to perform maintenance functions on connected clients. Since the number of clients is variable, and can be very large, this could cause latency spikes when the 100ms `serverCron()` task gets invoked. To combat those latency spikes, a feature called "dynamic-hz" was introduced. This feature will run `serverCron()` more often, if there are more clients. The clients get processed up to 200 at a time. The delay for `serverCron()` is shortened with the goal of processing all of the clients every second. The result of this is that some of the other (non-client) maintenance functions also get (unnecessarily) run more often. Like `cronUpdateMemoryStats()` and `databasesCron()`. Logically, it doesn't make sense to run these functions more often, just because we happen to have more clients attached. This PR separates client activities onto a separate, variable, timer. The "dynamic-hz" feature is eliminated. Now, `serverCron` will run at a standard configured rate. The separate clients cron will automatically adjust based on the number of clients. This has the added benefit that often, the 2 crons will fire during separate event loop invocations and will usually avoid the combined latency impact of doing both maintenance activities together. The new timer follows the same rules which were established with the dynamic HZ feature. * The goal is to process all of the clients once per second * We never want to process more than 200 clients in a single invocation (`MAX_CLIENTS_PER_CLOCK_TICK`) * We always process at least 5 clients at a time (`CLIENTS_CRON_MIN_ITERATIONS`) * The minimum rate is determined by HZ The delay (ms) for the new timer is also more precise, computing the number of milliseconds needed to achieve the goal of reaching all of the clients every second. The old dynamic-hz feature just performs a doubling of the HZ until the clients processing rate is achieved (i.e. delays of 100ms, 50ms, 25ms, 12ms...) --------- Signed-off-by: Jim Brunner <[email protected]> Co-authored-by: Binbin <[email protected]>
- Loading branch information
1 parent
2eac2cc
commit c75e866
Showing
8 changed files
with
76 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters