OSDN Git Service

[libFuzzer] print how much memory is consumed by the outer merge process (https:...
authorKostya Serebryany <kcc@google.com>
Sat, 11 Mar 2017 02:26:20 +0000 (02:26 +0000)
committerKostya Serebryany <kcc@google.com>
Sat, 11 Mar 2017 02:26:20 +0000 (02:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297546 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Fuzzer/FuzzerMerge.cpp
lib/Fuzzer/FuzzerMerge.h

index 344d7a8..5c17f66 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <fstream>
 #include <iterator>
+#include <set>
 #include <sstream>
 
 namespace fuzzer {
@@ -88,7 +89,7 @@ bool Merger::Parse(std::istream &IS, bool ParseCoverage) {
       assert(ExpectedStartMarker < Files.size());
       ExpectedStartMarker++;
     } else if (Marker == "DONE") {
-      // DONE FILE_SIZE COV1 COV2 COV3 ...
+      // DONE FILE_ID COV1 COV2 COV3 ...
       size_t CurrentFileIdx = N;
       if (CurrentFileIdx != LastSeenStartMarker)
         return false;
@@ -111,6 +112,13 @@ bool Merger::Parse(std::istream &IS, bool ParseCoverage) {
   return true;
 }
 
+size_t Merger::ApproximateMemoryConsumption() const  {
+  size_t Res = 0;
+  for (const auto &F: Files)
+    Res += sizeof(F) + F.Features.size() * sizeof(F.Features[0]);
+  return Res;
+}
+
 // Decides which files need to be merged (add thost to NewFiles).
 // Returns the number of new features added.
 size_t Merger::Merge(std::vector<std::string> *NewFiles) {
@@ -262,6 +270,8 @@ void Fuzzer::CrashResistantMerge(const std::vector<std::string> &Args,
   IF.seekg(0, IF.beg);
   M.ParseOrExit(IF, true);
   IF.close();
+  Printf("MERGE-OUTER: consumed %zd bytes to parse the control file\n",
+         M.ApproximateMemoryConsumption());
   std::vector<std::string> NewFiles;
   size_t NumNewFeatures = M.Merge(&NewFiles);
   Printf("MERGE-OUTER: %zd new files with %zd new features added\n",
index 8a2fe5d..4cef9c4 100644 (file)
@@ -43,7 +43,6 @@
 #include "FuzzerDefs.h"
 
 #include <istream>
-#include <set>
 
 namespace fuzzer {
 
@@ -63,6 +62,7 @@ struct Merger {
   bool Parse(const std::string &Str, bool ParseCoverage);
   void ParseOrExit(std::istream &IS, bool ParseCoverage);
   size_t Merge(std::vector<std::string> *NewFiles);
+  size_t ApproximateMemoryConsumption() const;
 };
 
 }  // namespace fuzzer