[llvm] f5ef9bd - [memprof] Call SmallVector::reserve (#86055)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 21 11:17:55 PDT 2024
Author: Kazu Hirata
Date: 2024-03-21T11:17:52-07:00
New Revision: f5ef9bd26d531d104f44f9e5b283bd2f80c024be
URL: https://github.com/llvm/llvm-project/commit/f5ef9bd26d531d104f44f9e5b283bd2f80c024be
DIFF: https://github.com/llvm/llvm-project/commit/f5ef9bd26d531d104f44f9e5b283bd2f80c024be.diff
LOG: [memprof] Call SmallVector::reserve (#86055)
With one raw memprof file I have, NumPCs averages about 41. Given the
default number of inline elements being 8 for SmallVector<uint64_t>,
we should reserve the storage in advance.
Added:
Modified:
llvm/lib/ProfileData/RawMemProfReader.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ProfileData/RawMemProfReader.cpp b/llvm/lib/ProfileData/RawMemProfReader.cpp
index 0e2b8668bab72c..60c37c417aa049 100644
--- a/llvm/lib/ProfileData/RawMemProfReader.cpp
+++ b/llvm/lib/ProfileData/RawMemProfReader.cpp
@@ -127,6 +127,7 @@ CallStackMap readStackInfo(const char *Ptr) {
endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr);
SmallVector<uint64_t> CallStack;
+ CallStack.reserve(NumPCs);
for (uint64_t J = 0; J < NumPCs; J++) {
CallStack.push_back(
endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr));
More information about the llvm-commits
mailing list