Bug 1570212 - Convert toolkit.telemetry.ipcBatchTimeout to a static pref. r=chutten

Differential Revision: https://phabricator.services.mozilla.com/D40006

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nicholas Nethercote 2019-08-01 06:01:44 +00:00
parent 1e23726d7b
commit dd8024d316
2 changed files with 16 additions and 19 deletions

View File

@ -5829,6 +5829,15 @@
value: 3
mirror: always
# Sending each remote accumulation immediately places undue strain on the IPC
# subsystem. Batch the remote accumulations for a period of time before sending
# them all at once. This value was chosen as a balance between data timeliness
# and performance (see bug 1218576).
- name: toolkit.telemetry.ipcBatchTimeout
type: uint32_t
value: 2000
mirror: always
#---------------------------------------------------------------------------
# Prefs starting with "ui."
#---------------------------------------------------------------------------

View File

@ -13,6 +13,7 @@
#include "mozilla/gfx/GPUProcessManager.h"
#include "mozilla/net/SocketProcessChild.h"
#include "mozilla/StaticMutex.h"
#include "mozilla/StaticPrefs_toolkit.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/SystemGroup.h"
#include "mozilla/Unused.h"
@ -37,16 +38,10 @@ using mozilla::Telemetry::ScalarVariant;
namespace TelemetryIPCAccumulator = mozilla::TelemetryIPCAccumulator;
// Sending each remote accumulation immediately places undue strain on the
// IPC subsystem. Batch the remote accumulations for a period of time before
// sending them all at once. This value was chosen as a balance between data
// timeliness and performance (see bug 1218576)
const uint32_t kDefaultBatchTimeoutMs = 2000;
static uint32_t sBatchTimeoutMs = kDefaultBatchTimeoutMs;
// To stop growing unbounded in memory while waiting for sBatchTimeoutMs to
// drain the probe accumulation arrays, we request an immediate flush if the
// arrays manage to reach certain high water mark of elements.
// To stop growing unbounded in memory while waiting for
// StaticPrefs::toolkit_telemetry_ipcBatchTimeout() milliseconds to drain the
// probe accumulation arrays, we request an immediate flush if the arrays
// manage to reach certain high water mark of elements.
const size_t kHistogramAccumulationsArrayHighWaterMark = 5 * 1024;
const size_t kScalarActionsArrayHighWaterMark = 10000;
// With the current limits, events cost us about 1100 bytes each.
@ -94,16 +89,9 @@ void DoArmIPCTimerMainThread(const StaticMutexAutoLock& lock) {
NS_NewTimer(SystemGroup::EventTargetFor(TaskCategory::Other)).take();
}
if (gIPCTimer) {
static bool sTimeoutInitialized = false;
if (!sTimeoutInitialized && Preferences::IsServiceAvailable()) {
Preferences::AddUintVarCache(&sBatchTimeoutMs,
"toolkit.telemetry.ipcBatchTimeout",
kDefaultBatchTimeoutMs);
sTimeoutInitialized = true;
}
gIPCTimer->InitWithNamedFuncCallback(
TelemetryIPCAccumulator::IPCTimerFired, nullptr, sBatchTimeoutMs,
TelemetryIPCAccumulator::IPCTimerFired, nullptr,
mozilla::StaticPrefs::toolkit_telemetry_ipcBatchTimeout(),
nsITimer::TYPE_ONE_SHOT_LOW_PRIORITY,
"TelemetryIPCAccumulator::IPCTimerFired");
gIPCTimerArmed = true;