mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
[ProfileData] Use a different data structure to save memory.
This change swaps FunctionSamples to a std::map. This saves us around 17% of the memory required to parse sample profiles. To put hard numbers on this, clang now eats around 1.3GB of RAM instead of 1.6GB while parsing a 50MB profile. The CPU time taken by a large profile merge (3.1GB of data across 226 files) is also reduced by ~11% by this patch (1:09.08 vs 1:01.11). This was split out at the request of reviewers in D41152. llvm-svn: 320764
This commit is contained in:
parent
7cdf778e13
commit
eef4390e6c
@ -185,7 +185,9 @@ raw_ostream &operator<<(raw_ostream &OS, const SampleRecord &Sample);
|
||||
class FunctionSamples;
|
||||
|
||||
using BodySampleMap = std::map<LineLocation, SampleRecord>;
|
||||
using FunctionSamplesMap = StringMap<FunctionSamples>;
|
||||
// NOTE: Using a StringMap here makes parsed profiles consume around 17% more
|
||||
// memory, which is *very* significant for large profiles.
|
||||
using FunctionSamplesMap = std::map<std::string, FunctionSamples>;
|
||||
using CallsiteSampleMap = std::map<LineLocation, FunctionSamplesMap>;
|
||||
|
||||
/// Representation of the samples collected for a function.
|
||||
@ -278,7 +280,7 @@ public:
|
||||
return nullptr;
|
||||
auto FS = iter->second.find(CalleeName);
|
||||
if (FS != iter->second.end())
|
||||
return &FS->getValue();
|
||||
return &FS->second;
|
||||
// If we cannot find exact match of the callee name, return the FS with
|
||||
// the max total count.
|
||||
uint64_t MaxTotalSamples = 0;
|
||||
@ -347,7 +349,7 @@ public:
|
||||
const LineLocation &Loc = I.first;
|
||||
FunctionSamplesMap &FSMap = functionSamplesAt(Loc);
|
||||
for (const auto &Rec : I.second)
|
||||
MergeResult(Result, FSMap[Rec.first()].merge(Rec.second, Weight));
|
||||
MergeResult(Result, FSMap[Rec.first].merge(Rec.second, Weight));
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user