diff --git a/toolkit/components/places/nsPlacesAutoComplete.js b/toolkit/components/places/nsPlacesAutoComplete.js index c817e046985..c6d709833b8 100644 --- a/toolkit/components/places/nsPlacesAutoComplete.js +++ b/toolkit/components/places/nsPlacesAutoComplete.js @@ -8,6 +8,8 @@ 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 @@ -77,6 +79,9 @@ 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 @@ -1391,7 +1396,11 @@ urlInlineComplete.prototype = { 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); @@ -1400,6 +1409,7 @@ urlInlineComplete.prototype = { } finally { query.reset(); } + TelemetryStopwatch.finish(DOMAIN_QUERY_TELEMETRY); if (hasDomainResult) { // We got a match for a domain, we can add it immediately. diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index dd2c779d12e..e815aefb3a8 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -1833,6 +1833,13 @@ "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,