Skip to content

Commit 74d5264

Browse files
author
mxms
committed
[ProfData] Improve efficiency of reader
Pre-reserve space in the map before inserting. In release builds, 9.4% of all CPU time is spent in llvm::sampleprof::ProfileSymbolList::add. Of that 9.4%, roughly half is in llvm::DenseMapBase::grow.
1 parent 3c994a3 commit 74d5264

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

llvm/lib/ProfileData/SampleProf.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,10 @@ std::error_code ProfileSymbolList::read(const uint8_t *Data,
404404
uint64_t ExpectedCount = 0;
405405

406406
// Scan forward to see how many elements we expect.
407-
while (Offset < ListSize) {
408-
if (ListStart[Offset] == '\0') ExpectedCount++;
409-
Offset++;
407+
while (Size < ListSize) {
408+
if (ListStart[Size] == '\0') ExpectedCount++;
409+
Size++;
410+
}
410411

411412
reserve(ExpectedCount);
412413

0 commit comments

Comments
 (0)