Skip to content

[memprof] Make ContextNode smaller #116271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 15, 2024

Conversation

kazutakahirata
Copy link
Contributor

With this patch, sizeof(ContextNode) goes down from 144 to 128.

Note that SmallVector<T, 0> uses uint32_t for its capacity and size
fields.

I could change other instances of std::vector to SmallVector<T, 0>,
but that would require updates to many places, so I am leaving them
alone for now.

With this patch, sizeof(ContextNode) goes down from 144 to 128.

Note that SmallVector<T, 0> uses uint32_t for its capacity and size
fields.

I could change other instances of std::vector to SmallVector<T, 0>,
but that would require updates to many places, so I am leaving them
alone for now.
@llvmbot
Copy link
Member

llvmbot commented Nov 14, 2024

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

Changes

With this patch, sizeof(ContextNode) goes down from 144 to 128.

Note that SmallVector<T, 0> uses uint32_t for its capacity and size
fields.

I could change other instances of std::vector to SmallVector<T, 0>,
but that would require updates to many places, so I am leaving them
alone for now.


Full diff: https://github.com/llvm/llvm-project/pull/116271.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp (+5-5)
diff --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
index 353dc00c9928e1..a37e888cc04bc7 100644
--- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
+++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
@@ -247,6 +247,10 @@ class CallsiteContextGraph {
     // recursion.
     bool Recursive = false;
 
+    // This will be formed by ORing together the AllocationType enum values
+    // for contexts including this node.
+    uint8_t AllocTypes = 0;
+
     // The corresponding allocation or interior call. This is the primary call
     // for which we have created this node.
     CallInfo Call;
@@ -255,7 +259,7 @@ class CallsiteContextGraph {
     // through cloning. I.e. located in the same function and have the same
     // (possibly pruned) stack ids. They will be updated the same way as the
     // primary call when assigning to function clones.
-    std::vector<CallInfo> MatchingCalls;
+    SmallVector<CallInfo, 0> MatchingCalls;
 
     // For alloc nodes this is a unique id assigned when constructed, and for
     // callsite stack nodes it is the original stack id when the node is
@@ -266,10 +270,6 @@ class CallsiteContextGraph {
     // clones.
     uint64_t OrigStackOrAllocId = 0;
 
-    // This will be formed by ORing together the AllocationType enum values
-    // for contexts including this node.
-    uint8_t AllocTypes = 0;
-
     // Edges to all callees in the profiled call stacks.
     // TODO: Should this be a map (from Callee node) for more efficient lookup?
     std::vector<std::shared_ptr<ContextEdge>> CalleeEdges;

Copy link
Contributor

@teresajohnson teresajohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@kazutakahirata kazutakahirata merged commit 17bc738 into llvm:main Nov 15, 2024
8 checks passed
@kazutakahirata kazutakahirata deleted the memprof_ContextNode branch November 15, 2024 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants