зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1207416: Add Telemetry for time spent in different Load states in WebRTC r=gcp
This commit is contained in:
Родитель
34664b8354
Коммит
6027a43516
|
@ -15,6 +15,8 @@
|
|||
#include "nsThreadUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
|
||||
// NSPR_LOG_MODULES=LoadManager:5
|
||||
PRLogModuleInfo *gLoadManagerLog = nullptr;
|
||||
|
@ -53,6 +55,11 @@ LoadManagerSingleton::LoadManagerSingleton(int aLoadMeasurementInterval,
|
|||
mLoadMonitor = new LoadMonitor(mLoadMeasurementInterval);
|
||||
mLoadMonitor->Init(mLoadMonitor);
|
||||
mLoadMonitor->SetLoadChangeCallback(this);
|
||||
|
||||
mLastStateChange = TimeStamp::Now();
|
||||
for (auto &in_state : mTimeInState) {
|
||||
in_state = 0;
|
||||
}
|
||||
}
|
||||
|
||||
LoadManagerSingleton::~LoadManagerSingleton()
|
||||
|
@ -100,21 +107,22 @@ LoadManagerSingleton::LoadChanged(float aSystemLoad, float aProcesLoad)
|
|||
if (mLoadSumMeasurements >= mAveragingMeasurements) {
|
||||
double averagedLoad = mLoadSum / (float)mLoadSumMeasurements;
|
||||
|
||||
webrtc::CPULoadState oldState = mCurrentState;
|
||||
webrtc::CPULoadState newState = mCurrentState;
|
||||
|
||||
if (mOveruseActive || averagedLoad > mHighLoadThreshold) {
|
||||
LOG(("LoadManager - LoadStressed"));
|
||||
mCurrentState = webrtc::kLoadStressed;
|
||||
newState = webrtc::kLoadStressed;
|
||||
} else if (averagedLoad < mLowLoadThreshold) {
|
||||
LOG(("LoadManager - LoadRelaxed"));
|
||||
mCurrentState = webrtc::kLoadRelaxed;
|
||||
newState = webrtc::kLoadRelaxed;
|
||||
} else {
|
||||
LOG(("LoadManager - LoadNormal"));
|
||||
mCurrentState = webrtc::kLoadNormal;
|
||||
newState = webrtc::kLoadNormal;
|
||||
}
|
||||
|
||||
if (oldState != mCurrentState)
|
||||
LoadHasChanged();
|
||||
if (newState != mCurrentState) {
|
||||
LoadHasChanged(newState);
|
||||
}
|
||||
|
||||
mLoadSum = 0;
|
||||
mLoadSumMeasurements = 0;
|
||||
|
@ -128,8 +136,7 @@ LoadManagerSingleton::OveruseDetected()
|
|||
MutexAutoLock lock(mLock);
|
||||
mOveruseActive = true;
|
||||
if (mCurrentState != webrtc::kLoadStressed) {
|
||||
mCurrentState = webrtc::kLoadStressed;
|
||||
LoadHasChanged();
|
||||
LoadHasChanged(webrtc::kLoadStressed);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,10 +149,18 @@ LoadManagerSingleton::NormalUsage()
|
|||
}
|
||||
|
||||
void
|
||||
LoadManagerSingleton::LoadHasChanged()
|
||||
LoadManagerSingleton::LoadHasChanged(webrtc::CPULoadState aNewState)
|
||||
{
|
||||
mLock.AssertCurrentThreadOwns();
|
||||
LOG(("LoadManager - Signaling LoadHasChanged to %d listeners", mObservers.Length()));
|
||||
LOG(("LoadManager - Signaling LoadHasChanged from %d to %d to %d listeners",
|
||||
mCurrentState, aNewState, mObservers.Length()));
|
||||
|
||||
// Record how long we spent in this state for later Telemetry or display
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
mTimeInState[mCurrentState] += (now - mLastStateChange).ToMilliseconds();
|
||||
mLastStateChange = now;
|
||||
|
||||
mCurrentState = aNewState;
|
||||
for (size_t i = 0; i < mObservers.Length(); i++) {
|
||||
mObservers.ElementAt(i)->onLoadStateChanged(mCurrentState);
|
||||
}
|
||||
|
@ -162,6 +177,7 @@ LoadManagerSingleton::AddObserver(webrtc::CPULoadStateObserver * aObserver)
|
|||
mLoadMonitor = new LoadMonitor(mLoadMeasurementInterval);
|
||||
mLoadMonitor->Init(mLoadMonitor);
|
||||
mLoadMonitor->SetLoadChangeCallback(this);
|
||||
mLastStateChange = TimeStamp::Now();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -176,6 +192,35 @@ LoadManagerSingleton::RemoveObserver(webrtc::CPULoadStateObserver * aObserver)
|
|||
}
|
||||
if (mObservers.Length() == 0) {
|
||||
if (mLoadMonitor) {
|
||||
// Record how long we spent in the final state for later Telemetry or display
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
mTimeInState[mCurrentState] += (now - mLastStateChange).ToMilliseconds();
|
||||
|
||||
float total = 0;
|
||||
for (size_t i = 0; i < MOZ_ARRAY_LENGTH(mTimeInState); i++) {
|
||||
total += mTimeInState[i];
|
||||
}
|
||||
// Don't include short calls; we don't have reasonable load data, and
|
||||
// such short calls rarely reach a stable state. Keep relatively
|
||||
// short calls separate from longer ones
|
||||
bool log = total > 5*PR_MSEC_PER_SEC;
|
||||
bool small = log && total < 30*PR_MSEC_PER_SEC;
|
||||
if (log) {
|
||||
// Note: We don't care about rounding here; thus total may be < 100
|
||||
Telemetry::Accumulate(small ? Telemetry::WEBRTC_LOAD_STATE_RELAXED_SHORT :
|
||||
Telemetry::WEBRTC_LOAD_STATE_RELAXED,
|
||||
(uint32_t) (mTimeInState[webrtc::CPULoadState::kLoadRelaxed]/total * 100));
|
||||
Telemetry::Accumulate(small ? Telemetry::WEBRTC_LOAD_STATE_NORMAL_SHORT :
|
||||
Telemetry::WEBRTC_LOAD_STATE_NORMAL,
|
||||
(uint32_t) (mTimeInState[webrtc::CPULoadState::kLoadNormal]/total * 100));
|
||||
Telemetry::Accumulate(small ? Telemetry::WEBRTC_LOAD_STATE_STRESSED_SHORT :
|
||||
Telemetry::WEBRTC_LOAD_STATE_STRESSED,
|
||||
(uint32_t) (mTimeInState[webrtc::CPULoadState::kLoadStressed]/total * 100));
|
||||
}
|
||||
for (auto &in_state : mTimeInState) {
|
||||
in_state = 0;
|
||||
}
|
||||
|
||||
// Dance to avoid deadlock on mLock!
|
||||
nsRefPtr<LoadMonitor> loadMonitor = mLoadMonitor.forget();
|
||||
MutexAutoUnlock unlock(mLock);
|
||||
|
|
|
@ -50,7 +50,7 @@ private:
|
|||
float aLowLoadThreshold);
|
||||
~LoadManagerSingleton();
|
||||
|
||||
void LoadHasChanged();
|
||||
void LoadHasChanged(webrtc::CPULoadState aNewState);
|
||||
|
||||
nsRefPtr<LoadMonitor> mLoadMonitor;
|
||||
|
||||
|
@ -59,6 +59,9 @@ private:
|
|||
Mutex mLock;
|
||||
nsTArray<webrtc::CPULoadStateObserver*> mObservers;
|
||||
webrtc::CPULoadState mCurrentState;
|
||||
TimeStamp mLastStateChange;
|
||||
float mTimeInState[static_cast<int>(webrtc::kLoadLast)];
|
||||
|
||||
// Set when overuse was signaled to us, and hasn't been un-signaled yet.
|
||||
bool mOveruseActive;
|
||||
float mLoadSum;
|
||||
|
|
|
@ -787,9 +787,10 @@ struct OverUseDetectorOptions {
|
|||
};
|
||||
|
||||
enum CPULoadState {
|
||||
kLoadRelaxed,
|
||||
kLoadRelaxed = 0,
|
||||
kLoadNormal,
|
||||
kLoadStressed
|
||||
kLoadStressed,
|
||||
kLoadLast,
|
||||
};
|
||||
|
||||
class CPULoadStateObserver {
|
||||
|
|
|
@ -6505,6 +6505,48 @@
|
|||
"n_values": 8,
|
||||
"description": "Type for media in getUserMedia calls (0=Camera, 1=Screen, 2=Application, 3=Window, 4=Browser, 5=Microphone, 6=AudioCapture, 7=Other)"
|
||||
},
|
||||
"WEBRTC_LOAD_STATE_RELAXED": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "linear",
|
||||
"high": "100",
|
||||
"n_buckets": "25",
|
||||
"description": "Percentage of time spent in the Relaxed load state in calls over 30 seconds."
|
||||
},
|
||||
"WEBRTC_LOAD_STATE_RELAXED_SHORT": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "linear",
|
||||
"high": "100",
|
||||
"n_buckets": "25",
|
||||
"description": "Percentage of time spent in the Relaxed load state in calls 5-30 seconds."
|
||||
},
|
||||
"WEBRTC_LOAD_STATE_NORMAL": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "linear",
|
||||
"high": "100",
|
||||
"n_buckets": "25",
|
||||
"description": "Percentage of time spent in the Normal load state in calls over 30 seconds."
|
||||
},
|
||||
"WEBRTC_LOAD_STATE_NORMAL_SHORT": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "linear",
|
||||
"high": "100",
|
||||
"n_buckets": "25",
|
||||
"description": "Percentage of time spent in the Normal load state in calls over 5-30 seconds."
|
||||
},
|
||||
"WEBRTC_LOAD_STATE_STRESSED": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "linear",
|
||||
"high": "100",
|
||||
"n_buckets": "25",
|
||||
"description": "Percentage of time spent in the Stressed load state in calls over 30 seconds."
|
||||
},
|
||||
"WEBRTC_LOAD_STATE_STRESSED_SHORT": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "linear",
|
||||
"high": "100",
|
||||
"n_buckets": "25",
|
||||
"description": "Percentage of time spent in the Stressed load state in calls 5-30 seconds."
|
||||
},
|
||||
"DEVTOOLS_DEBUGGER_RDP_LOCAL_TRACERDETACH_MS": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
|
|
Загрузка…
Ссылка в новой задаче