Bug 1489745 - Convert the preference sample-frequency-khz to hz r=ochameau,mstange
authorJulien Wajsberg <felash@gmail.com>
Wed, 24 Oct 2018 12:09:37 +0000
changeset 491115 2485564ba1b4ccf49e14fcc783e2f22b950fb094
parent 491114 3312d8b04ebda7ed5b25b72fff6d68fe7a92381a
child 491116 33b1c05d92a70b51b12f08484637f9999f2c9976
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersochameau, mstange
bugs1489745
milestone65.0a1
Bug 1489745 - Convert the preference sample-frequency-khz to hz r=ochameau,mstange The int preference profiler.sample-frequency-khz didn't make it possible to reduce the overhead in tests, because we could have intervals bigger than 1ms. With this change we can now do it. Depends on D8547 Differential Revision: https://phabricator.services.mozilla.com/D8548
devtools/client/performance/modules/global.js
devtools/client/performance/test/browser_perf-options-propagate-profiler.js
devtools/client/performance/test/helpers/prefs.js
devtools/client/preferences/devtools-client.js
devtools/server/actors/performance-recording.js
devtools/server/performance/profiler.js
devtools/shared/performance/recording-utils.js
--- a/devtools/client/performance/modules/global.js
+++ b/devtools/client/performance/modules/global.js
@@ -25,12 +25,12 @@ exports.L10N = new MultiLocalizationHelp
  */
 exports.PREFS = new PrefsHelper("devtools.performance", {
   "show-triggers-for-gc-types": ["Char", "ui.show-triggers-for-gc-types"],
   "show-platform-data": ["Bool", "ui.show-platform-data"],
   "hidden-markers": ["Json", "timeline.hidden-markers"],
   "memory-sample-probability": ["Float", "memory.sample-probability"],
   "memory-max-log-length": ["Int", "memory.max-log-length"],
   "profiler-buffer-size": ["Int", "profiler.buffer-size"],
-  "profiler-sample-frequency": ["Int", "profiler.sample-frequency-khz"],
+  "profiler-sample-frequency": ["Int", "profiler.sample-frequency-hz"],
   // TODO: re-enable once we flame charts via bug 1148663.
   "enable-memory-flame": ["Bool", "ui.enable-memory-flame"],
 });
--- a/devtools/client/performance/test/browser_perf-options-propagate-profiler.js
+++ b/devtools/client/performance/test/browser_perf-options-propagate-profiler.js
@@ -14,17 +14,17 @@ const { startRecording, stopRecording } 
 
 add_task(async function() {
   const { panel, toolbox } = await initPerformanceInNewTab({
     url: SIMPLE_URL,
     win: window,
   });
 
   Services.prefs.setIntPref(PROFILER_BUFFER_SIZE_PREF, 1000);
-  Services.prefs.setIntPref(PROFILER_SAMPLE_RATE_PREF, 2);
+  Services.prefs.setIntPref(PROFILER_SAMPLE_RATE_PREF, 2000);
 
   await startRecording(panel);
   const { entries, interval } = await toolbox.performance.getConfiguration();
   await stopRecording(panel);
 
   is(entries, 1000, "profiler entries option is set on profiler");
   is(interval, 0.5, "profiler interval option is set on profiler");
 
--- a/devtools/client/performance/test/helpers/prefs.js
+++ b/devtools/client/performance/test/helpers/prefs.js
@@ -5,17 +5,17 @@
 const Services = require("Services");
 const { Preferences } = require("resource://gre/modules/Preferences.jsm");
 
 // Prefs to revert to default once tests finish. Keep these in sync with
 // all the preferences defined in devtools/client/preferences/devtools-client.js.
 exports.MEMORY_SAMPLE_PROB_PREF = "devtools.performance.memory.sample-probability";
 exports.MEMORY_MAX_LOG_LEN_PREF = "devtools.performance.memory.max-log-length";
 exports.PROFILER_BUFFER_SIZE_PREF = "devtools.performance.profiler.buffer-size";
-exports.PROFILER_SAMPLE_RATE_PREF = "devtools.performance.profiler.sample-frequency-khz";
+exports.PROFILER_SAMPLE_RATE_PREF = "devtools.performance.profiler.sample-frequency-hz";
 
 exports.UI_EXPERIMENTAL_PREF = "devtools.performance.ui.experimental";
 exports.UI_INVERT_CALL_TREE_PREF = "devtools.performance.ui.invert-call-tree";
 exports.UI_INVERT_FLAME_PREF = "devtools.performance.ui.invert-flame-graph";
 exports.UI_FLATTEN_RECURSION_PREF = "devtools.performance.ui.flatten-tree-recursion";
 exports.UI_SHOW_PLATFORM_DATA_PREF = "devtools.performance.ui.show-platform-data";
 exports.UI_SHOW_IDLE_BLOCKS_PREF = "devtools.performance.ui.show-idle-blocks";
 exports.UI_ENABLE_FRAMERATE_PREF = "devtools.performance.ui.enable-framerate";
--- a/devtools/client/preferences/devtools-client.js
+++ b/devtools/client/preferences/devtools-client.js
@@ -111,17 +111,17 @@ pref("devtools.performance.enabled", tru
 // The default Performance UI settings
 pref("devtools.performance.memory.sample-probability", "0.05");
 // Can't go higher than this without causing internal allocation overflows while
 // serializing the allocations data over the RDP.
 pref("devtools.performance.memory.max-log-length", 125000);
 pref("devtools.performance.timeline.hidden-markers",
   "[\"Composite\",\"CompositeForwardTransaction\"]");
 pref("devtools.performance.profiler.buffer-size", 10000000);
-pref("devtools.performance.profiler.sample-frequency-khz", 1);
+pref("devtools.performance.profiler.sample-frequency-hz", 1000);
 pref("devtools.performance.ui.invert-call-tree", true);
 pref("devtools.performance.ui.invert-flame-graph", false);
 pref("devtools.performance.ui.flatten-tree-recursion", true);
 pref("devtools.performance.ui.show-platform-data", false);
 pref("devtools.performance.ui.show-idle-blocks", true);
 pref("devtools.performance.ui.enable-memory", false);
 pref("devtools.performance.ui.enable-allocations", false);
 pref("devtools.performance.ui.enable-framerate", true);
--- a/devtools/server/actors/performance-recording.js
+++ b/devtools/server/actors/performance-recording.js
@@ -65,17 +65,17 @@ Object.assign({
     this._configuration = {
       withMarkers: options.withMarkers || false,
       withTicks: options.withTicks || false,
       withMemory: options.withMemory || false,
       withAllocations: options.withAllocations || false,
       allocationsSampleProbability: options.allocationsSampleProbability || 0,
       allocationsMaxLogLength: options.allocationsMaxLogLength || 0,
       bufferSize: options.bufferSize || 0,
-      sampleFrequency: options.sampleFrequency || 1,
+      sampleFrequency: options.sampleFrequency || 1000,
     };
 
     this._console = !!options.console;
     this._label = options.label || "";
 
     if (meta) {
       // Store the start time roughly with Date.now() so when we
       // are checking the duration during a recording, we can get close
--- a/devtools/server/performance/profiler.js
+++ b/devtools/server/performance/profiler.js
@@ -20,17 +20,17 @@ const PROFILER_SYSTEM_EVENTS = [
 // How often the "profiler-status" is emitted by default (in ms)
 const BUFFER_STATUS_INTERVAL_DEFAULT = 5000;
 
 var DEFAULT_PROFILER_OPTIONS = {
   // When using the DevTools Performance Tools, this will be overridden
   // by the pref `devtools.performance.profiler.buffer-size`.
   entries: Math.pow(10, 7),
   // When using the DevTools Performance Tools, this will be overridden
-  // by the pref `devtools.performance.profiler.sample-rate-khz`.
+  // by the pref `devtools.performance.profiler.sample-frequency-hz`.
   interval: 1,
   features: ["js"],
   threadFilters: ["GeckoMain"],
 };
 
 /**
  * Main interface for interacting with nsIProfiler
  */
--- a/devtools/shared/performance/recording-utils.js
+++ b/devtools/shared/performance/recording-utils.js
@@ -7,17 +7,17 @@
  * Utility functions for managing recording models and their internal data,
  * such as filtering profile samples or offsetting timestamps.
  */
 
 function mapRecordingOptions(type, options) {
   if (type === "profiler") {
     return {
       entries: options.bufferSize,
-      interval: options.sampleFrequency ? (1000 / (options.sampleFrequency * 1000))
+      interval: options.sampleFrequency ? (1000 / options.sampleFrequency)
                                         : void 0,
     };
   }
 
   if (type === "memory") {
     return {
       probability: options.allocationsSampleProbability,
       maxLogLength: options.allocationsMaxLogLength,