Skip to content

Commit

Permalink
Remove unused DNS.HostCache histograms
Browse files Browse the repository at this point in the history
They're not used and this change can be easily reverted to add them back.

Bug: 908717
Bug: 906936
Change-Id: I81f866c7491a84c1c5b0c87c023d3e43cf9d3a8c
Reviewed-on: https://chromium-review.googlesource.com/c/1352330
Reviewed-by: Misha Efimov <[email protected]>
Reviewed-by: Jesse Doherty <[email protected]>
Commit-Queue: Paul Jensen <[email protected]>
Cr-Commit-Position: refs/heads/master@{#611333}
  • Loading branch information
JensenPaul authored and Commit Bot committed Nov 27, 2018
1 parent 4a4c0b7 commit f23e02e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 134 deletions.
124 changes: 3 additions & 121 deletions net/dns/host_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}

Expand All @@ -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);
Expand All @@ -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<AddressListDeltaType> addresses_delta;
if (entry.addresses() || it->second.addresses()) {
if (entry.addresses() && it->second.addresses()) {
Expand Down Expand Up @@ -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 =
Expand All @@ -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_));
Expand Down Expand Up @@ -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)
Expand All @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down
13 changes: 0 additions & 13 deletions net/dns/host_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
39 changes: 39 additions & 0 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21575,12 +21575,18 @@ uploading your change for review.
</histogram>

<histogram name="DNS.HostCache.Erase" enum="DNS.HostCache.EraseReason">
<obsolete>
Deprecated as of 11/2018.
</obsolete>
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>The reason for erasing a DNS entry from the host cache.</summary>
</histogram>

<histogram name="DNS.HostCache.EraseStale.ExpiredBy" units="ms">
<obsolete>
Deprecated as of 11/2018.
</obsolete>
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
Expand All @@ -21590,6 +21596,9 @@ uploading your change for review.
</histogram>

<histogram name="DNS.HostCache.EraseStale.NetworkChanges" units="changes">
<obsolete>
Deprecated as of 11/2018.
</obsolete>
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
Expand All @@ -21599,6 +21608,9 @@ uploading your change for review.
</histogram>

<histogram name="DNS.HostCache.EraseStale.StaleHits" units="hits">
<obsolete>
Deprecated as of 11/2018.
</obsolete>
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
Expand All @@ -21608,6 +21620,9 @@ uploading your change for review.
</histogram>

<histogram name="DNS.HostCache.EraseValid.ValidFor" units="ms">
<obsolete>
Deprecated as of 11/2018.
</obsolete>
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
Expand All @@ -21617,12 +21632,18 @@ uploading your change for review.
</histogram>

<histogram name="DNS.HostCache.Lookup" enum="DNS.HostCache.LookupOutcome">
<obsolete>
Deprecated as of 11/2018.
</obsolete>
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>The outcome of looking up a DNS entry in the host cache.</summary>
</histogram>

<histogram name="DNS.HostCache.LookupStale.ExpiredBy" units="ms">
<obsolete>
Deprecated as of 11/2018.
</obsolete>
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
Expand All @@ -21632,6 +21653,9 @@ uploading your change for review.
</histogram>

<histogram name="DNS.HostCache.LookupStale.NetworkChanges" units="changes">
<obsolete>
Deprecated as of 11/2018.
</obsolete>
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
Expand All @@ -21657,13 +21681,19 @@ uploading your change for review.
</histogram>

<histogram name="DNS.HostCache.Set" enum="DNS.HostCache.SetOutcome">
<obsolete>
Deprecated as of 11/2018.
</obsolete>
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>The outcome of setting a DNS entry in the host cache.</summary>
</histogram>

<histogram name="DNS.HostCache.UpdateStale.AddressListDelta"
enum="DNS.AddressListDeltaType">
<obsolete>
Deprecated as of 11/2018.
</obsolete>
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
Expand All @@ -21674,6 +21704,9 @@ uploading your change for review.
</histogram>

<histogram name="DNS.HostCache.UpdateStale.ExpiredBy" units="ms">
<obsolete>
Deprecated as of 11/2018.
</obsolete>
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
Expand All @@ -21683,6 +21716,9 @@ uploading your change for review.
</histogram>

<histogram name="DNS.HostCache.UpdateStale.NetworkChanges" units="changes">
<obsolete>
Deprecated as of 11/2018.
</obsolete>
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
Expand All @@ -21693,6 +21729,9 @@ uploading your change for review.
</histogram>

<histogram name="DNS.HostCache.UpdateStale.StaleHits" units="hits">
<obsolete>
Deprecated as of 11/2018.
</obsolete>
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
Expand Down

0 comments on commit f23e02e

Please sign in to comment.