Skip to content

Commit

Permalink
ANGLE Perf Test fixes.
Browse files Browse the repository at this point in the history
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/1343677
Reviewed-by: Yuly Novikov <[email protected]>
Reviewed-by: Jamie Madill <[email protected]>
Commit-Queue: Jamie Madill <[email protected]>
  • Loading branch information
null77 authored and Commit Bot committed Nov 20, 2018
1 parent b81ff9e commit 0e604f9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
48 changes: 29 additions & 19 deletions src/tests/perf_tests/ANGLEPerfTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ constexpr unsigned int kNumTrials = 3;

bool gCalibration = false;
Optional<unsigned int> gStepsToRunOverride;
bool gEnableTrace = false;
const char *gTraceFile = "ANGLETrace.json";

struct TraceCategory
{
Expand Down Expand Up @@ -66,6 +68,9 @@ angle::TraceEventHandle AddTraceEvent(angle::PlatformMethods *platform,
const unsigned long long *argValues,
unsigned char flags)
{
if (!gEnableTrace)
return 0;

// 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.
static_assert(offsetof(TraceCategory, enabled) == 0,
Expand All @@ -83,11 +88,14 @@ angle::TraceEventHandle AddTraceEvent(angle::PlatformMethods *platform,
const unsigned char *GetTraceCategoryEnabledFlag(angle::PlatformMethods *platform,
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;
}
}
}

Expand Down Expand Up @@ -148,11 +156,12 @@ void DumpTraceEventsToJSONFile(const std::vector<TraceEvent> &traceEvents,

outFile.close();
}
} // anonymous namespace

bool g_OnlyOneRunFrame = false;
bool gEnableTrace = false;
const char *gTraceFile = "ANGLETrace.json";
bool OneFrame()
{
return gStepsToRunOverride.valid() && gStepsToRunOverride.value() == 1;
}
} // anonymous namespace

ANGLEPerfTest::ANGLEPerfTest(const std::string &name,
const std::string &suffix,
Expand All @@ -161,6 +170,7 @@ ANGLEPerfTest::ANGLEPerfTest(const std::string &name,
mSuffix(suffix),
mTimer(CreateTimer()),
mSkipTest(false),
mStepsToRun(std::numeric_limits<unsigned int>::max()),
mNumStepsPerformed(0),
mIterationsPerStep(iterationsPerStep),
mRunning(true)
Expand All @@ -184,14 +194,20 @@ void ANGLEPerfTest::run()
{
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.
if (gCalibration)
{
printResult("steps", static_cast<size_t>(mNumStepsPerformed), "count", false);
printResult("steps", static_cast<size_t>(mStepsToRun), "count", false);
return;
}

gStepsToRunOverride = mNumStepsPerformed;
}
else
{
mStepsToRun = gStepsToRunOverride.value();
}

// Do another warmup run. Seems to consistently improve results.
Expand Down Expand Up @@ -220,8 +236,7 @@ void ANGLEPerfTest::doRunLoop(double maxRunTime)
{
mRunning = false;
}
else if (gStepsToRunOverride.valid() &&
mNumStepsPerformed >= gStepsToRunOverride.value())
else if (mNumStepsPerformed >= mStepsToRun)
{
mRunning = false;
}
Expand Down Expand Up @@ -297,19 +312,15 @@ std::string RenderTestParams::suffix() const
}

ANGLERenderTest::ANGLERenderTest(const std::string &name, const RenderTestParams &testParams)
: ANGLEPerfTest(name,
testParams.suffix(),
g_OnlyOneRunFrame ? 1 : testParams.iterationsPerStep),
: ANGLEPerfTest(name, testParams.suffix(), OneFrame() ? 1 : testParams.iterationsPerStep),
mTestParams(testParams),
mEGLWindow(createEGLWindow(testParams)),
mOSWindow(nullptr)
{
// 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 (g_OnlyOneRunFrame)
if (OneFrame())
{
const_cast<RenderTestParams &>(testParams).iterationsPerStep = 1;
gStepsToRunOverride = 1;
}

// Try to ensure we don't trigger allocation during execution.
Expand Down Expand Up @@ -491,7 +502,6 @@ void ANGLEProcessPerfTestArgs(int *argc, char **argv)
{
if (strcmp("--one-frame-only", argv[argIndex]) == 0)
{
g_OnlyOneRunFrame = true;
gStepsToRunOverride = 1;
}
else if (strcmp("--enable-trace", argv[argIndex]) == 0)
Expand Down
3 changes: 1 addition & 2 deletions src/tests/perf_tests/ANGLEPerfTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class ANGLEPerfTest : public testing::Test, angle::NonCopyable
private:
void printResults();

unsigned int mStepsToRun;
unsigned int mNumStepsPerformed;
unsigned int mIterationsPerStep;
bool mRunning;
Expand Down Expand Up @@ -155,6 +156,4 @@ class ANGLERenderTest : public ANGLEPerfTest
std::vector<TraceEvent> mTraceEventBuffer;
};

extern bool g_OnlyOneRunFrame;

#endif // PERF_TESTS_ANGLE_PERF_TEST_H_

0 comments on commit 0e604f9

Please sign in to comment.