[llvm] [memprof] Call SmallVector::reserve (PR #86055)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 20 18:39:12 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/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.
>From ddcda0f24f8b047be96c99448065bf8306d0f6e3 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 20 Mar 2024 18:32:08 -0700
Subject: [PATCH] [memprof] Call SmallVector::reserve
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.
---
llvm/lib/ProfileData/RawMemProfReader.cpp | 1 +
1 file changed, 1 insertion(+)
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