Bug 1922661 - Migrate NETWORK_CACHE_V2_MISS_TIME_MS, NETWORK_CACHE_HIT_MISS_STAT_PER_CACHE_SIZE, and NETWORK_CACHE_HIT_RATE_PER_CACHE_SIZE probes to glean r=acreskey,necko-reviewers,valentin

Differential Revision: https://phabricator.services.mozilla.com/D227697
This commit is contained in:
Sean 2024-11-05 18:30:50 +00:00
parent 56c00789dc
commit b963e7c0de
5 changed files with 85 additions and 48 deletions

View File

@ -367,15 +367,11 @@ void DetailedCacheHitTelemetry::HitRate::AddRecord(ERecType aType) {
}
}
uint32_t DetailedCacheHitTelemetry::HitRate::GetHitRateBucket(
uint32_t aNumOfBuckets) const {
uint32_t bucketIdx = (aNumOfBuckets * mHitCnt) / (mHitCnt + mMissCnt);
if (bucketIdx ==
aNumOfBuckets) { // make sure 100% falls into the last bucket
--bucketIdx;
uint32_t DetailedCacheHitTelemetry::HitRate::GetHitRateBucket() const {
if (mHitCnt + mMissCnt == 0) {
return 0;
}
return bucketIdx;
return (100 * mHitCnt) / (mHitCnt + mMissCnt);
}
uint32_t DetailedCacheHitTelemetry::HitRate::Count() {
@ -408,23 +404,40 @@ void DetailedCacheHitTelemetry::AddRecord(ERecType aType,
rangeIdx = kNumOfRanges - 1;
}
uint32_t hitMissValue = 2 * rangeIdx; // 2 values per range
if (aType == MISS) { // The order is HIT, MISS
++hitMissValue;
#ifndef ANDROID
nsAutoCString hitMissValue;
if (aType == HIT) {
hitMissValue.AppendLiteral("Hit ");
} else {
hitMissValue.AppendLiteral("Miss ");
}
uint32_t lowerBound = rangeIdx * kRangeSize;
if (rangeIdx < kNumOfRanges - 1) {
uint32_t upperBound = (rangeIdx + 1) * kRangeSize - 1;
hitMissValue.AppendInt(lowerBound);
hitMissValue.AppendLiteral("-");
hitMissValue.AppendInt(upperBound);
} else {
// Since no upper limit
hitMissValue.AppendInt(lowerBound);
hitMissValue.AppendLiteral("+");
}
#endif
StaticMutexAutoLock lock(sLock);
if (aType == MISS) {
mozilla::Telemetry::AccumulateTimeDelta(
mozilla::Telemetry::NETWORK_CACHE_V2_MISS_TIME_MS, aLoadStart);
mozilla::glean::network::cache_miss_time.AccumulateRawDuration(
TimeStamp::Now() - aLoadStart);
} else {
mozilla::glean::network::cache_hit_time.AccumulateRawDuration(
TimeStamp::Now() - aLoadStart);
}
Telemetry::Accumulate(Telemetry::NETWORK_CACHE_HIT_MISS_STAT_PER_CACHE_SIZE,
hitMissValue);
#ifndef ANDROID
mozilla::glean::network::cache_hit_miss_stat_per_cache_size.Get(hitMissValue)
.Add(1);
#endif
sHRStats[rangeIdx].AddRecord(aType);
++sRecordCnt;
@ -437,15 +450,14 @@ void DetailedCacheHitTelemetry::AddRecord(ERecType aType,
for (uint32_t i = 0; i < kNumOfRanges; ++i) {
if (sHRStats[i].Count() >= kHitRateSamplesReportLimit) {
// The telemetry enums are grouped by buckets as follows:
// Telemetry value : 0,1,2,3, ... ,19,20,21,22, ... ,398,399
// Hit rate bucket : 0,0,0,0, ... , 0, 1, 1, 1, ... , 19, 19
// Cache size range: 0,1,2,3, ... ,19, 0, 1, 2, ... , 18, 19
uint32_t bucketOffset =
sHRStats[i].GetHitRateBucket(kHitRateBuckets) * kNumOfRanges;
#ifndef ANDROID
nsAutoCString cacheSizeIdx;
cacheSizeIdx.AppendInt(i);
uint32_t hitRateBucket = sHRStats[i].GetHitRateBucket();
Telemetry::Accumulate(Telemetry::NETWORK_CACHE_HIT_RATE_PER_CACHE_SIZE,
bucketOffset + i);
mozilla::glean::network::cache_hit_rate_per_cache_size.Get(cacheSizeIdx)
.AccumulateSingleSample(hitRateBucket);
#endif
sHRStats[i].Reset();
}
}

View File

@ -98,9 +98,7 @@ class DetailedCacheHitTelemetry {
HitRate();
void AddRecord(ERecType aType);
// Returns the bucket index that the current hit rate falls into according
// to the given aNumOfBuckets.
uint32_t GetHitRateBucket(uint32_t aNumOfBuckets) const;
uint32_t GetHitRateBucket() const;
uint32_t Count();
void Reset();
@ -113,6 +111,8 @@ class DetailedCacheHitTelemetry {
// 5001-10000, ... , 95001- )
static const uint32_t kRangeSize = 5000;
static const uint32_t kNumOfRanges = 20;
static const uint32_t kPercentageRange = 5;
static const uint32_t kMaxPercentage = 100;
// Use the same ranges to report an average hit rate. Report the hit rates
// (and reset the counters) every kTotalSamplesReportLimit samples.

View File

@ -203,6 +203,52 @@ network:
- necko@mozilla.com
expires: never
cache_miss_time:
type: timing_distribution
time_unit: millisecond
telemetry_mirror: NETWORK_CACHE_V2_MISS_TIME_MS
description: >
Time spent to find out a cache entry file is missing.
(Migrated from the geckoview metric of the same name).
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1489524
- https://bugzilla.mozilla.org/show_bug.cgi?id=1580077
- https://bugzilla.mozilla.org/show_bug.cgi?id=1922661
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1580077#c10
notification_emails:
- necko@mozilla.com
expires: never
cache_hit_miss_stat_per_cache_size:
type: labeled_counter
description: >
Hit/Miss count split by cache size in file count Hit 0-5000, Miss 0-5000, Hit 5001-10000, ...
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1131600
- https://bugzilla.mozilla.org/show_bug.cgi?id=1922661
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1131600
notification_emails:
- necko@mozilla.com
expires: never
cache_hit_rate_per_cache_size:
type: labeled_custom_distribution
description: >
Hit rate for a specific cache size in file count. The hit rate is split into 20 buckets. The key is the cacheSize (20 buckets) and the value is between 0 and 100.
bucket_count: 20
range_min: 0
range_max: 100
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1131600
- https://bugzilla.mozilla.org/show_bug.cgi?id=1922661
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1131600
notification_emails:
- necko@mozilla.com
expires: never
font_download_end:
type: timing_distribution
time_unit: millisecond

View File

@ -10715,22 +10715,6 @@
"n_values": 7,
"description": "Final status of the CacheFileInputStream (0=ok, 1=other error, 2=out of memory, 3=disk full, 4=file corrupted, 5=file not found, 6=binding aborted)"
},
"NETWORK_CACHE_HIT_MISS_STAT_PER_CACHE_SIZE": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec"],
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 40,
"description": "Hit/Miss count split by cache size in file count (0=Hit 0-5000, 1=Miss 0-5000, 2=Hit 5001-10000, ...)"
},
"NETWORK_CACHE_HIT_RATE_PER_CACHE_SIZE": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec"],
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 400,
"description": "Hit rate for a specific cache size in file count. The hit rate is split into 20 buckets, the lower limit of the range in percents is 5*n/20. The cache size is divided into 20 ranges of length 5000, the lower limit of the range is 5000*(n%20)"
},
"NETWORK_CACHE_METADATA_FIRST_READ_TIME_MS": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec"],

View File

@ -87,8 +87,6 @@
"MIXED_CONTENT_PAGE_LOAD",
"MIXED_CONTENT_UNBLOCK_COUNTER",
"MOZ_SQLITE_COOKIES_OPEN_READAHEAD_MS",
"NETWORK_CACHE_HIT_MISS_STAT_PER_CACHE_SIZE",
"NETWORK_CACHE_HIT_RATE_PER_CACHE_SIZE",
"NETWORK_CACHE_METADATA_FIRST_READ_TIME_MS",
"NETWORK_CACHE_METADATA_SECOND_READ_TIME_MS",
"NETWORK_CACHE_V2_INPUT_STREAM_STATUS",
@ -330,8 +328,6 @@
"MIXED_CONTENT_PAGE_LOAD",
"MIXED_CONTENT_UNBLOCK_COUNTER",
"MOZ_SQLITE_COOKIES_OPEN_READAHEAD_MS",
"NETWORK_CACHE_HIT_MISS_STAT_PER_CACHE_SIZE",
"NETWORK_CACHE_HIT_RATE_PER_CACHE_SIZE",
"NETWORK_CACHE_METADATA_FIRST_READ_TIME_MS",
"NETWORK_CACHE_METADATA_SECOND_READ_TIME_MS",
"NETWORK_CACHE_V2_INPUT_STREAM_STATUS",
@ -574,7 +570,6 @@
"DEVTOOLS_READ_HEAP_SNAPSHOT_MS",
"DEVTOOLS_HEAP_SNAPSHOT_NODE_COUNT",
"DEVTOOLS_HEAP_SNAPSHOT_EDGE_COUNT",
"NETWORK_CACHE_HIT_RATE_PER_CACHE_SIZE",
"SSL_HANDSHAKE_RESULT",
"SSL_HANDSHAKE_RESULT_FIRST_TRY",
"SSL_HANDSHAKE_RESULT_CONSERVATIVE",