[llvm] r297546 - [libFuzzer] print how much memory is consumed by the outer merge process (https://github.com/google/oss-fuzz/issues/445)
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 10 18:26:21 PST 2017
Author: kcc
Date: Fri Mar 10 20:26:20 2017
New Revision: 297546
URL: http://llvm.org/viewvc/llvm-project?rev=297546&view=rev
Log:
[libFuzzer] print how much memory is consumed by the outer merge process (https://github.com/google/oss-fuzz/issues/445)
Modified:
llvm/trunk/lib/Fuzzer/FuzzerMerge.cpp
llvm/trunk/lib/Fuzzer/FuzzerMerge.h
Modified: llvm/trunk/lib/Fuzzer/FuzzerMerge.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerMerge.cpp?rev=297546&r1=297545&r2=297546&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerMerge.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerMerge.cpp Fri Mar 10 20:26:20 2017
@@ -17,6 +17,7 @@
#include <fstream>
#include <iterator>
+#include <set>
#include <sstream>
namespace fuzzer {
@@ -88,7 +89,7 @@ bool Merger::Parse(std::istream &IS, boo
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, boo
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 s
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",
Modified: llvm/trunk/lib/Fuzzer/FuzzerMerge.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerMerge.h?rev=297546&r1=297545&r2=297546&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerMerge.h (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerMerge.h Fri Mar 10 20:26:20 2017
@@ -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
More information about the llvm-commits
mailing list