Commit 0e604f9f by Jamie Madill Committed by Commit Bot

ANGLE Perf Test fixes.

Includes the following fixes: * Removes obsolete global variable. * Disables trace event collection when trace events disabled. * Fixes calibrated steps getting stuck after first test. * Scale calibrated steps with actual time after glFinish. Should fix a few crashes and timeouts with the perf tests. Bug: angleproject:2923 Change-Id: I9ba1c042dee31cf2400ccbeedca0d497ed52fb12 Reviewed-on: https://chromium-review.googlesource.com/c/1343677Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent b81ff9e6
...@@ -32,6 +32,8 @@ constexpr unsigned int kNumTrials = 3; ...@@ -32,6 +32,8 @@ constexpr unsigned int kNumTrials = 3;
bool gCalibration = false; bool gCalibration = false;
Optional<unsigned int> gStepsToRunOverride; Optional<unsigned int> gStepsToRunOverride;
bool gEnableTrace = false;
const char *gTraceFile = "ANGLETrace.json";
struct TraceCategory struct TraceCategory
{ {
...@@ -66,6 +68,9 @@ angle::TraceEventHandle AddTraceEvent(angle::PlatformMethods *platform, ...@@ -66,6 +68,9 @@ angle::TraceEventHandle AddTraceEvent(angle::PlatformMethods *platform,
const unsigned long long *argValues, const unsigned long long *argValues,
unsigned char flags) unsigned char flags)
{ {
if (!gEnableTrace)
return 0;
// Discover the category name based on categoryEnabledFlag. This flag comes from the first // Discover the category name based on categoryEnabledFlag. This flag comes from the first
// parameter of TraceCategory, and corresponds to one of the entries in gTraceCategories. // parameter of TraceCategory, and corresponds to one of the entries in gTraceCategories.
static_assert(offsetof(TraceCategory, enabled) == 0, static_assert(offsetof(TraceCategory, enabled) == 0,
...@@ -83,11 +88,14 @@ angle::TraceEventHandle AddTraceEvent(angle::PlatformMethods *platform, ...@@ -83,11 +88,14 @@ angle::TraceEventHandle AddTraceEvent(angle::PlatformMethods *platform,
const unsigned char *GetTraceCategoryEnabledFlag(angle::PlatformMethods *platform, const unsigned char *GetTraceCategoryEnabledFlag(angle::PlatformMethods *platform,
const char *categoryName) const char *categoryName)
{ {
for (const TraceCategory &category : gTraceCategories) if (gEnableTrace)
{ {
if (strcmp(category.name, categoryName) == 0) for (const TraceCategory &category : gTraceCategories)
{ {
return &category.enabled; if (strcmp(category.name, categoryName) == 0)
{
return &category.enabled;
}
} }
} }
...@@ -148,11 +156,12 @@ void DumpTraceEventsToJSONFile(const std::vector<TraceEvent> &traceEvents, ...@@ -148,11 +156,12 @@ void DumpTraceEventsToJSONFile(const std::vector<TraceEvent> &traceEvents,
outFile.close(); outFile.close();
} }
} // anonymous namespace
bool g_OnlyOneRunFrame = false; bool OneFrame()
bool gEnableTrace = false; {
const char *gTraceFile = "ANGLETrace.json"; return gStepsToRunOverride.valid() && gStepsToRunOverride.value() == 1;
}
} // anonymous namespace
ANGLEPerfTest::ANGLEPerfTest(const std::string &name, ANGLEPerfTest::ANGLEPerfTest(const std::string &name,
const std::string &suffix, const std::string &suffix,
...@@ -161,6 +170,7 @@ ANGLEPerfTest::ANGLEPerfTest(const std::string &name, ...@@ -161,6 +170,7 @@ ANGLEPerfTest::ANGLEPerfTest(const std::string &name,
mSuffix(suffix), mSuffix(suffix),
mTimer(CreateTimer()), mTimer(CreateTimer()),
mSkipTest(false), mSkipTest(false),
mStepsToRun(std::numeric_limits<unsigned int>::max()),
mNumStepsPerformed(0), mNumStepsPerformed(0),
mIterationsPerStep(iterationsPerStep), mIterationsPerStep(iterationsPerStep),
mRunning(true) mRunning(true)
...@@ -184,14 +194,20 @@ void ANGLEPerfTest::run() ...@@ -184,14 +194,20 @@ void ANGLEPerfTest::run()
{ {
doRunLoop(kCalibrationRunTimeSeconds); doRunLoop(kCalibrationRunTimeSeconds);
// Scale steps down according to the time that exeeded one second.
double scale = kCalibrationRunTimeSeconds / mTimer->getElapsedTime();
mStepsToRun = static_cast<size_t>(static_cast<double>(mNumStepsPerformed) * scale);
// Calibration allows the perf test runner script to save some time. // Calibration allows the perf test runner script to save some time.
if (gCalibration) if (gCalibration)
{ {
printResult("steps", static_cast<size_t>(mNumStepsPerformed), "count", false); printResult("steps", static_cast<size_t>(mStepsToRun), "count", false);
return; return;
} }
}
gStepsToRunOverride = mNumStepsPerformed; else
{
mStepsToRun = gStepsToRunOverride.value();
} }
// Do another warmup run. Seems to consistently improve results. // Do another warmup run. Seems to consistently improve results.
...@@ -220,8 +236,7 @@ void ANGLEPerfTest::doRunLoop(double maxRunTime) ...@@ -220,8 +236,7 @@ void ANGLEPerfTest::doRunLoop(double maxRunTime)
{ {
mRunning = false; mRunning = false;
} }
else if (gStepsToRunOverride.valid() && else if (mNumStepsPerformed >= mStepsToRun)
mNumStepsPerformed >= gStepsToRunOverride.value())
{ {
mRunning = false; mRunning = false;
} }
...@@ -297,19 +312,15 @@ std::string RenderTestParams::suffix() const ...@@ -297,19 +312,15 @@ std::string RenderTestParams::suffix() const
} }
ANGLERenderTest::ANGLERenderTest(const std::string &name, const RenderTestParams &testParams) ANGLERenderTest::ANGLERenderTest(const std::string &name, const RenderTestParams &testParams)
: ANGLEPerfTest(name, : ANGLEPerfTest(name, testParams.suffix(), OneFrame() ? 1 : testParams.iterationsPerStep),
testParams.suffix(),
g_OnlyOneRunFrame ? 1 : testParams.iterationsPerStep),
mTestParams(testParams), mTestParams(testParams),
mEGLWindow(createEGLWindow(testParams)), mEGLWindow(createEGLWindow(testParams)),
mOSWindow(nullptr) mOSWindow(nullptr)
{ {
// Force fast tests to make sure our slowest bots don't time out. // Force fast tests to make sure our slowest bots don't time out.
// TODO(jmadill): Remove this flag once rolled into Chromium. http://anglebug.com/2923 if (OneFrame())
if (g_OnlyOneRunFrame)
{ {
const_cast<RenderTestParams &>(testParams).iterationsPerStep = 1; const_cast<RenderTestParams &>(testParams).iterationsPerStep = 1;
gStepsToRunOverride = 1;
} }
// Try to ensure we don't trigger allocation during execution. // Try to ensure we don't trigger allocation during execution.
...@@ -491,7 +502,6 @@ void ANGLEProcessPerfTestArgs(int *argc, char **argv) ...@@ -491,7 +502,6 @@ void ANGLEProcessPerfTestArgs(int *argc, char **argv)
{ {
if (strcmp("--one-frame-only", argv[argIndex]) == 0) if (strcmp("--one-frame-only", argv[argIndex]) == 0)
{ {
g_OnlyOneRunFrame = true;
gStepsToRunOverride = 1; gStepsToRunOverride = 1;
} }
else if (strcmp("--enable-trace", argv[argIndex]) == 0) else if (strcmp("--enable-trace", argv[argIndex]) == 0)
......
...@@ -94,6 +94,7 @@ class ANGLEPerfTest : public testing::Test, angle::NonCopyable ...@@ -94,6 +94,7 @@ class ANGLEPerfTest : public testing::Test, angle::NonCopyable
private: private:
void printResults(); void printResults();
unsigned int mStepsToRun;
unsigned int mNumStepsPerformed; unsigned int mNumStepsPerformed;
unsigned int mIterationsPerStep; unsigned int mIterationsPerStep;
bool mRunning; bool mRunning;
...@@ -155,6 +156,4 @@ class ANGLERenderTest : public ANGLEPerfTest ...@@ -155,6 +156,4 @@ class ANGLERenderTest : public ANGLEPerfTest
std::vector<TraceEvent> mTraceEventBuffer; std::vector<TraceEvent> mTraceEventBuffer;
}; };
extern bool g_OnlyOneRunFrame;
#endif // PERF_TESTS_ANGLE_PERF_TEST_H_ #endif // PERF_TESTS_ANGLE_PERF_TEST_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment