[compiler-rt] [llvm] [ctxprof] root autodetection mechanism (PR #133147)
Snehasish Kumar via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 1 21:58:55 PDT 2025
================
@@ -53,5 +54,35 @@ class PerThreadCallsiteTrie {
/// thread, together with the number of samples that included them.
DenseMap<uptr, uint64_t> determineRoots() const;
};
+
+class RootAutoDetector final {
+ static const uint64_t SampleRate = 6113;
+ const unsigned WaitSeconds;
+ pthread_t WorkerThread;
+
+ struct PerThreadSamples {
+ PerThreadSamples(RootAutoDetector &Parent);
+
+ PerThreadCallsiteTrie TrieRoot;
+ SpinMutex M;
+ };
+ SpinMutex AllSamplesMutex;
+ SANITIZER_GUARDED_BY(AllSamplesMutex)
+ Vector<PerThreadSamples *> AllSamples;
+ atomic_uintptr_t &FunctionDataListHead;
+ atomic_uintptr_t &Self;
+ void collectStack();
+
+public:
+ RootAutoDetector(atomic_uintptr_t &FunctionDataListHead,
+ atomic_uintptr_t &Self, unsigned WaitSeconds)
+ : WaitSeconds(WaitSeconds), FunctionDataListHead(FunctionDataListHead),
+ Self(Self) {}
+
+ void sample();
+ void start();
+ void join();
----------------
snehasish wrote:
Add a comment describing the public methods?
https://github.com/llvm/llvm-project/pull/133147
More information about the llvm-commits
mailing list