Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2616)

Unified Diff: chrome/browser/safe_browsing/safe_browsing_database.cc

Issue 6765035: More PrefixSet diagnostics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/safe_browsing/prefix_set_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/safe_browsing_database.cc
diff --git a/chrome/browser/safe_browsing/safe_browsing_database.cc b/chrome/browser/safe_browsing/safe_browsing_database.cc
index 09854da6868bdf6ddde703e314bee29b609e4451..7c97b15ea67b65ce192d80487f599c49ea1e9b86 100644
--- a/chrome/browser/safe_browsing/safe_browsing_database.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_database.cc
@@ -221,6 +221,8 @@ enum PrefixSetEvent {
PREFIX_SET_SBPREFIX_WAS_BROKEN,
PREFIX_SET_GETPREFIXES_BROKEN_SORTING,
PREFIX_SET_GETPREFIXES_BROKEN_DUPLICATION,
+ PREFIX_SET_GETPREFIX_UNSORTED_IS_DELTA,
+ PREFIX_SET_GETPREFIX_UNSORTED_IS_INDEX,
// Memory space for histograms is determined by the max. ALWAYS ADD
// NEW VALUES BEFORE THIS ONE.
@@ -285,28 +287,53 @@ safe_browsing::PrefixSet* PrefixSetFromAddPrefixes(
// Check whether |restored| is unsorted, or has duplication.
if (restored.size()) {
- bool unsorted = false;
+ size_t unsorted_count = 0;
bool duplicates = false;
- std::vector<SBPrefix>::const_iterator prev = restored.begin();
- for (std::vector<SBPrefix>::const_iterator iter = prev + 1;
- iter != restored.end(); prev = iter, ++iter) {
- if (*prev > *iter)
- unsorted = true;
- if (*prev == *iter)
+ SBPrefix prev = restored[0];
+ for (size_t i = 0; i < restored.size(); prev = restored[i], ++i) {
+ if (prev > restored[i]) {
+ unsorted_count++;
+ UMA_HISTOGRAM_COUNTS("SB2.PrefixSetUnsortedDifference",
+ prev - restored[i]);
+
+ // When unsorted, how big is the set, and how far are we into
+ // it. If the set is very small or large, that might inform
+ // pursuit of a degenerate case. If the percentage is close
+ // to 0%, 100%, or 50%, then there might be an interesting
+ // degenerate case to explore.
+ UMA_HISTOGRAM_COUNTS("SB2.PrefixSetUnsortedSize", restored.size());
+ UMA_HISTOGRAM_PERCENTAGE("SB2.PrefixSetUnsortedPercent",
+ i * 100 / restored.size());
+
+ if (prefix_set->IsDeltaAt(i)) {
+ RecordPrefixSetInfo(PREFIX_SET_GETPREFIX_UNSORTED_IS_DELTA);
+
+ // Histograms require memory on the order of the number of
+ // buckets, making high-precision logging expensive. For
+ // now aim for a sense of the range of the problem.
+ UMA_HISTOGRAM_CUSTOM_COUNTS("SB2.PrefixSetUnsortedDelta",
+ prefix_set->DeltaAt(i), 1, 0xFFFF, 50);
+ } else {
+ RecordPrefixSetInfo(PREFIX_SET_GETPREFIX_UNSORTED_IS_INDEX);
+ }
+ }
+ if (prev == restored[i])
duplicates = true;
}
// Record findings.
- if (unsorted)
+ if (unsorted_count) {
RecordPrefixSetInfo(PREFIX_SET_GETPREFIXES_BROKEN_SORTING);
+ UMA_HISTOGRAM_COUNTS_100("SB2.PrefixSetUnsorted", unsorted_count);
+ }
if (duplicates)
RecordPrefixSetInfo(PREFIX_SET_GETPREFIXES_BROKEN_DUPLICATION);
// Fix the problems noted. If |restored| was unsorted, then
// |duplicates| may give a false negative.
- if (unsorted)
+ if (unsorted_count)
std::sort(restored.begin(), restored.end());
- if (unsorted || duplicates)
+ if (unsorted_count || duplicates)
restored.erase(std::unique(restored.begin(), restored.end()),
restored.end());
}
« no previous file with comments | « chrome/browser/safe_browsing/prefix_set_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698