Skip to content

Commit

Permalink
[subresource_filter] Add traces/UMA around ruleset verification
Browse files Browse the repository at this point in the history
Not only will the UMA give us latency numbers, but it will ensure
that we aren't mapping in the ruleset when we shouldn't be.

Bug: 721512
Change-Id: I705bfccc69b7b7da582532338d625641b399f705
Reviewed-on: https://chromium-review.googlesource.com/546137
Commit-Queue: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: Steven Holte <holte@chromium.org>
Cr-Commit-Position: refs/heads/master@{#495796}
  • Loading branch information
csharrison authored and Commit Bot committed Aug 19, 2017
1 parent 1b0da99 commit e7912e8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "base/files/file.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/trace_event/trace_event.h"
#include "components/subresource_filter/core/common/indexed_ruleset.h"
#include "components/subresource_filter/core/common/memory_mapped_ruleset.h"

Expand All @@ -26,6 +27,8 @@ void VerifiedRulesetDealer::SetRulesetFile(base::File ruleset_file) {

scoped_refptr<const MemoryMappedRuleset> VerifiedRulesetDealer::GetRuleset() {
DCHECK(CalledOnValidSequence());
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("loading"),
"VerifiedRulesetDealer::GetRuleset");

// TODO(pkalinnikov): Record verification status to a histogram.
switch (status_) {
Expand Down
6 changes: 6 additions & 0 deletions components/subresource_filter/core/common/indexed_ruleset.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#include "components/subresource_filter/core/common/indexed_ruleset.h"

#include "base/logging.h"
#include "base/trace_event/trace_event.h"
#include "components/subresource_filter/core/common/first_party_origin.h"
#include "components/subresource_filter/core/common/time_measurements.h"
#include "url/gurl.h"
#include "url/origin.h"

Expand Down Expand Up @@ -58,6 +60,10 @@ void RulesetIndexer::Finish() {

// static
bool IndexedRulesetMatcher::Verify(const uint8_t* buffer, size_t size) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("loading"),
"IndexedRulesetMatcher::Verify");
SCOPED_UMA_HISTOGRAM_MICRO_TIMER(
"SubresourceFilter.IndexRuleset.Verify.WallDuration");
flatbuffers::Verifier verifier(buffer, size);
return flat::VerifyIndexedRulesetBuffer(verifier);
}
Expand Down
10 changes: 10 additions & 0 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78045,6 +78045,16 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>

<histogram name="SubresourceFilter.IndexRuleset.Verify.WallDuration"
units="microseconds">
<owner>csharrison@chromium.org</owner>
<summary>
The total time it took to verify the indexed ruleset in the browser process.
Logged every time verification occurs, which usually occurs when the first
page with activation is navigated to.
</summary>
</histogram>

<histogram name="SubresourceFilter.IndexRuleset.WallDuration" units="ms">
<owner>engedy@chromium.org</owner>
<summary>
Expand Down

0 comments on commit e7912e8

Please sign in to comment.