Bug 1263839: P2. Force re-run of VP9 benchmark based on a version check. r?kentuckyfriedtakahe draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 13 Apr 2016 12:44:29 +1000
changeset 350252 a1b8f36e8d3f3ac1a174b44cbed8af2eb79b9f33
parent 350251 44f916e5134f34c4a03f0df95ff0d76863cc65dd
child 350329 886f2dfae936c071e2bda4ab100a756af3ad1fc1
push id15282
push userbmo:jyavenard@mozilla.com
push dateWed, 13 Apr 2016 02:45:28 +0000
reviewerskentuckyfriedtakahe
bugs1263839
milestone48.0a1
Bug 1263839: P2. Force re-run of VP9 benchmark based on a version check. r?kentuckyfriedtakahe The version number is to be manually updated when we want to re-run the test (like improvement in ffvp9 or libvpx) MozReview-Commit-ID: 9KzYCGWvIpp
dom/ipc/ContentParent.cpp
dom/media/Benchmark.cpp
dom/media/Benchmark.h
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -5712,16 +5712,18 @@ ContentParent::RecvGetAndroidSystemInfo(
 
 bool
 ContentParent::RecvNotifyBenchmarkResult(const nsString& aCodecName,
                                          const uint32_t& aDecodeFPS)
 
 {
   if (aCodecName.EqualsLiteral("VP9")) {
     Preferences::SetUint(VP9Benchmark::sBenchmarkFpsPref, aDecodeFPS);
+    Preferences::SetUint(VP9Benchmark::sBenchmarkFpsVersionCheck,
+                         VP9Benchmark::sBenchmarkVersionID);
   }
   return true;
 }
 
 void
 ContentParent::StartProfiler(nsIProfilerStartParams* aParams)
 {
 #ifdef MOZ_ENABLE_PROFILER_SPS
--- a/dom/media/Benchmark.cpp
+++ b/dom/media/Benchmark.cpp
@@ -11,27 +11,33 @@
 #include "WebMDemuxer.h"
 #include "WebMSample.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/dom/ContentChild.h"
 
 namespace mozilla {
 
+// Update this version number to force re-running the benchmark. Such as when
+// an improvement to FFVP9 or LIBVPX is deemed worthwhile.
+const uint32_t VP9Benchmark::sBenchmarkVersionID = 1;
+
 const char* VP9Benchmark::sBenchmarkFpsPref = "media.benchmark.vp9.fps";
+const char* VP9Benchmark::sBenchmarkFpsVersionCheck = "media.benchmark.vp9.versioncheck";
 bool VP9Benchmark::sHasRunTest = false;
 
 bool
 VP9Benchmark::IsVP9DecodeFast()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   bool hasPref = Preferences::HasUserValue(sBenchmarkFpsPref);
+  uint32_t hadRecentUpdate = Preferences::GetUint(sBenchmarkFpsVersionCheck, 0U);
 
-  if (!sHasRunTest && !hasPref) {
+  if (!sHasRunTest && (!hasPref || hadRecentUpdate != sBenchmarkVersionID)) {
     sHasRunTest = true;
 
     RefPtr<WebMDemuxer> demuxer =
       new WebMDemuxer(new BufferMediaResource(sWebMSample, sizeof(sWebMSample), nullptr,
                                               NS_LITERAL_CSTRING("video/webm")));
     PDMFactory::Init();
 
     RefPtr<Benchmark> estimiser =
@@ -49,16 +55,17 @@ VP9Benchmark::IsVP9DecodeFast()
         if (XRE_IsContentProcess()) {
           dom::ContentChild* contentChild = dom::ContentChild::GetSingleton();
           if (contentChild) {
             contentChild->SendNotifyBenchmarkResult(NS_LITERAL_STRING("VP9"),
                                                     aDecodeFps);
           }
         } else {
           Preferences::SetUint(sBenchmarkFpsPref, aDecodeFps);
+          Preferences::SetUint(sBenchmarkFpsVersionCheck, sBenchmarkVersionID);
         }
         Telemetry::Accumulate(Telemetry::ID::VIDEO_VP9_BENCHMARK_FPS, aDecodeFps);
       },
       []() { });
   }
 
   if (!hasPref) {
     return false;
--- a/dom/media/Benchmark.h
+++ b/dom/media/Benchmark.h
@@ -99,13 +99,15 @@ private:
   MozPromiseHolder<BenchmarkPromise> mPromise;
 };
 
 class VP9Benchmark
 {
 public:
   static bool IsVP9DecodeFast();
   static const char* sBenchmarkFpsPref;
+  static const char* sBenchmarkFpsVersionCheck;
+  static const uint32_t sBenchmarkVersionID;
   static bool sHasRunTest;
 };
 }
 
 #endif