Bug 1331571 - Remove Intel Power Gadget integration from the compiler. r=mstange.

Nobody has ever used this, and measuring power consumption while running a
sampling profiler at 1000 Hz isn't a good idea.

--HG--
extra : rebase_source : b84255a08bfea07b90bedc1f24086695143d5c8e
This commit is contained in:
Nicholas Nethercote 2017-01-19 08:05:47 +11:00
Родитель 81cba3873b
Коммит d7d1bbbb95
9 изменённых файлов: 2 добавлений и 509 удалений

Просмотреть файл

@ -180,15 +180,11 @@ GeckoSampler::GeckoSampler(double aInterval, int aEntrySize,
: Sampler(aInterval, true, aEntrySize)
, mBuffer(new ProfileBuffer(aEntrySize))
, mSaveRequested(false)
#if defined(XP_WIN)
, mIntelPowerGadget(nullptr)
#endif
{
mUseStackWalk = hasFeature(aFeatures, aFeatureCount, "stackwalk");
mProfileJS = hasFeature(aFeatures, aFeatureCount, "js");
mProfileGPU = hasFeature(aFeatures, aFeatureCount, "gpu");
mProfilePower = hasFeature(aFeatures, aFeatureCount, "power");
// Users sometimes ask to filter by a list of threads but forget to request
// profiling non main threads. Let's make it implificit if we have a filter
mProfileThreads = hasFeature(aFeatures, aFeatureCount, "threads") || aFilterCount > 0;
@ -201,13 +197,6 @@ GeckoSampler::GeckoSampler(double aInterval, int aEntrySize,
mDisplayListDump = hasFeature(aFeatures, aFeatureCount, "displaylistdump");
mProfileRestyle = hasFeature(aFeatures, aFeatureCount, "restyle");
#if defined(XP_WIN)
if (mProfilePower) {
mIntelPowerGadget = new IntelPowerGadget();
mProfilePower = mIntelPowerGadget->Init();
}
#endif
#if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
mProfileJava = mozilla::jni::IsFennec() &&
hasFeature(aFeatures, aFeatureCount, "java");
@ -274,9 +263,6 @@ GeckoSampler::~GeckoSampler()
}
}
}
#if defined(XP_WIN)
delete mIntelPowerGadget;
#endif
// Cancel any in-flight async profile gatherering
// requests
@ -1256,13 +1242,6 @@ void GeckoSampler::InplaceTick(TickSample* sample)
currThreadProfile.addTag(ProfileEntry('U', static_cast<double>(sample->ussMemory)));
}
#if defined(XP_WIN)
if (mProfilePower) {
mIntelPowerGadget->TakeSample();
currThreadProfile.addTag(ProfileEntry('p', static_cast<double>(mIntelPowerGadget->GetTotalPackagePowerInWatts())));
}
#endif
if (sLastFrameNumber != sFrameNumber) {
currThreadProfile.addTag(ProfileEntry('f', sFrameNumber));
sLastFrameNumber = sFrameNumber;

Просмотреть файл

@ -12,9 +12,6 @@
#include "mozilla/Vector.h"
#include "ThreadProfile.h"
#include "ThreadInfo.h"
#ifndef SPS_STANDALONE
#include "IntelPowerGadget.h"
#endif
#ifdef MOZ_TASK_TRACER
#include "GeckoTaskTracer.h"
#endif
@ -102,7 +99,6 @@ class GeckoSampler: public Sampler {
bool ProfileJS() const { return mProfileJS; }
bool ProfileJava() const { return mProfileJava; }
bool ProfileGPU() const { return mProfileGPU; }
bool ProfilePower() const { return mProfilePower; }
bool ProfileThreads() const override { return mProfileThreads; }
bool InPrivacyMode() const { return mPrivacyMode; }
bool AddMainThreadIO() const { return mAddMainThreadIO; }
@ -133,7 +129,6 @@ protected:
bool mProfileGPU;
bool mProfileThreads;
bool mProfileJava;
bool mProfilePower;
bool mLayersDump;
bool mDisplayListDump;
bool mProfileRestyle;
@ -146,9 +141,6 @@ protected:
bool mAddMainThreadIO;
bool mProfileMemory;
bool mTaskTracer;
#if defined(XP_WIN)
IntelPowerGadget* mIntelPowerGadget;
#endif
private:
RefPtr<mozilla::ProfileGatherer> mGatherer;

Просмотреть файл

@ -1,310 +0,0 @@
/*
* Copyright 2013, Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author: Joe Olivas <joseph.k.olivas@intel.com>
*/
#include "nsDebug.h"
#include "nsString.h"
#include "IntelPowerGadget.h"
#include "prenv.h"
IntelPowerGadget::IntelPowerGadget() :
libpowergadget(nullptr),
Initialize(nullptr),
GetNumNodes(nullptr),
GetMsrName(nullptr),
GetMsrFunc(nullptr),
ReadMSR(nullptr),
WriteMSR(nullptr),
GetIAFrequency(nullptr),
GetTDP(nullptr),
GetMaxTemperature(nullptr),
GetThresholds(nullptr),
GetTemperature(nullptr),
ReadSample(nullptr),
GetSysTime(nullptr),
GetRDTSC(nullptr),
GetTimeInterval(nullptr),
GetBaseFrequency(nullptr),
GetPowerData(nullptr),
StartLog(nullptr),
StopLog(nullptr),
GetNumMsrs(nullptr),
packageMSR(-1),
cpuMSR(-1),
freqMSR(-1),
tempMSR(-1)
{
}
bool
IntelPowerGadget::Init()
{
bool success = false;
const char *path = PR_GetEnv("IPG_Dir");
nsCString ipg_library;
if (path && *path) {
ipg_library.Append(path);
ipg_library.Append('/');
ipg_library.AppendLiteral(PG_LIBRARY_NAME);
libpowergadget = PR_LoadLibrary(ipg_library.get());
}
if(libpowergadget) {
Initialize = (IPGInitialize) PR_FindFunctionSymbol(libpowergadget, "IntelEnergyLibInitialize");
GetNumNodes = (IPGGetNumNodes) PR_FindFunctionSymbol(libpowergadget, "GetNumNodes");
GetMsrName = (IPGGetMsrName) PR_FindFunctionSymbol(libpowergadget, "GetMsrName");
GetMsrFunc = (IPGGetMsrFunc) PR_FindFunctionSymbol(libpowergadget, "GetMsrFunc");
ReadMSR = (IPGReadMSR) PR_FindFunctionSymbol(libpowergadget, "ReadMSR");
WriteMSR = (IPGWriteMSR) PR_FindFunctionSymbol(libpowergadget, "WriteMSR");
GetIAFrequency = (IPGGetIAFrequency) PR_FindFunctionSymbol(libpowergadget, "GetIAFrequency");
GetTDP = (IPGGetTDP) PR_FindFunctionSymbol(libpowergadget, "GetTDP");
GetMaxTemperature = (IPGGetMaxTemperature) PR_FindFunctionSymbol(libpowergadget, "GetMaxTemperature");
GetThresholds = (IPGGetThresholds) PR_FindFunctionSymbol(libpowergadget, "GetThresholds");
GetTemperature = (IPGGetTemperature) PR_FindFunctionSymbol(libpowergadget, "GetTemperature");
ReadSample = (IPGReadSample) PR_FindFunctionSymbol(libpowergadget, "ReadSample");
GetSysTime = (IPGGetSysTime) PR_FindFunctionSymbol(libpowergadget, "GetSysTime");
GetRDTSC = (IPGGetRDTSC) PR_FindFunctionSymbol(libpowergadget, "GetRDTSC");
GetTimeInterval = (IPGGetTimeInterval) PR_FindFunctionSymbol(libpowergadget, "GetTimeInterval");
GetBaseFrequency = (IPGGetBaseFrequency) PR_FindFunctionSymbol(libpowergadget, "GetBaseFrequency");
GetPowerData = (IPGGetPowerData) PR_FindFunctionSymbol(libpowergadget, "GetPowerData");
StartLog = (IPGStartLog) PR_FindFunctionSymbol(libpowergadget, "StartLog");
StopLog = (IPGStopLog) PR_FindFunctionSymbol(libpowergadget, "StopLog");
GetNumMsrs = (IPGGetNumMsrs) PR_FindFunctionSymbol(libpowergadget, "GetNumMsrs");
}
if(Initialize) {
Initialize();
int msrCount = GetNumberMsrs();
wchar_t name[1024] = {0};
for(int i = 0; i < msrCount; ++i) {
GetMsrName(i, name);
int func = 0;
GetMsrFunc(i, &func);
// MSR for frequency
if(wcscmp(name, L"CPU Frequency") == 0 && (func == 0)) {
this->freqMSR = i;
}
// MSR for Package
else if(wcscmp(name, L"Processor") == 0 && (func == 1)) {
this->packageMSR = i;
}
// MSR for CPU
else if(wcscmp(name, L"IA") == 0 && (func == 1)) {
this->cpuMSR = i;
}
// MSR for Temperature
else if(wcscmp(name, L"Package") == 0 && (func == 2)) {
this->tempMSR = i;
}
}
// Grab one sample at startup for a diff
TakeSample();
success = true;
}
return success;
}
IntelPowerGadget::~IntelPowerGadget()
{
if(libpowergadget) {
NS_WARNING("Unloading PowerGadget library!\n");
PR_UnloadLibrary(libpowergadget);
libpowergadget = nullptr;
Initialize = nullptr;
GetNumNodes = nullptr;
GetMsrName = nullptr;
GetMsrFunc = nullptr;
ReadMSR = nullptr;
WriteMSR = nullptr;
GetIAFrequency = nullptr;
GetTDP = nullptr;
GetMaxTemperature = nullptr;
GetThresholds = nullptr;
GetTemperature = nullptr;
ReadSample = nullptr;
GetSysTime = nullptr;
GetRDTSC = nullptr;
GetTimeInterval = nullptr;
GetBaseFrequency = nullptr;
GetPowerData = nullptr;
StartLog = nullptr;
StopLog = nullptr;
GetNumMsrs = nullptr;
}
}
int
IntelPowerGadget::GetNumberNodes()
{
int nodes = 0;
if(GetNumNodes) {
int ok = GetNumNodes(&nodes);
}
return nodes;
}
int
IntelPowerGadget::GetNumberMsrs()
{
int msrs = 0;
if(GetNumMsrs) {
int ok = GetNumMsrs(&msrs);
}
return msrs;
}
int
IntelPowerGadget::GetCPUFrequency(int node)
{
int frequency = 0;
if(GetIAFrequency) {
int ok = GetIAFrequency(node, &frequency);
}
return frequency;
}
double
IntelPowerGadget::GetTdp(int node)
{
double tdp = 0.0;
if(GetTDP) {
int ok = GetTDP(node, &tdp);
}
return tdp;
}
int
IntelPowerGadget::GetMaxTemp(int node)
{
int maxTemperatureC = 0;
if(GetMaxTemperature) {
int ok = GetMaxTemperature(node, &maxTemperatureC);
}
return maxTemperatureC;
}
int
IntelPowerGadget::GetTemp(int node)
{
int temperatureC = 0;
if(GetTemperature) {
int ok = GetTemperature(node, &temperatureC);
}
return temperatureC;
}
int
IntelPowerGadget::TakeSample()
{
int ok = 0;
if(ReadSample) {
ok = ReadSample();
}
return ok;
}
uint64_t
IntelPowerGadget::GetRdtsc()
{
uint64_t rdtsc = 0;
if(GetRDTSC) {
int ok = GetRDTSC(&rdtsc);
}
return rdtsc;
}
double
IntelPowerGadget::GetInterval()
{
double interval = 0.0;
if(GetTimeInterval) {
int ok = GetTimeInterval(&interval);
}
return interval;
}
double
IntelPowerGadget::GetCPUBaseFrequency(int node)
{
double freq = 0.0;
if(GetBaseFrequency) {
int ok = GetBaseFrequency(node, &freq);
}
return freq;
}
double
IntelPowerGadget::GetTotalPackagePowerInWatts()
{
int nodes = GetNumberNodes();
double totalPower = 0.0;
for(int i = 0; i < nodes; ++i) {
totalPower += GetPackagePowerInWatts(i);
}
return totalPower;
}
double
IntelPowerGadget::GetPackagePowerInWatts(int node)
{
int numResult = 0;
double result[] = {0.0, 0.0, 0.0};
if(GetPowerData && packageMSR != -1) {
int ok = GetPowerData(node, packageMSR, result, &numResult);
}
return result[0];
}
double
IntelPowerGadget::GetTotalCPUPowerInWatts()
{
int nodes = GetNumberNodes();
double totalPower = 0.0;
for(int i = 0; i < nodes; ++i) {
totalPower += GetCPUPowerInWatts(i);
}
return totalPower;
}
double
IntelPowerGadget::GetCPUPowerInWatts(int node)
{
int numResult = 0;
double result[] = {0.0, 0.0, 0.0};
if(GetPowerData && cpuMSR != -1) {
int ok = GetPowerData(node, cpuMSR, result, &numResult);
}
return result[0];
}
double
IntelPowerGadget::GetTotalGPUPowerInWatts()
{
int nodes = GetNumberNodes();
double totalPower = 0.0;
for(int i = 0; i < nodes; ++i) {
totalPower += GetGPUPowerInWatts(i);
}
return totalPower;
}
double
IntelPowerGadget::GetGPUPowerInWatts(int node)
{
return 0.0;
}

Просмотреть файл

@ -1,150 +0,0 @@
/*
* Copyright 2013, Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author: Joe Olivas <joseph.k.olivas@intel.com>
*/
#ifndef profiler_IntelPowerGadget_h
#define profiler_IntelPowerGadget_h
#ifdef _MSC_VER
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#endif
#include "prlink.h"
typedef int (*IPGInitialize) ();
typedef int (*IPGGetNumNodes) (int *nNodes);
typedef int (*IPGGetNumMsrs) (int *nMsr);
typedef int (*IPGGetMsrName) (int iMsr, wchar_t *szName);
typedef int (*IPGGetMsrFunc) (int iMsr, int *pFuncID);
typedef int (*IPGReadMSR) (int iNode, unsigned int address, uint64_t *value);
typedef int (*IPGWriteMSR) (int iNode, unsigned int address, uint64_t value);
typedef int (*IPGGetIAFrequency) (int iNode, int *freqInMHz);
typedef int (*IPGGetTDP) (int iNode, double *TDP);
typedef int (*IPGGetMaxTemperature) (int iNode, int *degreeC);
typedef int (*IPGGetThresholds) (int iNode, int *degree1C, int *degree2C);
typedef int (*IPGGetTemperature) (int iNode, int *degreeC);
typedef int (*IPGReadSample) ();
typedef int (*IPGGetSysTime) (void *pSysTime);
typedef int (*IPGGetRDTSC) (uint64_t *pTSC);
typedef int (*IPGGetTimeInterval) (double *pOffset);
typedef int (*IPGGetBaseFrequency) (int iNode, double *pBaseFrequency);
typedef int (*IPGGetPowerData) (int iNode, int iMSR, double *pResult, int *nResult);
typedef int (*IPGStartLog) (wchar_t *szFileName);
typedef int (*IPGStopLog) ();
#if defined(__x86_64__) || defined(__x86_64) || defined(_M_AMD64)
#define PG_LIBRARY_NAME "EnergyLib64"
#else
#define PG_LIBRARY_NAME "EnergyLib32"
#endif
class IntelPowerGadget
{
public:
IntelPowerGadget();
~IntelPowerGadget();
// Fails if initialization is incomplete
bool Init();
// Returns the number of packages on the system
int GetNumberNodes();
// Returns the number of MSRs being tracked
int GetNumberMsrs();
// Given a node, returns the temperature
int GetCPUFrequency(int);
// Returns the TDP of the given node
double GetTdp(int);
// Returns the maximum temperature for the given node
int GetMaxTemp(int);
// Returns the current temperature in degrees C
// of the given node
int GetTemp(int);
// Takes a sample of data. Must be called before
// any current data is retrieved.
int TakeSample();
// Gets the timestamp of the most recent sample
uint64_t GetRdtsc();
// returns number of seconds between the last
// two samples
double GetInterval();
// Returns the base frequency for the given node
double GetCPUBaseFrequency(int node);
// Returns the combined package power for all
// packages on the system for the last sample.
double GetTotalPackagePowerInWatts();
double GetPackagePowerInWatts(int node);
// Returns the combined CPU power for all
// packages on the system for the last sample.
// If the reading is not available, returns 0.0
double GetTotalCPUPowerInWatts();
double GetCPUPowerInWatts(int node);
// Returns the combined GPU power for all
// packages on the system for the last sample.
// If the reading is not available, returns 0.0
double GetTotalGPUPowerInWatts();
double GetGPUPowerInWatts(int node);
private:
PRLibrary *libpowergadget;
IPGInitialize Initialize;
IPGGetNumNodes GetNumNodes;
IPGGetNumMsrs GetNumMsrs;
IPGGetMsrName GetMsrName;
IPGGetMsrFunc GetMsrFunc;
IPGReadMSR ReadMSR;
IPGWriteMSR WriteMSR;
IPGGetIAFrequency GetIAFrequency;
IPGGetTDP GetTDP;
IPGGetMaxTemperature GetMaxTemperature;
IPGGetThresholds GetThresholds;
IPGGetTemperature GetTemperature;
IPGReadSample ReadSample;
IPGGetSysTime GetSysTime;
IPGGetRDTSC GetRDTSC;
IPGGetTimeInterval GetTimeInterval;
IPGGetBaseFrequency GetBaseFrequency;
IPGGetPowerData GetPowerData;
IPGStartLog StartLog;
IPGStopLog StopLog;
int packageMSR;
int cpuMSR;
int freqMSR;
int tempMSR;
};
#endif // profiler_IntelPowerGadget_h

Просмотреть файл

@ -612,7 +612,6 @@ struct ProfileSample
Maybe<double> mRSS;
Maybe<double> mUSS;
Maybe<int> mFrameNumber;
Maybe<double> mPower;
};
static void WriteSample(SpliceableJSONWriter& aWriter, ProfileSample& aSample)
@ -623,8 +622,7 @@ static void WriteSample(SpliceableJSONWriter& aWriter, ProfileSample& aSample)
RESPONSIVENESS = 2,
RSS = 3,
USS = 4,
FRAME_NUMBER = 5,
POWER = 6
FRAME_NUMBER = 5
};
AutoArraySchemaWriter writer(aWriter);
@ -650,10 +648,6 @@ static void WriteSample(SpliceableJSONWriter& aWriter, ProfileSample& aSample)
if (aSample.mFrameNumber.isSome()) {
writer.IntElement(FRAME_NUMBER, *aSample.mFrameNumber);
}
if (aSample.mPower.isSome()) {
writer.DoubleElement(POWER, *aSample.mPower);
}
}
void ProfileBuffer::StreamSamplesToJSON(SpliceableJSONWriter& aWriter, int aThreadId,
@ -686,11 +680,6 @@ void ProfileBuffer::StreamSamplesToJSON(SpliceableJSONWriter& aWriter, int aThre
sample->mResponsiveness = Some(entry.mTagDouble);
}
break;
case 'p':
if (sample.isSome()) {
sample->mPower = Some(entry.mTagDouble);
}
break;
case 'R':
if (sample.isSome()) {
sample->mRSS = Some(entry.mTagDouble);

Просмотреть файл

@ -340,8 +340,7 @@ private:
// "responsiveness": 2, /* number */
// "rss": 3, /* number */
// "uss": 4, /* number */
// "frameNumber": 5, /* number */
// "power": 6 /* number */
// "frameNumber": 5 /* number */
// },
// "data":
// [

Просмотреть файл

@ -124,7 +124,6 @@ void ThreadProfile::StreamSamplesAndMarkers(SpliceableJSONWriter& aWriter, doubl
schema.WriteField("rss");
schema.WriteField("uss");
schema.WriteField("frameNumber");
schema.WriteField("power");
}
aWriter.StartArrayProperty("data");

Просмотреть файл

@ -817,10 +817,6 @@ const char** mozilla_sampler_get_features()
#ifdef MOZ_TASK_TRACER
// Start profiling with feature TaskTracer.
"tasktracer",
#endif
#if defined(XP_WIN)
// Add power collection
"power",
#endif
nullptr
};

Просмотреть файл

@ -86,7 +86,6 @@ if CONFIG['MOZ_ENABLE_PROFILER_SPS']:
]
elif CONFIG['OS_TARGET'] == 'WINNT':
SOURCES += [
'core/IntelPowerGadget.cpp',
'core/platform-win32.cc',
'core/shared-libraries-win32.cc',
]