Bug 1305801 - Part 2: Add telemetry for variable-length prefix set. r=francois
authorDimi Lee <dlee@mozilla.com>
Tue, 27 Sep 2016 14:26:09 -0700
changeset 316422 4b01da3f451aaef178662a8b16103a148a8646f9
parent 316421 39a5fc72213d842e796d101b5674c04c2d4c2433
child 316423 94d8f8d4e3d57a2bb17db6aaa911ba855ac2f69d
push id30770
push userkwierso@gmail.com
push dateWed, 05 Oct 2016 00:00:48 +0000
treeherdermozilla-central@3470e326025c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrancois
bugs1305801
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1305801 - Part 2: Add telemetry for variable-length prefix set. r=francois MozReview-Commit-ID: 8SebDJ8ZeKn
toolkit/components/telemetry/Histograms.json
toolkit/components/url-classifier/VariableLengthPrefixSet.cpp
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -3759,16 +3759,34 @@
   "URLCLASSIFIER_PS_CONSTRUCT_TIME": {
     "alert_emails": ["safebrowsing-telemetry@mozilla.org"],
     "expires_in_version": "never",
     "kind": "exponential",
     "high": 5000,
     "n_buckets": 15,
     "description": "Time spent constructing PrefixSet from DB (ms)"
   },
+  "URLCLASSIFIER_VLPS_FILELOAD_TIME": {
+    "alert_emails": ["safebrowsing-telemetry@mozilla.org"],
+    "expires_in_version": "58",
+    "kind": "exponential",
+    "high": 1000,
+    "n_buckets": 10,
+    "bug_numbers": [1283007],
+    "description": "Time spent loading Variable-Length PrefixSet from file (ms)"
+  },
+  "URLCLASSIFIER_VLPS_FALLOCATE_TIME": {
+    "alert_emails": ["safebrowsing-telemetry@mozilla.org"],
+    "expires_in_version": "58",
+    "kind": "exponential",
+    "high": 1000,
+    "n_buckets": 10,
+    "bug_numbers": [1283007],
+    "description": "Time spent fallocating Variable-Length PrefixSet (ms)"
+  },
   "URLCLASSIFIER_LC_PREFIXES": {
     "alert_emails": ["safebrowsing-telemetry@mozilla.org"],
     "expires_in_version": "never",
     "kind": "linear",
     "high": 1500000,
     "n_buckets": 15,
     "description": "Size of the prefix cache in entries"
   },
--- a/toolkit/components/url-classifier/VariableLengthPrefixSet.cpp
+++ b/toolkit/components/url-classifier/VariableLengthPrefixSet.cpp
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "VariableLengthPrefixSet.h"
 #include "nsUrlClassifierPrefixSet.h"
 #include "nsPrintfCString.h"
 #include "nsThreadUtils.h"
 #include "mozilla/EndianUtils.h"
+#include "mozilla/Telemetry.h"
 #include "mozilla/Unused.h"
 #include <algorithm>
 
 // MOZ_LOG=UrlClassifierPrefixSet:5
 static mozilla::LazyLogModule gUrlClassifierPrefixSetLog("UrlClassifierPrefixSet");
 #define LOG(args) MOZ_LOG(gUrlClassifierPrefixSetLog, mozilla::LogLevel::Debug, args)
 #define LOG_ENABLED() MOZ_LOG_TEST(gUrlClassifierPrefixSetLog, mozilla::LogLevel::Debug)
 
@@ -203,16 +204,18 @@ VariableLengthPrefixSet::IsEmpty(bool* a
 
 NS_IMETHODIMP
 VariableLengthPrefixSet::LoadFromFile(nsIFile* aFile)
 {
   MutexAutoLock lock(mLock);
 
   NS_ENSURE_ARG_POINTER(aFile);
 
+  Telemetry::AutoTimer<Telemetry::URLCLASSIFIER_VLPS_FILELOAD_TIME> timer;
+
   nsCOMPtr<nsIInputStream> localInFile;
   nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(localInFile), aFile,
                                            PR_RDONLY | nsIFile::OS_READAHEAD);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Calculate how big the file is, make sure our read buffer isn't bigger
   // than the file itself which is just wasting memory.
   int64_t fileSize;
@@ -249,16 +252,17 @@ VariableLengthPrefixSet::StoreToFile(nsI
   nsresult rv = NS_NewLocalFileOutputStream(getter_AddRefs(localOutFile), aFile,
                                             PR_WRONLY | PR_TRUNCATE | PR_CREATE_FILE);
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t fileSize = 0;
   // Preallocate the file storage
   {
     nsCOMPtr<nsIFileOutputStream> fos(do_QueryInterface(localOutFile));
+    Telemetry::AutoTimer<Telemetry::URLCLASSIFIER_VLPS_FALLOCATE_TIME> timer;
 
     fileSize += mFixedPrefixSet->CalculatePreallocateSize();
     fileSize += CalculatePreallocateSize();
 
     Unused << fos->Preallocate(fileSize);
   }
 
   // Convert to buffered stream