Skip to content

[MemProf][NFC] Hoist size computation out of the loop for v3 #137479

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

Conversation

snehasish
Copy link
Contributor

@snehasish snehasish commented Apr 26, 2025

Similar to the suggestion in #137394. In this case apply it to the current binary format (v3).

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@snehasish snehasish marked this pull request as ready for review April 26, 2025 22:50
@llvmbot llvmbot added the PGO Profile Guided Optimizations label Apr 26, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 26, 2025

@llvm/pr-subscribers-pgo

Author: Snehasish Kumar (snehasish)

Changes

Similar to the suggestion in #137394. In this case apply it to the current binary format (v3).


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

1 Files Affected:

  • (modified) llvm/lib/ProfileData/MemProf.cpp (+2-1)
diff --git a/llvm/lib/ProfileData/MemProf.cpp b/llvm/lib/ProfileData/MemProf.cpp
index 0af08ca51481f..1e956250e5b84 100644
--- a/llvm/lib/ProfileData/MemProf.cpp
+++ b/llvm/lib/ProfileData/MemProf.cpp
@@ -190,12 +190,13 @@ static IndexedMemProfRecord deserializeV3(const MemProfSchema &Schema,
   const uint64_t NumNodes =
       endian::readNext<uint64_t, llvm::endianness::little>(Ptr);
   Record.AllocSites.reserve(NumNodes);
+  const size_t SerializedSize = PortableMemInfoBlock::serializedSize(Schema);
   for (uint64_t I = 0; I < NumNodes; I++) {
     IndexedAllocationInfo Node;
     Node.CSId =
         endian::readNext<LinearCallStackId, llvm::endianness::little>(Ptr);
     Node.Info.deserialize(Schema, Ptr);
-    Ptr += PortableMemInfoBlock::serializedSize(Schema);
+    Ptr += SerializedSize;
     Record.AllocSites.push_back(Node);
   }
 

Copy link
Contributor

@mingmingl-llvm mingmingl-llvm left a comment

Choose a reason for hiding this comment

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

thanks for the change!

Copy link
Contributor Author

snehasish commented Apr 28, 2025

Merge activity

  • Apr 28, 2:14 PM EDT: A user started a stack merge that includes this pull request via Graphite.
  • Apr 28, 2:16 PM EDT: @snehasish merged this pull request with Graphite.

@snehasish snehasish merged commit a61048b into main Apr 28, 2025
13 of 15 checks passed
@snehasish snehasish deleted the users/snehasish/04-26-_memprof_nfc_hoist_size_computation_out_of_the_loop_for_v3 branch April 28, 2025 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PGO Profile Guided Optimizations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants