aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-09-01 10:03:40 -0700
committerGravatar Craig Tiller <ctiller@google.com>2017-09-01 10:03:40 -0700
commitda5cd59ed3f383318fb01b1bf461489cc828d453 (patch)
tree5c42d6faa538ab9068559624d7d56e983350854a /src/core
parent357f3f61623b95654216432aff4e9bb4e1c9b779 (diff)
Restrict histograms to integral boundaries
Diffstat (limited to 'src/core')
-rw-r--r--src/core/lib/debug/stats.c6
-rw-r--r--src/core/lib/debug/stats.h2
-rw-r--r--src/core/lib/debug/stats_data.c166
-rw-r--r--src/core/lib/debug/stats_data.h12
4 files changed, 38 insertions, 148 deletions
diff --git a/src/core/lib/debug/stats.c b/src/core/lib/debug/stats.c
index 5079ed2ffa..a65dfe49b1 100644
--- a/src/core/lib/debug/stats.c
+++ b/src/core/lib/debug/stats.c
@@ -63,7 +63,7 @@ void grpc_stats_diff(const grpc_stats_data *b, const grpc_stats_data *a,
}
int grpc_stats_histo_find_bucket_slow(grpc_exec_ctx *exec_ctx, double value,
- const double *table, int table_size) {
+ const int *table, int table_size) {
GRPC_STATS_INC_HISTOGRAM_SLOW_LOOKUPS(exec_ctx);
if (value < 0.0) return 0;
if (value >= table[table_size - 1]) return table_size - 1;
@@ -92,7 +92,7 @@ size_t grpc_stats_histo_count(const grpc_stats_data *stats,
}
static double threshold_for_count_below(const gpr_atm *bucket_counts,
- const double *bucket_boundaries,
+ const int *bucket_boundaries,
int num_buckets, double count_below) {
double count_so_far;
double lower_bound;
@@ -163,7 +163,7 @@ char *grpc_stats_data_as_json(const grpc_stats_data *data) {
gpr_asprintf(&tmp, "], \"%s_bkt\": [", grpc_stats_histogram_name[i]);
gpr_strvec_add(&v, tmp);
for (int j = 0; j < grpc_stats_histo_buckets[i]; j++) {
- gpr_asprintf(&tmp, "%s%lf", j == 0 ? "" : ",",
+ gpr_asprintf(&tmp, "%s%d", j == 0 ? "" : ",",
grpc_stats_histo_bucket_boundaries[i][j]);
gpr_strvec_add(&v, tmp);
}
diff --git a/src/core/lib/debug/stats.h b/src/core/lib/debug/stats.h
index c440ab3b66..9d729c20f4 100644
--- a/src/core/lib/debug/stats.h
+++ b/src/core/lib/debug/stats.h
@@ -51,7 +51,7 @@ void grpc_stats_diff(const grpc_stats_data *b, const grpc_stats_data *a,
grpc_stats_data *c);
char *grpc_stats_data_as_json(const grpc_stats_data *data);
int grpc_stats_histo_find_bucket_slow(grpc_exec_ctx *exec_ctx, double value,
- const double *table, int table_size);
+ const int *table, int table_size);
double grpc_stats_histo_percentile(const grpc_stats_data *data,
grpc_stats_histograms histogram,
double percentile);
diff --git a/src/core/lib/debug/stats_data.c b/src/core/lib/debug/stats_data.c
index 9277ee57b2..47f482bd1b 100644
--- a/src/core/lib/debug/stats_data.c
+++ b/src/core/lib/debug/stats_data.c
@@ -50,146 +50,36 @@ const char *grpc_stats_histogram_name[GRPC_STATS_HISTOGRAM_COUNT] = {
"tcp_write_size", "tcp_write_iov_size", "tcp_read_size",
"tcp_read_offer", "tcp_read_iov_size", "http2_send_message_size",
};
-const double grpc_stats_table_0[64] = {0,
- 1,
- 2,
- 3,
- 4,
- 5.17974600698,
- 6.70744217421,
- 8.68571170472,
- 11.2474451301,
- 14.5647272503,
- 18.8603969544,
- 24.4230164536,
- 31.6262554885,
- 40.9539926456,
- 53.032819969,
- 68.6741343683,
- 88.9286433193,
- 115.156946285,
- 149.120933174,
- 193.102139541,
- 250.055009057,
- 323.805358672,
- 419.307378404,
- 542.976429747,
- 703.119998467,
- 910.495751121,
- 1179.03418281,
- 1526.77440013,
- 1977.07590065,
- 2560.18775048,
- 3315.28056941,
- 4293.07782286,
- 5559.26317765,
- 7198.89281155,
- 9322.10907382,
- 12071.5393129,
- 15631.8768886,
- 20242.2879738,
- 26212.4775761,
- 33943.4940145,
- 43954.6693961,
- 56918.5058232,
- 73705.8508152,
- 95444.3966128,
- 123594.433061,
- 160046.942783,
- 207250.628202,
- 268376.403469,
- 347530.401059,
- 450029.801797,
- 582760.01722,
- 754637.218056,
- 977207.279236,
- 1265421.37565,
- 1638640.32942,
- 2121935.1758,
- 2747771.31348,
- 3558189.37227,
- 4607629.29828,
- 5966587.36485,
- 7726351.7696,
- 10005134.9318,
- 12956014.428,
- 16777216.0};
+const int grpc_stats_table_0[64] = {
+ 0, 1, 2, 3, 4, 6, 8, 11,
+ 15, 20, 26, 34, 44, 57, 74, 96,
+ 124, 160, 206, 265, 341, 439, 565, 727,
+ 935, 1202, 1546, 1988, 2556, 3286, 4225, 5432,
+ 6983, 8977, 11540, 14834, 19069, 24513, 31510, 40505,
+ 52067, 66929, 86033, 110590, 142157, 182734, 234893, 301940,
+ 388125, 498910, 641316, 824370, 1059674, 1362141, 1750943, 2250722,
+ 2893155, 3718960, 4780478, 6144988, 7898976, 10153611, 13051794, 16777216};
const uint8_t grpc_stats_table_1[87] = {
- 0, 1, 3, 3, 4, 6, 6, 7, 9, 9, 10, 12, 12, 13, 15, 15, 16, 18,
- 18, 19, 21, 21, 22, 24, 24, 25, 27, 27, 28, 30, 30, 31, 32, 34, 34, 36,
- 36, 37, 39, 39, 40, 42, 42, 43, 44, 46, 46, 47, 49, 49, 51, 51, 52, 53,
- 55, 55, 56, 58, 58, 59, 61, 61, 63, 63, 64, 65, 67, 67, 68, 70, 70, 71,
- 73, 73, 75, 75, 76, 77, 79, 79, 80, 82, 82, 83, 85, 85, 87};
-const double grpc_stats_table_2[64] = {0,
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9,
- 10,
- 11,
- 12.0020736244,
- 13.0954337532,
- 14.2883963681,
- 15.5900350167,
- 17.0102498252,
- 18.5598427974,
- 20.2505999737,
- 22.0953810747,
- 24.1082173107,
- 26.3044181014,
- 28.7006875181,
- 31.315251333,
- 34.1679956422,
- 37.2806181177,
- 40.6767930374,
- 44.3823513489,
- 48.4254771375,
- 52.8369219909,
- 57.6502388927,
- 62.902037423,
- 68.6322622068,
- 74.8844967285,
- 81.7062948236,
- 89.1495423679,
- 97.2708519163,
- 106.131993291,
- 115.800363399,
- 126.34949884,
- 137.859635225,
- 150.418317437,
- 164.121065485,
- 179.072101023,
- 195.38514005,
- 213.184257818,
- 232.604832535,
- 253.794575043,
- 276.914652285,
- 302.140913126,
- 329.665225843,
- 359.696937452,
- 392.464465978,
- 428.217037783,
- 467.226583154,
- 509.78980457,
- 556.230433401,
- 606.901692163,
- 662.1889811,
- 722.512809492,
- 788.331994007,
- 860.147148411,
- 938.504491184,
- 1024.0};
-const uint8_t grpc_stats_table_3[52] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
- 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 52};
+ 1, 1, 3, 3, 4, 6, 6, 8, 8, 9, 11, 11, 12, 14, 14, 15, 17, 17,
+ 18, 20, 20, 21, 23, 23, 24, 25, 27, 27, 28, 30, 30, 31, 33, 33, 34, 35,
+ 37, 37, 39, 39, 40, 41, 43, 43, 44, 46, 46, 47, 48, 50, 50, 51, 53, 53,
+ 55, 55, 56, 57, 59, 59, 60, 62, 62, 63, 64, 66, 66, 67, 69, 69, 71, 71,
+ 72, 73, 75, 75, 76, 78, 78, 79, 80, 82, 82, 83, 85, 85, 87};
+const int grpc_stats_table_2[64] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13,
+ 15, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 49,
+ 54, 59, 64, 70, 76, 83, 90, 98, 106, 115, 125, 136, 147,
+ 159, 172, 186, 201, 218, 236, 255, 276, 299, 323, 349, 377, 408,
+ 441, 477, 515, 556, 601, 649, 701, 757, 817, 881, 950, 1024};
+const uint8_t grpc_stats_table_3[104] = {
+ 2, 2, 2, 6, 6, 6, 6, 9, 9, 9, 11, 11, 13, 13, 15, 15, 17, 17,
+ 20, 20, 20, 23, 23, 23, 25, 25, 26, 28, 28, 30, 30, 32, 32, 35, 35, 35,
+ 37, 37, 40, 40, 40, 41, 43, 43, 44, 46, 46, 48, 48, 50, 50, 52, 52, 55,
+ 55, 55, 57, 57, 58, 59, 61, 61, 63, 63, 65, 65, 67, 67, 69, 69, 71, 71,
+ 73, 73, 74, 76, 76, 77, 79, 79, 81, 81, 83, 83, 85, 85, 88, 88, 88, 89,
+ 90, 92, 92, 93, 95, 95, 97, 97, 99, 99, 101, 101, 104, 104};
const int grpc_stats_histo_buckets[6] = {64, 64, 64, 64, 64, 64};
const int grpc_stats_histo_start[6] = {0, 64, 128, 192, 256, 320};
-const double *const grpc_stats_histo_bucket_boundaries[6] = {
+const int *const grpc_stats_histo_bucket_boundaries[6] = {
grpc_stats_table_0, grpc_stats_table_2, grpc_stats_table_0,
grpc_stats_table_0, grpc_stats_table_2, grpc_stats_table_0};
diff --git a/src/core/lib/debug/stats_data.h b/src/core/lib/debug/stats_data.h
index 4d1078dfdb..5350264c03 100644
--- a/src/core/lib/debug/stats_data.h
+++ b/src/core/lib/debug/stats_data.h
@@ -177,7 +177,7 @@ typedef enum {
if (_val.uint < 4652218415073722368ull) { \
GRPC_STATS_INC_HISTOGRAM( \
(exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE, \
- grpc_stats_table_3[((_val.uint - 4622945017495814144ull) >> 49)]); \
+ grpc_stats_table_3[((_val.uint - 4622945017495814144ull) >> 48)]); \
} else { \
GRPC_STATS_INC_HISTOGRAM( \
(exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE, \
@@ -249,7 +249,7 @@ typedef enum {
if (_val.uint < 4652218415073722368ull) { \
GRPC_STATS_INC_HISTOGRAM( \
(exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_IOV_SIZE, \
- grpc_stats_table_3[((_val.uint - 4622945017495814144ull) >> 49)]); \
+ grpc_stats_table_3[((_val.uint - 4622945017495814144ull) >> 48)]); \
} else { \
GRPC_STATS_INC_HISTOGRAM( \
(exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_IOV_SIZE, \
@@ -283,12 +283,12 @@ typedef enum {
} \
} \
} while (false)
-extern const double grpc_stats_table_0[64];
+extern const int grpc_stats_table_0[64];
extern const uint8_t grpc_stats_table_1[87];
-extern const double grpc_stats_table_2[64];
-extern const uint8_t grpc_stats_table_3[52];
+extern const int grpc_stats_table_2[64];
+extern const uint8_t grpc_stats_table_3[104];
extern const int grpc_stats_histo_buckets[6];
extern const int grpc_stats_histo_start[6];
-extern const double *const grpc_stats_histo_bucket_boundaries[6];
+extern const int *const grpc_stats_histo_bucket_boundaries[6];
#endif /* GRPC_CORE_LIB_DEBUG_STATS_DATA_H */