-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement streaming rate buffer (#478)
The current way we calculate rate and friends (increase and delta) is to buffer samples for the whole windowing range and apply the rate function over that buffer. Samples which are used in the next step are retained, and reused for the next step. This approach works well for short rate intervals (up to a few minutes), but it ends up using significant memory when the rate interval is over an hour long. This commit implements a specialized rate buffer which can calculate the rate in a streaming manner, by keeping track of the first and last sample for each evaluation step. In order to account for counter resets, we also store samples that trigger the reset in a separate slice and pass them to the rate function. The advantage of this approach is twofold: * we can use far less memory for instant queries over long rate intervals since we only track the first and last sample for the evaluation step * when using Grafana, the rate interval and step variables are set such that there is a very small overlap between sequential steps (e.g. rate_interval = 1m, step = 45s). This means that the rate buffer should only calculate the value for 2 steps at a time, and can reuse state from past steps for upcoming ones. Signed-off-by: Filip Petkovski <[email protected]>
- Loading branch information
1 parent
580dc96
commit acfee21
Showing
6 changed files
with
269 additions
and
42 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
Oops, something went wrong.