[compiler-rt] [llvm] [ctxprof] Flat profile collection (PR #130655)

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 12 07:46:38 PDT 2025


================
@@ -113,6 +113,28 @@ struct ContextRoot {
   static_assert(sizeof(Taken) == 1);
 };
 
+// This is allocated and zero-initialized by the compiler, the in-place
+// initialization serves mostly as self-documentation and for testing.
+// The design is influenced by the observation that typically (at least for
+// datacenter binaries, which is the motivating target of this profiler) less
+// than 10% of functions in a binary even appear in a profile (of any kind).
+//
+// 1) We could pre-allocate the flat profile storage in the compiler, just like
+// the flat instrumented profiling does. But that penalizes the static size of
+// the binary for little reason
+//
+// 2) We could do the above but zero-initialize the buffers, and dynamically
+// populate them. This, though, would page-in more memory upfront for the
+// binary's runtime
----------------
mtrofin wrote:

Right - so we don't forget: the `mmap` suggestion would be a way to more efficiently back Arenas, for example.

https://github.com/llvm/llvm-project/pull/130655


More information about the llvm-commits mailing list