diff --git a/net/dns/host_cache.cc b/net/dns/host_cache.cc index bacb6f194ac630..6889c19712ce57 100644 --- a/net/dns/host_cache.cc +++ b/net/dns/host_cache.cc @@ -183,7 +183,6 @@ HostCache::HostCache(size_t max_entries) HostCache::~HostCache() { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); - RecordEraseAll(ERASE_DESTRUCT, tick_clock_->NowTicks()); } const HostCache::Entry* HostCache::Lookup(const Key& key, base::TimeTicks now) { @@ -192,17 +191,12 @@ const HostCache::Entry* HostCache::Lookup(const Key& key, base::TimeTicks now) { return nullptr; HostCache::Entry* entry = LookupInternal(key); - if (!entry) { - RecordLookup(LOOKUP_MISS_ABSENT, now, nullptr); + if (!entry) return nullptr; - } - if (entry->IsStale(now, network_changes_)) { - RecordLookup(LOOKUP_MISS_STALE, now, entry); + if (entry->IsStale(now, network_changes_)) return nullptr; - } entry->CountHit(/* hit_is_stale= */ false); - RecordLookup(LOOKUP_HIT_VALID, now, entry); return entry; } @@ -215,14 +209,11 @@ const HostCache::Entry* HostCache::LookupStale( return nullptr; HostCache::Entry* entry = LookupInternal(key); - if (!entry) { - RecordLookup(LOOKUP_MISS_ABSENT, now, nullptr); + if (!entry) return nullptr; - } bool is_stale = entry->IsStale(now, network_changes_); entry->CountHit(/* hit_is_stale= */ is_stale); - RecordLookup(is_stale ? LOOKUP_HIT_STALE : LOOKUP_HIT_VALID, now, entry); if (stale_out) entry->GetStaleness(now, network_changes_, stale_out); @@ -246,8 +237,6 @@ void HostCache::Set(const Key& key, bool result_changed = false; auto it = entries_.find(key); if (it != entries_.end()) { - bool is_stale = it->second.IsStale(now, network_changes_); - base::Optional addresses_delta; if (entry.addresses() || it->second.addresses()) { if (entry.addresses() && it->second.addresses()) { @@ -297,8 +286,6 @@ void HostCache::Set(const Key& key, std::max(addresses_delta.value(), nonaddress_delta.value()); } - LogRecordSet(is_stale ? SET_UPDATE_STALE : SET_UPDATE_VALID, now, - &it->second, entry, overall_delta); // TODO(juliatuttle): Remember some old metadata (hit count or frequency or // something like that) if it's useful for better eviction algorithms? result_changed = @@ -309,7 +296,6 @@ void HostCache::Set(const Key& key, result_changed = true; if (size() == max_entries_) EvictOneEntry(now); - LogRecordSet(SET_INSERT, now, nullptr, entry, DELTA_DISJOINT); } AddEntry(Key(key), Entry(entry, now, ttl, network_changes_)); @@ -338,7 +324,6 @@ void HostCache::set_persistence_delegate(PersistenceDelegate* delegate) { void HostCache::clear() { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); - RecordEraseAll(ERASE_CLEAR, tick_clock_->NowTicks()); // Don't bother scheduling a write if there's nothing to clear. if (size() == 0) @@ -359,12 +344,10 @@ void HostCache::ClearForHosts( } bool changed = false; - base::TimeTicks now = tick_clock_->NowTicks(); for (auto it = entries_.begin(); it != entries_.end();) { auto next_it = std::next(it); if (host_filter.Run(it->first.hostname)) { - RecordErase(ERASE_CLEAR, now, it->second); entries_.erase(it); changed = true; } @@ -607,110 +590,9 @@ void HostCache::EvictOneEntry(base::TimeTicks now) { } } - RecordErase(ERASE_EVICT, now, oldest_it->second); entries_.erase(oldest_it); } -void HostCache::LogRecordSet(SetOutcome outcome, - base::TimeTicks now, - const Entry* old_entry, - const Entry& new_entry, - AddressListDeltaType delta) { - CACHE_HISTOGRAM_ENUM("Set", outcome, MAX_SET_OUTCOME); - switch (outcome) { - case SET_INSERT: - case SET_UPDATE_VALID: - // Nothing to log here. - break; - case SET_UPDATE_STALE: { - EntryStaleness stale; - old_entry->GetStaleness(now, network_changes_, &stale); - CACHE_HISTOGRAM_TIME("UpdateStale.ExpiredBy", stale.expired_by); - CACHE_HISTOGRAM_COUNT("UpdateStale.NetworkChanges", - stale.network_changes); - CACHE_HISTOGRAM_COUNT("UpdateStale.StaleHits", stale.stale_hits); - if (old_entry->error() == OK && new_entry.error() == OK) { - LogRecordUpdateStale(delta, stale); - } - break; - } - case MAX_SET_OUTCOME: - NOTREACHED(); - break; - } -} - -void HostCache::LogRecordUpdateStale(AddressListDeltaType delta, - const EntryStaleness& stale) { - CACHE_HISTOGRAM_ENUM("UpdateStale.AddressListDelta", delta, MAX_DELTA_TYPE); - switch (delta) { - case DELTA_IDENTICAL: - CACHE_HISTOGRAM_TIME("UpdateStale.ExpiredBy_Identical", stale.expired_by); - CACHE_HISTOGRAM_COUNT("UpdateStale.NetworkChanges_Identical", - stale.network_changes); - break; - case DELTA_REORDERED: - CACHE_HISTOGRAM_TIME("UpdateStale.ExpiredBy_Reordered", stale.expired_by); - CACHE_HISTOGRAM_COUNT("UpdateStale.NetworkChanges_Reordered", - stale.network_changes); - break; - case DELTA_OVERLAP: - CACHE_HISTOGRAM_TIME("UpdateStale.ExpiredBy_Overlap", stale.expired_by); - CACHE_HISTOGRAM_COUNT("UpdateStale.NetworkChanges_Overlap", - stale.network_changes); - break; - case DELTA_DISJOINT: - CACHE_HISTOGRAM_TIME("UpdateStale.ExpiredBy_Disjoint", stale.expired_by); - CACHE_HISTOGRAM_COUNT("UpdateStale.NetworkChanges_Disjoint", - stale.network_changes); - break; - case MAX_DELTA_TYPE: - NOTREACHED(); - break; - } -} - -void HostCache::RecordLookup(LookupOutcome outcome, - base::TimeTicks now, - const Entry* entry) { - CACHE_HISTOGRAM_ENUM("Lookup", outcome, MAX_LOOKUP_OUTCOME); - switch (outcome) { - case LOOKUP_MISS_ABSENT: - case LOOKUP_MISS_STALE: - case LOOKUP_HIT_VALID: - // Nothing to log here. - break; - case LOOKUP_HIT_STALE: - CACHE_HISTOGRAM_TIME("LookupStale.ExpiredBy", now - entry->expires()); - CACHE_HISTOGRAM_COUNT("LookupStale.NetworkChanges", - network_changes_ - entry->network_changes()); - break; - case MAX_LOOKUP_OUTCOME: - NOTREACHED(); - break; - } -} - -void HostCache::RecordErase(EraseReason reason, - base::TimeTicks now, - const Entry& entry) { - HostCache::EntryStaleness stale; - entry.GetStaleness(now, network_changes_, &stale); - CACHE_HISTOGRAM_ENUM("Erase", reason, MAX_ERASE_REASON); - if (stale.is_stale()) { - CACHE_HISTOGRAM_TIME("EraseStale.ExpiredBy", stale.expired_by); - CACHE_HISTOGRAM_COUNT("EraseStale.NetworkChanges", stale.network_changes); - CACHE_HISTOGRAM_COUNT("EraseStale.StaleHits", entry.stale_hits()); - } else { - CACHE_HISTOGRAM_TIME("EraseValid.ValidFor", -stale.expired_by); - } -} - -void HostCache::RecordEraseAll(EraseReason reason, base::TimeTicks now) { - for (const auto& it : entries_) - RecordErase(reason, now, it.second); -} - bool HostCache::HasEntry(base::StringPiece hostname, HostCache::Entry::Source* source_out, HostCache::EntryStaleness* stale_out) { diff --git a/net/dns/host_cache.h b/net/dns/host_cache.h index 87c3dbfa6287b8..6dda3aa946ec64 100644 --- a/net/dns/host_cache.h +++ b/net/dns/host_cache.h @@ -276,19 +276,6 @@ class NET_EXPORT HostCache { Entry* LookupInternal(const Key& key); - void LogRecordSet(SetOutcome outcome, - base::TimeTicks now, - const Entry* old_entry, - const Entry& new_entry, - AddressListDeltaType delta); - void LogRecordUpdateStale(AddressListDeltaType delta, - const EntryStaleness& stale); - void RecordLookup(LookupOutcome outcome, - base::TimeTicks now, - const Entry* entry); - void RecordErase(EraseReason reason, base::TimeTicks now, const Entry& entry); - void RecordEraseAll(EraseReason reason, base::TimeTicks now); - // Returns true if this HostCache can contain no entries. bool caching_is_disabled() const { return max_entries_ == 0; } diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 4b2881b7a372d2..c69689bb2cfb30 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -21575,12 +21575,18 @@ uploading your change for review. + + Deprecated as of 11/2018. + pauljensen@chromium.org mef@chromium.org The reason for erasing a DNS entry from the host cache. + + Deprecated as of 11/2018. + pauljensen@chromium.org mef@chromium.org @@ -21590,6 +21596,9 @@ uploading your change for review. + + Deprecated as of 11/2018. + pauljensen@chromium.org mef@chromium.org @@ -21599,6 +21608,9 @@ uploading your change for review. + + Deprecated as of 11/2018. + pauljensen@chromium.org mef@chromium.org @@ -21608,6 +21620,9 @@ uploading your change for review. + + Deprecated as of 11/2018. + pauljensen@chromium.org mef@chromium.org @@ -21617,12 +21632,18 @@ uploading your change for review. + + Deprecated as of 11/2018. + pauljensen@chromium.org mef@chromium.org The outcome of looking up a DNS entry in the host cache. + + Deprecated as of 11/2018. + pauljensen@chromium.org mef@chromium.org @@ -21632,6 +21653,9 @@ uploading your change for review. + + Deprecated as of 11/2018. + pauljensen@chromium.org mef@chromium.org @@ -21657,6 +21681,9 @@ uploading your change for review. + + Deprecated as of 11/2018. + pauljensen@chromium.org mef@chromium.org The outcome of setting a DNS entry in the host cache. @@ -21664,6 +21691,9 @@ uploading your change for review. + + Deprecated as of 11/2018. + pauljensen@chromium.org mef@chromium.org @@ -21674,6 +21704,9 @@ uploading your change for review. + + Deprecated as of 11/2018. + pauljensen@chromium.org mef@chromium.org @@ -21683,6 +21716,9 @@ uploading your change for review. + + Deprecated as of 11/2018. + pauljensen@chromium.org mef@chromium.org @@ -21693,6 +21729,9 @@ uploading your change for review. + + Deprecated as of 11/2018. + pauljensen@chromium.org mef@chromium.org