-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
admin: Streaming /stats implementation (#19693)
Commit Message: Implements streaming /stats API for JSON and Text. Prometheus can be done in a follow-up. Additional Description: The speed up with this algorithm is dramatic for the "/stats" endpoint on 10k clusters, improving a 1.76 second CPU/memory burst into less than half a second, and speeding up JSON delivery from 5.2 seconds to 2.5 seconds. There is still a bottleneck is the JSON serialization library, which is needed to ensure we have proper escaping of stat-names with special characters, and a larger bottleneck whenever regex filers are used because std::regex has poor performance. In the future, better mechanisms for filtering can be added, such as an HTML UI for navigating stats by name hierarchy (#18670) or prefix/suffix matching or using RE2. This PR fully resolves #16981 but does not address #16139 at all. It might be possible to generalize the solution here to cover Prometheus by keeping our statss_map_ indexed by tagExtractedStatName, but that would be a whole separate effort, and we'd have to figure out if related-stats could span scopes. This PR partially resolves #18675 but there's still a non-trivial burst of CPU especially when there's a regex filter. #18670 would (arguably) fully resolve #18675. BEFORE: ``` ------------------------------------------------------------------ Benchmark Time CPU Iterations ------------------------------------------------------------------ BM_AllCountersText 1760 ms 1760 ms 1 BM_UsedCountersText 118 ms 118 ms 6 BM_FilteredCountersText 4290 ms 4289 ms 1 BM_AllCountersJson 5221 ms 5218 ms 1 BM_UsedCountersJson 152 ms 152 ms 5 BM_FilteredCountersJson 4162 ms 4161 ms 1 ``` AFTER ``` ------------------------------------------------------------------ Benchmark Time CPU Iterations ------------------------------------------------------------------ BM_AllCountersText 454 ms 454 ms 2 BM_UsedCountersText 37.7 ms 37.7 ms 19 BM_FilteredCountersText 4056 ms 4055 ms 1 BM_AllCountersJson 2707 ms 2706 ms 1 BM_UsedCountersJson 63.4 ms 63.4 ms 11 BM_FilteredCountersJson 4008 ms 4008 ms 1 ``` I also ran a manual test with 100k clusters sending `/stats` to the admin port with output to /dev/null. Before this change, this takes 35 seconds and after this change it takes 7 seconds, and consumes about 2G less memory. These were measured with `time wget ...` and observing the process with `top`. To run that I had to set up the clusters to reference static IP addresses and make the stats-sink interval 299 seconds, as others DNS resolution and stats sinks dominate the CPU and make other measurements difficult. Risk Level: medium -- the stats generation code in admin is largely rewritten and is important in some flows. Testing: //test/... Docs Changes: n/a -- no functional changes in this PR -- just perf improvements Release Notes: n/a Platform Specific Features: n/a Fixes: #16981 Signed-off-by: Joshua Marantz <[email protected]>
- Loading branch information
Showing
25 changed files
with
1,416 additions
and
437 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.