Bug 1074789 - Adjust DNS renewal time telemetry to take TTL experiments into consideration r=mcmanus
--- a/netwerk/dns/nsHostResolver.cpp
+++ b/netwerk/dns/nsHostResolver.cpp
@@ -261,16 +261,57 @@ GetBlacklistCountHistogram(DnsExpiration
case DNS_EXP_VARIANT_UNSET:
; // Fall through
}
MOZ_ASSERT_UNREACHABLE("Invalid variant.");
return DNS_BLACKLIST_COUNT_VAR_CONTROL_LOW;
}
+static mozilla::Telemetry::ID
+GetRenewalTimeHistogram(DnsExpirationVariant aVariant)
+{
+ using namespace mozilla::Telemetry;
+
+#ifdef TTL_AVAILABLE
+ switch (sDnsVariant) {
+ case DNS_EXP_VARIANT_CONTROL:
+ return DNS_RENEWAL_TIME;
+ case DNS_EXP_VARIANT_TTL_ONLY:
+ return DNS_RENEWAL_TIME__TTL_ONLY_EXPT;
+ case DNS_EXP_VARIANT_TTL_PLUS_CONST_GRACE:
+ return DNS_RENEWAL_TIME__TTL_PLUS_CONST_GRACE_EXPT;
+ default:
+ MOZ_ASSERT_UNREACHABLE("Invalid variant.");
+ }
+#endif
+ return DNS_RENEWAL_TIME;
+}
+
+static mozilla::Telemetry::ID
+GetRenewalTimeForTTLHistogram(DnsExpirationVariant aVariant)
+{
+ using namespace mozilla::Telemetry;
+
+#ifdef TTL_AVAILABLE
+ switch (sDnsVariant) {
+ case DNS_EXP_VARIANT_CONTROL:
+ MOZ_ASSERT_UNREACHABLE("No TTL for Control Expt.");
+ return DNS_RENEWAL_TIME;
+ case DNS_EXP_VARIANT_TTL_ONLY:
+ return DNS_RENEWAL_TIME_FOR_TTL__TTL_ONLY_EXPT;
+ case DNS_EXP_VARIANT_TTL_PLUS_CONST_GRACE:
+ return DNS_RENEWAL_TIME_FOR_TTL__TTL_PLUS_CONST_GRACE_EXPT;
+ default:
+ MOZ_ASSERT_UNREACHABLE("Invalid variant.");
+ }
+#endif
+ return DNS_RENEWAL_TIME;
+}
+
// this macro filters out any flags that are not used when constructing the
// host key. the significant flags are those that would affect the resulting
// host record (i.e., the flags that are passed down to PR_GetAddrInfoByName).
#define RES_KEY_FLAGS(_f) ((_f) & nsHostResolver::RES_CANON_NAME)
nsHostRecord::nsHostRecord(const nsHostKey *key)
: addr_info_lock("nsHostRecord.addr_info_lock")
, addr_info_gencnt(0)
@@ -1605,22 +1646,29 @@ nsHostResolver::ThreadFunc(void *arg)
status = GetAddrInfo(rec->host, af, flags, &ai, getTtl);
}
#endif
TimeDuration elapsed = TimeStamp::Now() - startTime;
uint32_t millis = static_cast<uint32_t>(elapsed.ToMilliseconds());
if (NS_SUCCEEDED(status)) {
- Telemetry::Accumulate(!rec->addr_info_gencnt ?
- Telemetry::DNS_LOOKUP_TIME :
- Telemetry::DNS_RENEWAL_TIME,
- millis);
- }
- else {
+ Telemetry::ID histogramID;
+ if (!rec->addr_info_gencnt) {
+ // Time for initial lookup.
+ histogramID = Telemetry::DNS_LOOKUP_TIME;
+ } else if (!getTtl) {
+ // Time for renewal; categorized by expiration strategy.
+ histogramID = GetRenewalTimeHistogram(sDnsVariant);
+ } else {
+ // Time to get TTL; categorized by expiration strategy.
+ histogramID = GetRenewalTimeForTTLHistogram(sDnsVariant);
+ }
+ Telemetry::Accumulate(histogramID, millis);
+ } else {
Telemetry::Accumulate(Telemetry::DNS_FAILED_LOOKUP_TIME, millis);
}
// OnLookupComplete may release "rec", long before we lose it.
LOG(("DNS lookup thread - lookup completed for host [%s]: %s.\n",
rec->host, ai ? "success" : "failure: unknown host"));
if (LOOKUP_RESOLVEAGAIN == resolver->OnLookupComplete(rec, status, ai)) {
// leave 'rec' assigned and loop to make a renewed host resolve
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -2140,16 +2140,56 @@
"DNS_RENEWAL_TIME": {
"expires_in_version": "never",
"kind": "exponential",
"high": "60000",
"n_buckets": 50,
"extended_statistics_ok": true,
"description": "Time for a renewed DNS OS resolution (msec)"
},
+ "DNS_RENEWAL_TIME_FOR_TTL": {
+ "expires_in_version": "never",
+ "kind": "exponential",
+ "high": "60000",
+ "n_buckets": 50,
+ "extended_statistics_ok": true,
+ "description": "Time for a DNS OS resolution (msec) used to get TTL"
+ },
+ "DNS_RENEWAL_TIME_FOR_TTL__TTL_ONLY_EXPT": {
+ "expires_in_version": "never",
+ "kind": "exponential",
+ "high": "60000",
+ "n_buckets": 50,
+ "extended_statistics_ok": true,
+ "description": "Time for a DNS OS resolution (msec) used to get TTL - TTL Only Experiment"
+ },
+ "DNS_RENEWAL_TIME_FOR_TTL__TTL_PLUS_CONST_GRACE_EXPT": {
+ "expires_in_version": "never",
+ "kind": "exponential",
+ "high": "60000",
+ "n_buckets": 50,
+ "extended_statistics_ok": true,
+ "description": "Time for a DNS OS resolution (msec) used to get TTL - TTL + Const Grace Period Experiment"
+ },
+ "DNS_RENEWAL_TIME__TTL_ONLY_EXPT": {
+ "expires_in_version": "never",
+ "kind": "exponential",
+ "high": "60000",
+ "n_buckets": 50,
+ "extended_statistics_ok": true,
+ "description": "Time for a renewed DNS OS resolution (msec) - TTL Only Experiment"
+ },
+ "DNS_RENEWAL_TIME__TTL_PLUS_CONST_GRACE_EXPT": {
+ "expires_in_version": "never",
+ "kind": "exponential",
+ "high": "60000",
+ "n_buckets": 50,
+ "extended_statistics_ok": true,
+ "description": "Time for a renewed DNS OS resolution (msec) - TTL + Const Grace Period Experiment"
+ },
"DNS_FAILED_LOOKUP_TIME": {
"expires_in_version": "never",
"kind": "exponential",
"high": "60000",
"n_buckets": 50,
"extended_statistics_ok": true,
"description": "Time for an unsuccessful DNS OS resolution (msec)"
},