summaryrefslogtreecommitdiffstats
path: root/tools/profiler/public
diff options
context:
space:
mode:
Diffstat (limited to 'tools/profiler/public')
-rw-r--r--tools/profiler/public/ProfilerControl.h3
-rw-r--r--tools/profiler/public/ProfilerCounts.h30
-rw-r--r--tools/profiler/public/ProfilerState.h11
3 files changed, 40 insertions, 4 deletions
diff --git a/tools/profiler/public/ProfilerControl.h b/tools/profiler/public/ProfilerControl.h
index ac145fac00..53fec681ce 100644
--- a/tools/profiler/public/ProfilerControl.h
+++ b/tools/profiler/public/ProfilerControl.h
@@ -61,6 +61,9 @@ static constexpr mozilla::PowerOfTwo32 PROFILER_DEFAULT_ENTRIES =
static constexpr mozilla::PowerOfTwo32 PROFILER_DEFAULT_STARTUP_ENTRIES =
mozilla::baseprofiler::BASE_PROFILER_DEFAULT_STARTUP_ENTRIES;
+static constexpr mozilla::PowerOfTwo32 PROFILER_DEFAULT_SIGHANDLE_ENTRIES =
+ mozilla::MakePowerOfTwo32<64 * 1024 * 1024>(); // 64M entries = 512MiB
+
# define PROFILER_DEFAULT_INTERVAL BASE_PROFILER_DEFAULT_INTERVAL
# define PROFILER_MAX_INTERVAL BASE_PROFILER_MAX_INTERVAL
diff --git a/tools/profiler/public/ProfilerCounts.h b/tools/profiler/public/ProfilerCounts.h
index cebca81e2c..bdd2ddef9a 100644
--- a/tools/profiler/public/ProfilerCounts.h
+++ b/tools/profiler/public/ProfilerCounts.h
@@ -20,6 +20,7 @@
# include "mozilla/Assertions.h"
# include "mozilla/Atomics.h"
+# include "mozilla/DataMutex.h"
class BaseProfilerCount;
void profiler_add_sampled_counter(BaseProfilerCount* aCounter);
@@ -188,13 +189,33 @@ class ProfilerCounterTotal final : public BaseProfilerCount {
public:
ProfilerCounterTotal(const char* aLabel, const char* aCategory,
const char* aDescription)
- : BaseProfilerCount(aLabel, &mCounter, &mNumber, aCategory,
- aDescription) {
+ : BaseProfilerCount(aLabel, &mCounter, &mNumber, aCategory, aDescription),
+ mRegistered(false, "ProfilerCounterTotal::mRegistered") {
// Assume we're in libxul
+ Register();
+ }
+
+ virtual ~ProfilerCounterTotal() { Unregister(); }
+
+ void Register() {
+ auto registered = mRegistered.Lock();
+ if (*registered) {
+ return;
+ }
+
+ *registered = true;
profiler_add_sampled_counter(this);
}
- virtual ~ProfilerCounterTotal() { profiler_remove_sampled_counter(this); }
+ void Unregister() {
+ auto registered = mRegistered.Lock();
+ if (!*registered) {
+ return;
+ }
+
+ *registered = false;
+ profiler_remove_sampled_counter(this);
+ }
BaseProfilerCount& operator++() {
Add(1);
@@ -208,6 +229,9 @@ class ProfilerCounterTotal final : public BaseProfilerCount {
ProfilerAtomicSigned mCounter;
ProfilerAtomicUnsigned mNumber;
+ // Using OffTheBooksMutex here because we intentionally leak memory counters
+ // if they are initialized.
+ mozilla::DataMutexBase<bool, mozilla::OffTheBooksMutex> mRegistered;
};
// Defines a counter that is sampled on each profiler tick, with a running
diff --git a/tools/profiler/public/ProfilerState.h b/tools/profiler/public/ProfilerState.h
index 40e1517c91..aad74862b3 100644
--- a/tools/profiler/public/ProfilerState.h
+++ b/tools/profiler/public/ProfilerState.h
@@ -118,7 +118,10 @@
"every CPU core for every profiler sample.") \
\
MACRO(23, "bandwidth", Bandwidth, \
- "Record the network bandwidth used for every profiler sample.")
+ "Record the network bandwidth used for every profiler sample.") \
+ MACRO( \
+ 24, "memory", Memory, \
+ "Track the memory allocations and deallocations per process over time.")
// *** Synchronize with lists in BaseProfilerState.h and geckoProfiler.json ***
struct ProfilerFeature {
@@ -138,6 +141,12 @@ struct ProfilerFeature {
PROFILER_FOR_EACH_FEATURE(DECLARE)
#undef DECLARE
+
+ [[nodiscard]] static constexpr bool ShouldInstallMemoryHooks(
+ uint32_t aFeatures) {
+ return ProfilerFeature::HasMemory(aFeatures) ||
+ ProfilerFeature::HasNativeAllocations(aFeatures);
+ }
};
// clang-format off