Commit efc92934 authored by Charles Harrison's avatar Charles Harrison Committed by Commit Bot

[safe-browsing] Log prefix check in microseconds

Most prefix checks take between 0 and 1 ms. This CL improves the
resolution by logging the check in micros.

The CL also removes the SB2.FilterCheck metric which is not really
needed anymore.

Bug: 787092
Change-Id: I18a81d6eb7891f5a4c8c6fd6e7e956dc653d5379
Reviewed-on: https://chromium-review.googlesource.com/960248
Commit-Queue: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Reviewed-by: default avatarVarun Khaneja <vakh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542976}
parent 21e1836c
......@@ -514,8 +514,6 @@ bool LocalSafeBrowsingDatabaseManager::CheckBrowseUrl(
prefix_hits.erase(std::unique(prefix_hits.begin(), prefix_hits.end()),
prefix_hits.end());
UMA_HISTOGRAM_TIMES("SB2.FilterCheck", base::TimeTicks::Now() - start);
if (prefix_hits.empty() && cache_hits.empty())
return true; // URL is okay.
......
......@@ -18,6 +18,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_util.h"
#include "base/task_scheduler/post_task.h"
#include "base/timer/elapsed_timer.h"
#include "components/safe_browsing/db/notification_types.h"
#include "components/safe_browsing/db/v4_feature_list.h"
#include "components/safe_browsing/db/v4_protocol_manager_util.h"
......@@ -26,7 +27,6 @@
#include "crypto/sha2.h"
using content::BrowserThread;
using base::TimeTicks;
namespace safe_browsing {
......@@ -634,8 +634,7 @@ bool V4LocalDatabaseManager::GetPrefixMatches(
DCHECK(enabled_);
DCHECK(v4_database_);
const base::TimeTicks before = TimeTicks::Now();
base::ElapsedTimer timer;
full_hash_to_store_and_hash_prefixes->clear();
for (const auto& full_hash : check->full_hashes) {
StoreAndHashPrefixes matched_store_and_hash_prefixes;
......@@ -647,16 +646,11 @@ bool V4LocalDatabaseManager::GetPrefixMatches(
}
}
// TODO(vakh): Only log SafeBrowsing.V4GetPrefixMatches.Time once PVer3 code
// is removed.
// NOTE(vakh): This doesn't distinguish which stores it's searching through.
// However, the vast majority of the entries in this histogram will be from
// searching the three CHECK_BROWSE_URL stores.
base::TimeDelta diff = TimeTicks::Now() - before;
UMA_HISTOGRAM_TIMES("SB2.FilterCheck", diff);
UMA_HISTOGRAM_CUSTOM_TIMES("SafeBrowsing.V4GetPrefixMatches.Time", diff,
base::TimeDelta::FromMicroseconds(20),
base::TimeDelta::FromSeconds(1), 50);
UMA_HISTOGRAM_COUNTS_10M("SafeBrowsing.V4GetPrefixMatches.TimeUs",
timer.Elapsed().InMicroseconds());
return !full_hash_to_store_and_hash_prefixes->empty();
}
......
......@@ -75383,6 +75383,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</histogram>
<histogram name="SafeBrowsing.V4GetPrefixMatches.Time" units="ms">
<obsolete>
Deprecated in favor of the TimeUs variant
</obsolete>
<owner>vakh@chromium.org</owner>
<summary>
The time that it took to check a URL against our in-memory database. It is
......@@ -75390,6 +75393,16 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>
<histogram name="SafeBrowsing.V4GetPrefixMatches.TimeUs" units="microseconds">
<owner>csharrison@chromium.org</owner>
<owner>vakh@chromium.org</owner>
<summary>
The time that it took to check a URL against our in-memory database. It is
dominated by the time to perform checks for CheckBrowseUrl. Note that this
metric is recorded even for users with low resolution clocks.
</summary>
</histogram>
<histogram name="SafeBrowsing.V4MergeUpdateTime" units="ms">
<obsolete>
Replaced by SafeBrowsing.V4*.MergeUpdate.Time.
......@@ -76208,6 +76221,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</histogram>
<histogram name="SB2.FilterCheck" units="ms">
<obsolete>
Deprecated in favor of SafeBrowsing.V4GetPrefixMatches.TimeUs
</obsolete>
<owner>vakh@chromium.org</owner>
<summary>
The time that it took to check a URL against our in-memory filter.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment