[PATCH] D50782: [XRay][compiler-rt] Avoid InternalAlloc(...) in Profiling Mode

Eizan Miyamoto via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 16 05:25:33 PDT 2018


eizan added a comment.

I'm trying to understand the memory allocation/deallocation dynamics of this module. It looks like all of the Array<...> objects only have their memory allocation increase because the XRay segmented array doesn't support having its allocation shrink. However, the memory buffers that each cell in ProfileBuffers point to do get deallocated inside serialize(). Is this correct? Why are these buffers special that they should be deallocated rather than kept around for reuse later like all the other memory?



================
Comment at: compiler-rt/lib/xray/xray_profile_collector.cc:64
+
+// These need to be global aligned storage to avoid dynamic memory.
+static typename std::aligned_storage<sizeof(FunctionCallTrie::Allocators)>::type
----------------
Do you mean dynamic memory allocation? Why does alignment affect whether it's done?


================
Comment at: compiler-rt/lib/xray/xray_profile_collector.cc:84
+  auto B = reinterpret_cast<void *>(internal_mmap(
+      NULL, S, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0));
+  if (B == MAP_FAILED) {
----------------
fd argument should be set to -1


================
Comment at: compiler-rt/lib/xray/xray_profile_collector.cc:216
 
-  // Clear out the global ProfileBuffers.
-  for (uptr I = 0; I < ProfileBuffers->Size(); ++I)
----------------
suggest keeping the comments, as this one went away, but the "then repopulate..." stayed.


https://reviews.llvm.org/D50782





More information about the llvm-commits mailing list