tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit a0afdea225a83ec43c47652b676c5d2f9dce6f88
parent 0d7b27e210ff174fcc00a84321962a123e184472
Author: agoloman <agoloman@mozilla.com>
Date:   Tue,  7 Oct 2025 21:38:08 +0300

Revert "Bug 1988716 - Part 3: Make numerous memory probes labeled with their process. r=mccr8,toolkit-telemetry-reviewers" for causing xpcshell failures @test_TelemetrySession.js.

This reverts commit 45faaf0ca3708954443548a1866904b2618a5e78.

Revert "Bug 1988716 - Part 2: Add ProcessGet() function to labeled metrics. r=chutten,toolkit-telemetry-reviewers"

This reverts commit 0ec5b7dd75f1108e641c3af22ec24b7092a71148.

Revert "Bug 1988716 - Part 1: Make inference process distinguishable in our power usage data. r=florian,chutten,toolkit-telemetry-reviewers"

This reverts commit c6438c7d4aac99d18885069897dc259186aa1bef.

Diffstat:
Mtoolkit/components/glean/bindings/private/Labeled.cpp | 28----------------------------
Mtoolkit/components/glean/bindings/private/Labeled.h | 529+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
Mtoolkit/components/glean/ipc/FOGIPC.cpp | 12------------
Mtoolkit/components/glean/tests/gtest/TestFog.cpp | 9---------
Mtoolkit/components/processtools/metrics.yaml | 4----
Mtoolkit/components/telemetry/Histograms.json | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mtoolkit/components/telemetry/histogram-allowlists.json | 2++
Mxpcom/base/MemoryTelemetry.cpp | 10++++------
Mxpcom/metrics.yaml | 20++++++++++++--------
9 files changed, 481 insertions(+), 187 deletions(-)

diff --git a/toolkit/components/glean/bindings/private/Labeled.cpp b/toolkit/components/glean/bindings/private/Labeled.cpp @@ -12,9 +12,6 @@ #include "mozilla/glean/bindings/MetricTypes.h" #include "mozilla/glean/bindings/ScalarGIFFTMap.h" #include "nsString.h" -#include "nsXULAppAPI.h" -#include "mozilla/dom/ContentChild.h" -#include "mozilla/dom/RemoteType.h" namespace mozilla::glean { @@ -55,29 +52,4 @@ void GleanLabeled::GetSupportedNames(nsTArray<nsString>& aNames) { // We really don't know, so don't do anything. } -namespace impl { - -// Helper function to get the current process type string for telemetry labeling -nsCString GetProcessTypeForTelemetry() { - nsCString processType(XRE_GetProcessTypeString()); - - // For content processes, check the specific remote type - if (processType.EqualsLiteral("tab")) { - auto* cc = mozilla::dom::ContentChild::GetSingleton(); - if (cc) { - const nsACString& remoteType = cc->GetRemoteType(); - if (remoteType == EXTENSION_REMOTE_TYPE) { - processType.AssignLiteral("extension"); - } else if (remoteType == INFERENCE_REMOTE_TYPE) { - processType.AssignLiteral("inference"); - } - // Otherwise keep "tab" for regular content processes - } - } - - return processType; -} - -} // namespace impl - } // namespace mozilla::glean diff --git a/toolkit/components/glean/bindings/private/Labeled.h b/toolkit/components/glean/bindings/private/Labeled.h @@ -28,8 +28,39 @@ namespace mozilla::glean { namespace impl { -// Helper function to get the current process type string for telemetry labeling -nsCString GetProcessTypeForTelemetry(); +template <typename T, typename E> +class Labeled { + public: + constexpr explicit Labeled(uint32_t id) : mId(id) {} + + /** + * Gets a specific metric for a given label. + * + * If a set of acceptable labels were specified in the `metrics.yaml` file, + * and the given label is not in the set, it will be recorded under the + * special `OTHER_LABEL` label. + * + * If a set of acceptable labels was not specified in the `metrics.yaml` file, + * only the first 16 unique labels will be used. + * After that, any additional labels will be recorded under the special + * `OTHER_LABEL` label. + * + * @param aLabel - a snake_case string under 30 characters in length, + * otherwise the metric will be recorded under the special + * `OTHER_LABEL` label and an error will be recorded. + */ + T Get(const nsACString& aLabel) const; + + /** + * Gets a specific metric for a given label, using the label's enum variant. + * + * @param aLabel - a variant of this label's label enum. + */ + T EnumGet(E aLabel) const; + + private: + const uint32_t mId; +}; static inline void UpdateLabeledMirror(Telemetry::ScalarID aMirrorId, uint32_t aSubmetricId, @@ -51,114 +82,333 @@ static inline void UpdateLabeledDistributionMirror( }); } -template <typename T> -inline uint32_t fog_labeled_get(uint32_t aId, const nsACString* aLabel); -template <typename T> -inline uint32_t fog_labeled_enum_get(uint32_t aId, uint16_t aLabel); - -#define FOG_LABEL_TYPE_MAP(type, name) \ - template <> \ - inline uint32_t fog_labeled_get<type>(uint32_t aId, \ - const nsACString* aLabel) { \ - return fog_labeled_##name##_get(aId, aLabel); \ - } \ - template <> \ - inline uint32_t fog_labeled_enum_get<type>(uint32_t aId, uint16_t aLabel) { \ - return fog_labeled_##name##_enum_get(aId, aLabel); \ - } - -FOG_LABEL_TYPE_MAP(BooleanMetric, boolean) -FOG_LABEL_TYPE_MAP(QuantityMetric, quantity) -FOG_LABEL_TYPE_MAP(StringMetric, string) -FOG_LABEL_TYPE_MAP(CounterMetric<CounterType::eBaseOrLabeled>, counter) -FOG_LABEL_TYPE_MAP(CustomDistributionMetric, custom_distribution) -FOG_LABEL_TYPE_MAP(MemoryDistributionMetric, memory_distribution) -FOG_LABEL_TYPE_MAP(TimingDistributionMetric, timing_distribution) +template <typename E> +class Labeled<BooleanMetric, E> { + public: + constexpr explicit Labeled(uint32_t id) : mId(id) {} -template <typename T, typename E> -class Labeled { + BooleanMetric Get(const nsACString& aLabel) const { + auto submetricId = fog_labeled_boolean_get(mId, &aLabel); + // If this labeled metric is mirrored, we need to map the submetric id back + // to the label string and mirrored scalar so we can mirror its operations. + auto mirrorId = ScalarIdForMetric(mId); + if (mirrorId) { + UpdateLabeledMirror(mirrorId.extract(), submetricId, aLabel); + } + return BooleanMetric(submetricId); + } + + BooleanMetric EnumGet(E aLabel) const { + auto submetricId = + fog_labeled_boolean_enum_get(mId, static_cast<uint16_t>(aLabel)); + auto mirrorId = ScalarIdForMetric(mId); + if (mirrorId) { + // Telemetry's keyed scalars operate on (16-bit) strings, + // so we're going to need the string for this enum. + nsCString label; + fog_labeled_enum_to_str(mId, static_cast<uint16_t>(aLabel), &label); + UpdateLabeledMirror(mirrorId.extract(), submetricId, label); + } + return BooleanMetric(submetricId); + } + + private: + const uint32_t mId; +}; + +template <typename E> +class Labeled<CounterMetric<CounterType::eBaseOrLabeled>, E> { public: constexpr explicit Labeled(uint32_t id) : mId(id) {} - /** - * Gets a specific metric for a given label. - * - * If a set of acceptable labels were specified in the `metrics.yaml` file, - * and the given label is not in the set, it will be recorded under the - * special `OTHER_LABEL` label. - * - * If a set of acceptable labels was not specified in the `metrics.yaml` file, - * only the first 16 unique labels will be used. - * After that, any additional labels will be recorded under the special - * `OTHER_LABEL` label. - * - * @param aLabel - a snake_case string under 30 characters in length, - * otherwise the metric will be recorded under the special - * `OTHER_LABEL` label and an error will be recorded. - */ - T Get(const nsACString& aLabel) const { - uint32_t submetricId = fog_labeled_get<T>(mId, &aLabel); + CounterMetric<CounterType::eBaseOrLabeled> Get( + const nsACString& aLabel) const { + auto submetricId = fog_labeled_counter_get(mId, &aLabel); + // If this labeled metric is mirrored, we need to map the submetric id back + // to the label string and mirrored scalar so we can mirror its operations. + auto mirrorId = ScalarIdForMetric(mId); + if (mirrorId) { + UpdateLabeledMirror(mirrorId.extract(), submetricId, aLabel); + } else if (auto mirrorHgramId = HistogramIdForMetric(mId)) { + UpdateLabeledDistributionMirror(mirrorHgramId.extract(), submetricId, + aLabel); + } + return CounterMetric<CounterType::eBaseOrLabeled>(submetricId); + } - Maybe<ScalarID> mirrorId; - if constexpr (MayBeScalarMirror()) { - mirrorId = ScalarIdForMetric(mId); - if (mirrorId) { - UpdateLabeledMirror(mirrorId.extract(), submetricId, aLabel); - } + CounterMetric<CounterType::eBaseOrLabeled> EnumGet(E aLabel) const { + auto submetricId = + fog_labeled_counter_enum_get(mId, static_cast<uint16_t>(aLabel)); + auto mirrorId = ScalarIdForMetric(mId); + if (mirrorId) { + // Telemetry's keyed scalars operate on (16-bit) strings, + // so we're going to need the string for this enum. + nsCString label; + fog_labeled_enum_to_str(mId, static_cast<uint16_t>(aLabel), &label); + UpdateLabeledMirror(mirrorId.extract(), submetricId, label); + } else if (auto mirrorHgramId = HistogramIdForMetric(mId)) { + nsCString label; + fog_labeled_enum_to_str(mId, static_cast<uint16_t>(aLabel), &label); + UpdateLabeledDistributionMirror(mirrorHgramId.extract(), submetricId, + label); } - if constexpr (MayBeDistributionMirror()) { - if (!mirrorId) { - if (Maybe<HistogramID> mirrorHgramId = HistogramIdForMetric(mId)) { - UpdateLabeledDistributionMirror(mirrorHgramId.extract(), submetricId, - aLabel); - } - } + return CounterMetric<CounterType::eBaseOrLabeled>(submetricId); + } + + private: + const uint32_t mId; +}; + +template <typename E> +class Labeled<CustomDistributionMetric, E> { + public: + constexpr explicit Labeled(uint32_t id) : mId(id) {} + + CustomDistributionMetric Get(const nsACString& aLabel) const { + auto submetricId = fog_labeled_custom_distribution_get(mId, &aLabel); + // If this labeled metric is mirrored, we need to map the submetric id back + // to the label string and mirrored hgram so we can mirror its operations. + auto mirrorId = HistogramIdForMetric(mId); + if (mirrorId) { + UpdateLabeledDistributionMirror(mirrorId.extract(), submetricId, aLabel); } - return T(submetricId); + return CustomDistributionMetric(submetricId); } - /** - * Gets a specific metric for a given label, using the label's enum variant. - * - * @param aLabel - a variant of this label's label enum. - */ - template <typename U = T> - std::enable_if_t<!std::is_same_v<U, DynamicLabel>, T> EnumGet( - E aLabel) const { - uint32_t submetricId = - fog_labeled_enum_get<T>(mId, static_cast<uint16_t>(aLabel)); - - Maybe<ScalarID> mirrorId; - if constexpr (MayBeScalarMirror()) { - mirrorId = ScalarIdForMetric(mId); - if (mirrorId) { - // Telemetry's keyed scalars operate on (16-bit) strings, - // so we're going to need the string for this enum. - nsCString label; - fog_labeled_enum_to_str(mId, static_cast<uint16_t>(aLabel), &label); - UpdateLabeledMirror(mirrorId.extract(), submetricId, label); - } - } - if constexpr (MayBeDistributionMirror()) { - if (!mirrorId) { - if (Maybe<HistogramID> mirrorHgramId = HistogramIdForMetric(mId)) { - nsCString label; - fog_labeled_enum_to_str(mId, static_cast<uint16_t>(aLabel), &label); - UpdateLabeledDistributionMirror(mirrorHgramId.extract(), submetricId, - label); - } - } - } - return T(submetricId); - } - - // This is a workaround only needed in a rare case, ensure it's only compiled - // there. - template <typename U = T, typename V = E> - std::enable_if_t<std::is_same_v<U, TimingDistributionMetric> && - std::is_same_v<V, DynamicLabel>, - T> - MaybeTruncateAndGet(const nsACString& aLabel) const { + CustomDistributionMetric EnumGet(E aLabel) const { + auto submetricId = fog_labeled_custom_distribution_enum_get( + mId, static_cast<uint16_t>(aLabel)); + auto mirrorId = HistogramIdForMetric(mId); + if (mirrorId) { + // Telemetry's keyed histograms operate on strings, + // so we're going to need to store the string for this enum. + nsCString label; + fog_labeled_enum_to_str(mId, static_cast<uint16_t>(aLabel), &label); + UpdateLabeledDistributionMirror(mirrorId.extract(), submetricId, label); + } + return CustomDistributionMetric(submetricId); + } + + private: + const uint32_t mId; +}; + +template <typename E> +class Labeled<MemoryDistributionMetric, E> { + public: + constexpr explicit Labeled(uint32_t id) : mId(id) {} + + MemoryDistributionMetric Get(const nsACString& aLabel) const { + auto submetricId = fog_labeled_memory_distribution_get(mId, &aLabel); + // If this labeled metric is mirrored, we need to map the submetric id back + // to the label string and mirrored hgram so we can mirror its operations. + auto mirrorId = HistogramIdForMetric(mId); + if (mirrorId) { + UpdateLabeledDistributionMirror(mirrorId.extract(), submetricId, aLabel); + } + return MemoryDistributionMetric(submetricId); + } + + MemoryDistributionMetric EnumGet(E aLabel) const { + auto submetricId = fog_labeled_memory_distribution_enum_get( + mId, static_cast<uint16_t>(aLabel)); + auto mirrorId = HistogramIdForMetric(mId); + if (mirrorId) { + // Telemetry's keyed histograms operate on strings, + // so we're going to need to store the string for this enum. + nsCString label; + fog_labeled_enum_to_str(mId, static_cast<uint16_t>(aLabel), &label); + UpdateLabeledDistributionMirror(mirrorId.extract(), submetricId, label); + } + return MemoryDistributionMetric(submetricId); + } + + private: + const uint32_t mId; +}; + +template <typename E> +class Labeled<QuantityMetric, E> { + public: + constexpr explicit Labeled(uint32_t id) : mId(id) {} + + QuantityMetric Get(const nsACString& aLabel) const { + auto submetricId = fog_labeled_quantity_get(mId, &aLabel); + // If this labeled metric is mirrored, we need to map the submetric id back + // to the label string and mirrored scalar so we can mirror its operations. + auto mirrorId = ScalarIdForMetric(mId); + if (mirrorId) { + UpdateLabeledMirror(mirrorId.extract(), submetricId, aLabel); + } + return QuantityMetric(submetricId); + } + + QuantityMetric EnumGet(E aLabel) const { + auto submetricId = + fog_labeled_quantity_enum_get(mId, static_cast<uint16_t>(aLabel)); + auto mirrorId = ScalarIdForMetric(mId); + if (mirrorId) { + // Telemetry's keyed scalars operate on (16-bit) strings, + // so we're going to need the string for this enum. + nsCString label; + fog_labeled_enum_to_str(mId, static_cast<uint16_t>(aLabel), &label); + UpdateLabeledMirror(mirrorId.extract(), submetricId, label); + } + return QuantityMetric(submetricId); + } + + private: + const uint32_t mId; +}; + +template <typename E> +class Labeled<StringMetric, E> { + public: + constexpr explicit Labeled(uint32_t id) : mId(id) {} + + StringMetric Get(const nsACString& aLabel) const { + auto submetricId = fog_labeled_string_get(mId, &aLabel); + // Why no GIFFT map here? + // Labeled Strings can't be mirrored. Telemetry has no compatible probe. + return StringMetric(submetricId); + } + + StringMetric EnumGet(E aLabel) const { + auto submetricId = + fog_labeled_string_enum_get(mId, static_cast<uint16_t>(aLabel)); + // Why no GIFFT map here? + // Labeled Strings can't be mirrored. Telemetry has no compatible probe. + return StringMetric(submetricId); + } + + private: + const uint32_t mId; +}; + +template <typename E> +class Labeled<TimingDistributionMetric, E> { + public: + constexpr explicit Labeled(uint32_t id) : mId(id) {} + + TimingDistributionMetric Get(const nsACString& aLabel) const { + auto submetricId = fog_labeled_timing_distribution_get(mId, &aLabel); + // If this labeled metric is mirrored, we need to map the submetric id back + // to the label string and mirrored hgram so we can mirror its operations. + auto mirrorId = HistogramIdForMetric(mId); + if (mirrorId) { + UpdateLabeledDistributionMirror(mirrorId.extract(), submetricId, aLabel); + } + return TimingDistributionMetric(submetricId); + } + + TimingDistributionMetric EnumGet(E aLabel) const { + auto submetricId = fog_labeled_timing_distribution_enum_get( + mId, static_cast<uint16_t>(aLabel)); + auto mirrorId = HistogramIdForMetric(mId); + if (mirrorId) { + // Telemetry's keyed histograms operate on strings, + // so we're going to need to store the string for this enum. + nsCString label; + fog_labeled_enum_to_str(mId, static_cast<uint16_t>(aLabel), &label); + UpdateLabeledDistributionMirror(mirrorId.extract(), submetricId, label); + } + return TimingDistributionMetric(submetricId); + } + + private: + const uint32_t mId; +}; + +template <> +class Labeled<BooleanMetric, DynamicLabel> { + public: + constexpr explicit Labeled(uint32_t id) : mId(id) {} + + BooleanMetric Get(const nsACString& aLabel) const { + auto submetricId = fog_labeled_boolean_get(mId, &aLabel); + // If this labeled metric is mirrored, we need to map the submetric id back + // to the label string and mirrored scalar so we can mirror its operations. + auto mirrorId = ScalarIdForMetric(mId); + if (mirrorId) { + UpdateLabeledMirror(mirrorId.extract(), submetricId, aLabel); + } + return BooleanMetric(submetricId); + } + + BooleanMetric EnumGet(DynamicLabel aLabel) const = delete; + + private: + const uint32_t mId; +}; + +template <> +class Labeled<CounterMetric<CounterType::eBaseOrLabeled>, DynamicLabel> { + public: + constexpr explicit Labeled(uint32_t id) : mId(id) {} + + CounterMetric<CounterType::eBaseOrLabeled> Get( + const nsACString& aLabel) const { + auto submetricId = fog_labeled_counter_get(mId, &aLabel); + // If this labeled metric is mirrored, we need to map the submetric id back + // to the label string and mirrored scalar so we can mirror its operations. + auto mirrorId = ScalarIdForMetric(mId); + if (mirrorId) { + UpdateLabeledMirror(mirrorId.extract(), submetricId, aLabel); + } else if (auto mirrorHgramId = HistogramIdForMetric(mId)) { + UpdateLabeledDistributionMirror(mirrorHgramId.extract(), submetricId, + aLabel); + } + return CounterMetric<CounterType::eBaseOrLabeled>(submetricId); + } + + CounterMetric<CounterType::eBaseOrLabeled> EnumGet( + DynamicLabel aLabel) const = delete; + + private: + const uint32_t mId; +}; + +template <> +class Labeled<CustomDistributionMetric, DynamicLabel> { + public: + constexpr explicit Labeled(uint32_t id) : mId(id) {} + + CustomDistributionMetric Get(const nsACString& aLabel) const { + auto submetricId = fog_labeled_custom_distribution_get(mId, &aLabel); + // If this labeled metric is mirrored, we need to map the submetric id back + // to the label string and mirrored hgram so we can mirror its operations. + auto mirrorId = HistogramIdForMetric(mId); + if (mirrorId) { + UpdateLabeledDistributionMirror(mirrorId.extract(), submetricId, aLabel); + } + return CustomDistributionMetric(submetricId); + } + + CustomDistributionMetric EnumGet(DynamicLabel aLabel) const = delete; + + private: + const uint32_t mId; +}; + +template <> +class Labeled<TimingDistributionMetric, DynamicLabel> { + public: + constexpr explicit Labeled(uint32_t id) : mId(id) {} + + TimingDistributionMetric Get(const nsACString& aLabel) const { + auto submetricId = fog_labeled_memory_distribution_get(mId, &aLabel); + // If this labeled metric is mirrored, we need to map the submetric id back + // to the label string and mirrored hgram so we can mirror its operations. + auto mirrorId = HistogramIdForMetric(mId); + if (mirrorId) { + UpdateLabeledDistributionMirror(mirrorId.extract(), submetricId, aLabel); + } + return TimingDistributionMetric(submetricId); + } + + TimingDistributionMetric EnumGet(DynamicLabel aLabel) const = delete; + + TimingDistributionMetric MaybeTruncateAndGet(const nsACString& aLabel) const { // bug 1959765 is for incorporating this behaviour into the SDK. if (aLabel.Length() < 112) { return Get(aLabel); @@ -169,31 +419,70 @@ class Labeled { return Get(truncated); } - /** - * Gets a specific metric for the current process type. - * - * Automatically determines the process type and returns the appropriate - * labeled metric instance. For content processes, distinguishes between - * regular "tab" processes, "inference" processes, and "extension" processes. - */ - T ProcessGet() const { return Get(GetProcessTypeForTelemetry()); } + private: + const uint32_t mId; +}; - protected: - uint32_t mId; +template <> +class Labeled<QuantityMetric, DynamicLabel> { + public: + constexpr explicit Labeled(uint32_t id) : mId(id) {} + + QuantityMetric Get(const nsACString& aLabel) const { + auto submetricId = fog_labeled_quantity_get(mId, &aLabel); + // If this labeled metric is mirrored, we need to map the submetric id back + // to the label string and mirrored scalar so we can mirror its operations. + auto mirrorId = ScalarIdForMetric(mId); + if (mirrorId) { + UpdateLabeledMirror(mirrorId.extract(), submetricId, aLabel); + } + return QuantityMetric(submetricId); + } + + QuantityMetric EnumGet(DynamicLabel aLabel) const = delete; private: - static constexpr bool MayBeScalarMirror() { - return std::is_same_v<T, BooleanMetric> || - std::is_same_v<T, CounterMetric<CounterType::eBaseOrLabeled>> || - std::is_same_v<T, QuantityMetric>; + const uint32_t mId; +}; + +template <> +class Labeled<StringMetric, DynamicLabel> { + public: + constexpr explicit Labeled(uint32_t id) : mId(id) {} + + StringMetric Get(const nsACString& aLabel) const { + auto submetricId = fog_labeled_string_get(mId, &aLabel); + // Why no GIFFT map here? + // Labeled Strings can't be mirrored. Telemetry has no compatible probe. + return StringMetric(submetricId); } - static constexpr bool MayBeDistributionMirror() { - return std::is_same_v<T, CounterMetric<CounterType::eBaseOrLabeled>> || - std::is_same_v<T, CustomDistributionMetric> || - std::is_same_v<T, MemoryDistributionMetric> || - std::is_same_v<T, TimingDistributionMetric>; + StringMetric EnumGet(DynamicLabel aLabel) const = delete; + + private: + const uint32_t mId; +}; + +template <> +class Labeled<MemoryDistributionMetric, DynamicLabel> { + public: + constexpr explicit Labeled(uint32_t id) : mId(id) {} + + MemoryDistributionMetric Get(const nsACString& aLabel) const { + auto submetricId = fog_labeled_timing_distribution_get(mId, &aLabel); + // If this labeled metric is mirrored, we need to map the submetric id back + // to the label string and mirrored hgram so we can mirror its operations. + auto mirrorId = HistogramIdForMetric(mId); + if (mirrorId) { + UpdateLabeledDistributionMirror(mirrorId.extract(), submetricId, aLabel); + } + return MemoryDistributionMetric(submetricId); } + + MemoryDistributionMetric EnumGet(DynamicLabel aLabel) const = delete; + + private: + const uint32_t mId; }; } // namespace impl diff --git a/toolkit/components/glean/ipc/FOGIPC.cpp b/toolkit/components/glean/ipc/FOGIPC.cpp @@ -114,7 +114,6 @@ enum ProcessType { eContentForeground, eContentBackground, eGpuProcess, - eInferenceProcess, eUnknown, }; @@ -188,10 +187,6 @@ void RecordThreadCpuUse(const nsACString& aThreadName, uint64_t aCpuTimeMs, power_cpu_ms_per_thread::gpu_process.Get(threadName) .Add(int32_t(aCpuTimeMs)); break; - case eInferenceProcess: - power_cpu_ms_per_thread::inference_process.Get(threadName) - .Add(int32_t(aCpuTimeMs)); - break; case eUnknown: // Nothing to do. break; @@ -221,10 +216,6 @@ void RecordThreadCpuUse(const nsACString& aThreadName, uint64_t aCpuTimeMs, power_wakeups_per_thread::gpu_process.Get(threadName) .Add(int32_t(aWakeCount)); break; - case eInferenceProcess: - power_wakeups_per_thread::inference_process.Get(threadName) - .Add(int32_t(aWakeCount)); - break; case eUnknown: // Nothing to do. break; @@ -357,9 +348,6 @@ void RecordPowerMetrics() { MOZ_ASSERT_UNREACHABLE("Unsuppored process type for cpu time"); break; } - } else if (type == INFERENCE_REMOTE_TYPE) { - type.AssignLiteral("inference"); - gThisProcessType = ProcessType::eInferenceProcess; } GetTrackerType(trackerType); } else { diff --git a/toolkit/components/glean/tests/gtest/TestFog.cpp b/toolkit/components/glean/tests/gtest/TestFog.cpp @@ -437,15 +437,6 @@ TEST_F(FOGFixture, TestLabeledCounterWithLabelsWorks) { .ref()); } -TEST_F(FOGFixture, TestLabeledCounterProcessGetWorks) { - test_only::mabels_kitchen_counters.ProcessGet().Add(5); - - ASSERT_EQ(5, test_only::mabels_kitchen_counters.Get("default"_ns) - .TestGetValue() - .unwrap() - .ref()); -} - TEST_F(FOGFixture, TestLabeledStringWorks) { ASSERT_EQ(mozilla::Nothing(), test_only::mabels_balloon_strings.Get("twine"_ns) diff --git a/toolkit/components/processtools/metrics.yaml b/toolkit/components/processtools/metrics.yaml @@ -57,7 +57,6 @@ power: - gpu - gmplugin - utility - - inference telemetry_mirror: POWER_CPU_TIME_PER_PROCESS_TYPE_MS cpu_time_per_tracker_type_ms: @@ -271,7 +270,6 @@ power.wakeups_per_thread: - mozstorage - mtransport - netlink_monitor - - onnx_worker - pacerthread - permission - playeventsound @@ -321,7 +319,6 @@ power.wakeups_per_thread: content_foreground: *per_thread_wakeups content_background: *per_thread_wakeups gpu_process: *per_thread_wakeups - inference_process: *per_thread_wakeups power.cpu_ms_per_thread: parent_active: &per_thread_cpu_ms @@ -345,7 +342,6 @@ power.cpu_ms_per_thread: content_foreground: *per_thread_cpu_ms content_background: *per_thread_cpu_ms gpu_process: *per_thread_cpu_ms - inference_process: *per_thread_cpu_ms power.battery: percentage_when_user_active: diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json @@ -721,6 +721,35 @@ "n_buckets": 100, "description": "GPU process initialization (excluding XPCOM and fork time) time in milliseconds" }, + "MEMORY_RESIDENT_FAST": { + "record_in_processes": ["main", "content"], + "products": ["firefox", "fennec"], + "alert_emails": ["memshrink-telemetry-alerts@mozilla.com"], + "expires_in_version": "never", + "kind": "exponential", + "low": 32768, + "high": 16777216, + "n_buckets": 100, + "bug_numbers": [1226196, 1870550], + "description": "Resident memory size (KB)", + "releaseChannelCollection": "opt-out" + }, + "MEMORY_RESIDENT_PEAK": { + "record_in_processes": ["main", "content"], + "products": ["firefox"], + "alert_emails": [ + "memshrink-telemetry-alerts@mozilla.com", + "amccreight@mozilla.com" + ], + "expires_in_version": "never", + "kind": "exponential", + "low": 32768, + "high": 16777216, + "n_buckets": 100, + "bug_numbers": [1551648, 1870550], + "description": "Peak resident memory size (KB)", + "releaseChannelCollection": "opt-out" + }, "MEMORY_TOTAL": { "record_in_processes": ["main"], "products": ["firefox", "fennec", "thunderbird"], @@ -749,6 +778,19 @@ "n_buckets": 100, "description": "Absolute difference of each content process' USS and the mean of USS's, normalized by the mean, in percentage. It will be recorded with the rest of the memory probes when gatherMemory is called, if at least 2 content processes are alive. Example: in case of 4 content processes with USS's: 1G, 500MB, 1G, 1.5G, the reported numbers will be: 0, 50, 0, 50. Which indicates that 2 processes used 50% more or 50% less memory than the avarage and 2 used exactly as much as the avarage." }, + "MEMORY_UNIQUE": { + "record_in_processes": ["main", "content"], + "products": ["firefox", "fennec"], + "alert_emails": ["memshrink-telemetry-alerts@mozilla.com"], + "bug_numbers": [1198209, 1870550], + "expires_in_version": "never", + "kind": "exponential", + "low": 32768, + "high": 16777216, + "n_buckets": 100, + "description": "Unique Set Size (KB)", + "releaseChannelCollection": "opt-out" + }, "MEMORY_UNIQUE_CONTENT_STARTUP": { "record_in_processes": ["content"], "products": ["firefox", "fennec"], @@ -846,6 +888,18 @@ "n_buckets": 50, "description": "Total JavaScript realms used for web pages." }, + "MEMORY_JS_GC_HEAP": { + "record_in_processes": ["main", "content"], + "products": ["firefox", "fennec", "thunderbird"], + "alert_emails": ["memshrink-telemetry-alerts@mozilla.com"], + "expires_in_version": "never", + "releaseChannelCollection": "opt-out", + "kind": "exponential", + "low": 1024, + "high": 16777216, + "n_buckets": 200, + "description": "Memory used by the garbage-collected JavaScript heap (KB)" + }, "MEMORY_STORAGE_SQLITE": { "record_in_processes": ["main", "content"], "products": ["firefox", "fennec"], diff --git a/toolkit/components/telemetry/histogram-allowlists.json b/toolkit/components/telemetry/histogram-allowlists.json @@ -285,6 +285,7 @@ "MEMORY_IMAGES_CONTENT_USED_UNCOMPRESSED", "MEMORY_JS_COMPARTMENTS_SYSTEM", "MEMORY_JS_COMPARTMENTS_USER", + "MEMORY_JS_GC_HEAP", "MEMORY_STORAGE_SQLITE", "MEMORY_VSIZE", "MEMORY_VSIZE_MAX_CONTIGUOUS", @@ -440,6 +441,7 @@ "XMLHTTPREQUEST_ASYNC_OR_SYNC" ], "n_buckets": [ + "MEMORY_JS_GC_HEAP", "MEMORY_HEAP_ALLOCATED", "HTTP_REQUEST_PER_PAGE_FROM_CACHE", "SSL_TIME_UNTIL_READY", diff --git a/xpcom/base/MemoryTelemetry.cpp b/xpcom/base/MemoryTelemetry.cpp @@ -267,8 +267,6 @@ nsresult MemoryTelemetry::GatherReports( RECORD_OUTER(metric, glean::memory::id.AccumulateSingleSample(amt);) #define RECORD_BYTES(id, metric) \ RECORD_OUTER(metric, glean::memory::id.Accumulate(amt / 1024);) -#define RECORD_BYTES_PER_PROCESS(id, metric) \ - RECORD_OUTER(metric, glean::memory::id.ProcessGet().Accumulate(amt / 1024);) #define RECORD_PERCENTAGE(id, metric) \ RECORD_OUTER(metric, glean::memory::id.AccumulateSingleSample(amt / 100);) #define RECORD_COUNT_CUMULATIVE(id, metric) \ @@ -315,7 +313,7 @@ nsresult MemoryTelemetry::GatherReports( // Collect cheap or main-thread only metrics synchronously, on the main // thread. - RECORD_BYTES_PER_PROCESS(js_gc_heap, JSMainRuntimeGCHeap); + RECORD_BYTES(js_gc_heap, JSMainRuntimeGCHeap); RECORD_COUNT(js_compartments_system, JSMainRuntimeCompartmentsSystem); RECORD_COUNT(js_compartments_user, JSMainRuntimeCompartmentsUser); RECORD_COUNT(js_realms_system, JSMainRuntimeRealmsSystem); @@ -360,12 +358,12 @@ nsresult MemoryTelemetry::GatherReports( #if !defined(HAVE_64BIT_BUILD) || !defined(XP_WIN) RECORD_BYTES(vsize_max_contiguous, VsizeMaxContiguous); #endif - RECORD_BYTES_PER_PROCESS(resident_fast, ResidentFast); - RECORD_BYTES_PER_PROCESS(resident_peak, ResidentPeak); + RECORD_BYTES(resident_fast, ResidentFast); + RECORD_BYTES(resident_peak, ResidentPeak); // Although we can measure unique memory on MacOS we choose not to, because // doing so is too slow for telemetry. #ifndef XP_MACOSX - RECORD_BYTES_PER_PROCESS(unique, ResidentUnique); + RECORD_BYTES(unique, ResidentUnique); #endif if (completionRunnable) { diff --git a/xpcom/metrics.yaml b/xpcom/metrics.yaml @@ -492,9 +492,9 @@ cycle_collector: memory: resident_fast: - type: labeled_memory_distribution + type: memory_distribution description: > - Resident memory size (KB) by process type + Resident memory size (KB) This metric was generated to correspond to the Legacy Telemetry exponential histogram MEMORY_RESIDENT_FAST. @@ -508,11 +508,12 @@ memory: notification_emails: - memshrink-telemetry-alerts@mozilla.com expires: never + telemetry_mirror: MEMORY_RESIDENT_FAST resident_peak: - type: labeled_memory_distribution + type: memory_distribution description: > - Peak resident memory size (KB) by process type + Peak resident memory size (KB) This metric was generated to correspond to the Legacy Telemetry exponential histogram MEMORY_RESIDENT_PEAK. @@ -527,6 +528,7 @@ memory: - memshrink-telemetry-alerts@mozilla.com - amccreight@mozilla.com expires: never + telemetry_mirror: MEMORY_RESIDENT_PEAK total: type: memory_distribution @@ -577,9 +579,9 @@ memory: telemetry_mirror: MEMORY_DISTRIBUTION_AMONG_CONTENT unique: - type: labeled_memory_distribution + type: memory_distribution description: > - Unique Set Size (KB) by process type + Unique Set Size (KB) This metric was generated to correspond to the Legacy Telemetry exponential histogram MEMORY_UNIQUE. @@ -593,6 +595,7 @@ memory: notification_emails: - memshrink-telemetry-alerts@mozilla.com expires: never + telemetry_mirror: MEMORY_UNIQUE vsize: type: memory_distribution @@ -715,9 +718,9 @@ memory: telemetry_mirror: MEMORY_JS_REALMS_USER js_gc_heap: - type: labeled_memory_distribution + type: memory_distribution description: > - Memory used by the garbage-collected JavaScript heap (KB) by process type + Memory used by the garbage-collected JavaScript heap (KB) This metric was generated to correspond to the Legacy Telemetry exponential histogram MEMORY_JS_GC_HEAP. @@ -729,6 +732,7 @@ memory: notification_emails: - memshrink-telemetry-alerts@mozilla.com expires: never + telemetry_mirror: MEMORY_JS_GC_HEAP storage_sqlite: type: memory_distribution