[StaticDataLayout] Sort records before printing them in text format (#172592)
This change proposes to sort records before printing to make it more readable and easier to compare.
This commit is contained in:
parent
5a54d0f3af
commit
4822b43ae4
@ -1554,6 +1554,12 @@ memprof::AllMemProfData IndexedMemProfReader::getAllMemProfData() const {
|
||||
}
|
||||
// Populate the data access profiles for yaml output.
|
||||
if (DataAccessProfileData != nullptr) {
|
||||
AllMemProfData.YamlifiedDataAccessProfiles.Records.reserve(
|
||||
DataAccessProfileData->getRecords().size());
|
||||
AllMemProfData.YamlifiedDataAccessProfiles.KnownColdSymbols.reserve(
|
||||
DataAccessProfileData->getKnownColdSymbols().size());
|
||||
AllMemProfData.YamlifiedDataAccessProfiles.KnownColdStrHashes.reserve(
|
||||
DataAccessProfileData->getKnownColdHashes().size());
|
||||
for (const auto &[SymHandleRef, RecordRef] :
|
||||
DataAccessProfileData->getRecords())
|
||||
AllMemProfData.YamlifiedDataAccessProfiles.Records.push_back(
|
||||
@ -1565,6 +1571,19 @@ memprof::AllMemProfData IndexedMemProfReader::getAllMemProfData() const {
|
||||
for (uint64_t Hash : DataAccessProfileData->getKnownColdHashes())
|
||||
AllMemProfData.YamlifiedDataAccessProfiles.KnownColdStrHashes.push_back(
|
||||
Hash);
|
||||
llvm::stable_sort(AllMemProfData.YamlifiedDataAccessProfiles.Records,
|
||||
[](const llvm::memprof::DataAccessProfRecord &lhs,
|
||||
const llvm::memprof::DataAccessProfRecord &rhs) {
|
||||
return lhs.AccessCount > rhs.AccessCount;
|
||||
});
|
||||
llvm::stable_sort(
|
||||
AllMemProfData.YamlifiedDataAccessProfiles.KnownColdSymbols,
|
||||
[](const std::string &lhs, const std::string &rhs) {
|
||||
return lhs < rhs;
|
||||
});
|
||||
llvm::stable_sort(
|
||||
AllMemProfData.YamlifiedDataAccessProfiles.KnownColdStrHashes,
|
||||
[](const uint64_t &lhs, const uint64_t &rhs) { return lhs < rhs; });
|
||||
}
|
||||
return AllMemProfData;
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ HeapProfileRecords:
|
||||
DataAccessProfiles:
|
||||
SampledRecords:
|
||||
- Symbol: abcde
|
||||
AccessCount: 100
|
||||
AccessCount: 202
|
||||
Locations:
|
||||
- FileName: file2.h
|
||||
Line: 123
|
||||
@ -88,8 +88,8 @@ DataAccessProfiles:
|
||||
- FileName: file.cpp
|
||||
Line: 233
|
||||
KnownColdSymbols:
|
||||
- foo
|
||||
- bar
|
||||
- foo
|
||||
KnownColdStrHashes: [ 999, 1001 ]
|
||||
...
|
||||
;--- memprof-in-v3.yaml
|
||||
@ -233,7 +233,7 @@ HeapProfileRecords:
|
||||
DataAccessProfiles:
|
||||
SampledRecords:
|
||||
- Symbol: abcde
|
||||
AccessCount: 100
|
||||
AccessCount: 202
|
||||
Locations:
|
||||
- FileName: file2.h
|
||||
Line: 123
|
||||
@ -245,7 +245,7 @@ DataAccessProfiles:
|
||||
- FileName: file.cpp
|
||||
Line: 233
|
||||
KnownColdSymbols:
|
||||
- foo
|
||||
- bar
|
||||
- foo
|
||||
KnownColdStrHashes: [ 999, 1001 ]
|
||||
...
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user