Skip to content

Commit ac41e23

Browse files
Keivaun Waughfacebook-github-bot
authored andcommitted
Convert VipStats, PoolStats, and ConnectionStats histograms to QuantileStats for memory optimization
Summary: This diff converts all histogram metrics in VipStats, PoolStats, and ConnectionStats to QuantileStats to reduce memory usage while maintaining the same percentile estimates. NOTE: this will change metric values somewhat since QuantileState compute percentiles differently than Histograms. I think this is fine, however, since QuantileStats should be more accurate for head and tail values in the distribution. Reviewed By: dddmello Differential Revision: D79019775 fbshipit-source-id: 16c76ca971a19425c4cfa2842a4f3c8f6bb43623
1 parent 3a0dc4f commit ac41e23

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

third-party/proxygen/src/proxygen/lib/http/stats/ConnectionStats.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,8 @@ MinimalConnectionStats::MinimalConnectionStats(const std::string& prefix,
2929
ingressBodyBytes_.emplace(prefix + "_ingress_body_bytes", SUM, RATE);
3030

3131
totalDuration_.emplace(prefix + "_conn_duration",
32-
100,
33-
0,
34-
5000,
35-
facebook::fb303::AVG,
36-
50,
37-
95,
38-
99);
32+
facebook::stats::ExportTypeConsts::kAvg,
33+
facebook::fb303::QuantileConsts::kP50_P95_P99);
3934
currConns_.emplace(prefix + "_conn");
4035
newConns_.emplace(prefix + "_new_conn", SUM);
4136
currTcpConns_.emplace(prefix + "_tcp_conn");
@@ -71,7 +66,7 @@ void MinimalConnectionStats::recordResponse(
7166
}
7267

7368
void MinimalConnectionStats::recordDuration(size_t duration) {
74-
BaseStats::addToOptionalStat(totalDuration_, duration);
69+
BaseStats::addValueToOptionalStat(totalDuration_, duration);
7570
}
7671

7772
void MinimalConnectionStats::addEgressBytes(size_t bytes) {

third-party/proxygen/src/proxygen/lib/http/stats/ConnectionStats.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212

1313
#include <proxygen/lib/http/stats/TLResponseCodeStats.h>
1414

15+
#include "common/stats/DynamicStats.h"
1516
#include <proxygen/lib/stats/StatsWrapper.h>
1617

1718
namespace proxygen {
1819

20+
using QuantileStatWrapper = facebook::fb303::detail::QuantileStatWrapper;
21+
1922
/**
2023
* Connection stats abstract interface.
2124
*/
@@ -85,7 +88,7 @@ class MinimalConnectionStats : public ConnectionStats {
8588
std::optional<StatsWrapper::TLTimeseriesMinuteAndAllTime> egressBodyBytes_;
8689
std::optional<StatsWrapper::TLTimeseriesMinuteAndAllTime> ingressBodyBytes_;
8790
std::optional<StatsWrapper::TLTimeseriesMinute> upstreamLoadShed_;
88-
std::optional<StatsWrapper::TLHistogram> totalDuration_;
91+
std::optional<QuantileStatWrapper> totalDuration_;
8992

9093
std::optional<StatsWrapper::TLCounter> currConns_;
9194
std::optional<StatsWrapper::TLTimeseries> newConns_;

0 commit comments

Comments
 (0)