Bug 808557 - Telemetry to measure the impact of UIC_startSearch synchronous query. r=mak
authorDavid Rajchenbach-Teller <dteller@mozilla.com>
Tue, 20 Nov 2012 20:28:34 -0500
changeset 113854 dfa9f6c4c60820b8f7e86b5a4a505119bef228fc
parent 113853 0f76932d28c58881dd87455b031b71e90770c7b1
child 113855 029200e24d663be2665a38d8f416818b993603c8
push id23891
push useremorley@mozilla.com
push dateWed, 21 Nov 2012 15:30:36 +0000
treeherdermozilla-central@905492e644e3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs808557
milestone20.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 808557 - Telemetry to measure the impact of UIC_startSearch synchronous query. r=mak
toolkit/components/places/nsPlacesAutoComplete.js
toolkit/components/telemetry/Histograms.json
--- a/toolkit/components/places/nsPlacesAutoComplete.js
+++ b/toolkit/components/places/nsPlacesAutoComplete.js
@@ -3,16 +3,18 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://gre/modules/Services.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
                                   "resource://gre/modules/PlacesUtils.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "TelemetryStopwatch",
+                                  "resource://gre/modules/TelemetryStopwatch.jsm");
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Constants
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 
@@ -72,16 +74,19 @@ const kTitleTagsSeparator = " \u2013 ";
 const kBrowserUrlbarBranch = "browser.urlbar.";
 // Toggle autocomplete.
 const kBrowserUrlbarAutocompleteEnabledPref = "autocomplete.enabled";
 // Toggle autoFill.
 const kBrowserUrlbarAutofillPref = "autoFill";
 // Whether to search only typed entries.
 const kBrowserUrlbarAutofillTypedPref = "autoFill.typed";
 
+// The Telemetry histogram for urlInlineComplete query on domain
+const DOMAIN_QUERY_TELEMETRY = "PLACES_AUTOCOMPLETE_URLINLINE_DOMAIN_QUERY_TIME_MS";
+
 ////////////////////////////////////////////////////////////////////////////////
 //// Globals
 
 XPCOMUtils.defineLazyServiceGetter(this, "gTextURIService",
                                    "@mozilla.org/intl/texttosuburi;1",
                                    "nsITextToSubURI");
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1386,25 +1391,30 @@ urlInlineComplete.prototype = {
     let query = this._syncQuery;
     query.params.search_string = this._currentSearchString.toLowerCase();
 
     // Domains have no "/" in them.
     let lastSlashIndex = this._currentSearchString.lastIndexOf("/");
     if (lastSlashIndex == -1) {
       var hasDomainResult = false;
       var domain, untrimmedDomain;
+      TelemetryStopwatch.start(DOMAIN_QUERY_TELEMETRY);
       try {
+        // Execute the query synchronously.
+        // This is by design, to avoid race conditions between the
+        // user typing and the connection searching for the result.
         hasDomainResult = query.executeStep();
         if (hasDomainResult) {
           domain = query.getString(0);
           untrimmedDomain = query.getString(1);
         }
       } finally {
         query.reset();
       }
+      TelemetryStopwatch.finish(DOMAIN_QUERY_TELEMETRY);
 
       if (hasDomainResult) {
         // We got a match for a domain, we can add it immediately.
         // If the untrimmed value doesn't preserve the user's input just
         // ignore it and complete to the found domain.
         if (untrimmedDomain &&
             !untrimmedDomain.toLowerCase().contains(this._originalSearchString.toLowerCase())) {
           untrimmedDomain = null;
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -1828,16 +1828,23 @@
   },
   "PLACES_AUTOCOMPLETE_1ST_RESULT_TIME_MS": {
     "kind": "exponential",
     "low": 50,
     "high": "500",
     "n_buckets": 10,
     "description": "PLACES: Time for first autocomplete result if > 50ms (ms)"
   },
+  "PLACES_AUTOCOMPLETE_URLINLINE_DOMAIN_QUERY_TIME_MS": {
+    "kind": "exponential",
+    "low": 50,
+    "high": 2000,
+    "n_buckets": 10,
+    "description": "PLACES: Duration of the domain query for the url inline autocompletion (ms)"
+  },
   "PLACES_IDLE_FRECENCY_DECAY_TIME_MS": {
     "kind": "exponential",
     "low": 50,
     "high": "10000",
     "n_buckets": 10,
     "description": "PLACES: Time to decay all frecencies values on idle (ms)"
   },
   "PLACES_IDLE_MAINTENANCE_TIME_MS": {