From 7c2c456eeeffa18b3d1b0b1692e6305b47ffb24f Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 8 Oct 2014 14:56:46 -0700 Subject: [PATCH] Bug 1079657 - DMD: Remove the "stress" mode. r=erahm. --HG-- extra : rebase_source : d0b233a62c1b50facb27d781f9942628f100180e --- memory/replace/dmd/DMD.cpp | 95 +------------------------------------- 1 file changed, 2 insertions(+), 93 deletions(-) diff --git a/memory/replace/dmd/DMD.cpp b/memory/replace/dmd/DMD.cpp index b0ec4f1287da..d889cf463efc 100644 --- a/memory/replace/dmd/DMD.cpp +++ b/memory/replace/dmd/DMD.cpp @@ -291,8 +291,7 @@ class Options enum Mode { Normal, // run normally - Test, // do some basic correctness tests - Stress // do some performance stress tests + Test // do some basic correctness tests }; char* mDMDEnvVar; // a saved copy, for later printing @@ -320,7 +319,6 @@ public: void SetSampleBelowSize(size_t aN) { mSampleBelowSize.mActual = aN; } bool IsTestMode() const { return mMode == Test; } - bool IsStressMode() const { return mMode == Stress; } }; static Options *gOptions; @@ -1320,8 +1318,6 @@ Options::Options(const char* aDMDEnvVar) mMode = Options::Normal; } else if (strcmp(arg, "--mode=test") == 0) { mMode = Options::Test; - } else if (strcmp(arg, "--mode=stress") == 0) { - mMode = Options::Stress; } else if (strcmp(arg, "") == 0) { // This can only happen if there is trailing whitespace. Ignore. @@ -1358,7 +1354,7 @@ Options::BadArg(const char* aArg) int(mMaxFrames.mMax), int(mMaxFrames.mDefault)); StatusMsg(" --show-dump-stats= Show stats about dumps? [no]\n"); - StatusMsg(" --mode= Mode of operation [normal]\n"); + StatusMsg(" --mode= Mode of operation [normal]\n"); StatusMsg("\n"); exit(1); } @@ -1389,7 +1385,6 @@ OpenOutputFile(const char* aFilename) static void RunTestMode(UniquePtr aF1, UniquePtr aF2, UniquePtr aF3, UniquePtr aF4); -static void RunStressMode(UniquePtr aF); // WARNING: this function runs *very* early -- before all static initializers // have run. For this reason, non-scalar globals such as gStateLock and @@ -1462,16 +1457,6 @@ Init(const malloc_table_t* aMallocTable) exit(0); } - if (gOptions->IsStressMode()) { - auto f = MakeUnique(OpenOutputFile("stress.json")); - gIsDMDRunning = true; - - StatusMsg("running stress mode...\n"); - RunStressMode(Move(f)); - StatusMsg("finished stress mode\n"); - exit(0); - } - gIsDMDRunning = true; } @@ -2088,81 +2073,5 @@ RunTestMode(UniquePtr aF1, UniquePtr aF2, AnalyzeReports(writer4); } -//--------------------------------------------------------------------------- -// Stress testing microbenchmark -//--------------------------------------------------------------------------- - -// This stops otherwise-unused variables from being optimized away. -static void -UseItOrLoseIt2(void* a) -{ - if (a == (void*)0x42) { - printf("UseItOrLoseIt2\n"); - } -} - -MOZ_NEVER_INLINE static void -stress5() -{ - for (int i = 0; i < 10; i++) { - void* x = malloc(64); - UseItOrLoseIt2(x); - if (i & 1) { - free(x); - } - } -} - -MOZ_NEVER_INLINE static void -stress4() -{ - stress5(); stress5(); stress5(); stress5(); stress5(); - stress5(); stress5(); stress5(); stress5(); stress5(); -} - -MOZ_NEVER_INLINE static void -stress3() -{ - for (int i = 0; i < 10; i++) { - stress4(); - } -} - -MOZ_NEVER_INLINE static void -stress2() -{ - stress3(); stress3(); stress3(); stress3(); stress3(); - stress3(); stress3(); stress3(); stress3(); stress3(); -} - -MOZ_NEVER_INLINE static void -stress1() -{ - for (int i = 0; i < 10; i++) { - stress2(); - } -} - -// This stress test does lots of allocations and frees, which is where most of -// DMD's overhead occurs. It allocates 1,000,000 64-byte blocks, spread evenly -// across 1,000 distinct stack traces. It frees every second one immediately -// after allocating it. -// -// It's highly artificial, but it's deterministic and easy to run. It can be -// timed under different conditions to glean performance data. -static void -RunStressMode(UniquePtr aF) -{ - JSONWriter writer(Move(aF)); - - // Disable sampling for maximum stress. - gOptions->SetSampleBelowSize(1); - - stress1(); stress1(); stress1(); stress1(); stress1(); - stress1(); stress1(); stress1(); stress1(); stress1(); - - AnalyzeReports(writer); -} - } // namespace dmd } // namespace mozilla