From ee86610605ab519dba7696b0da9f3a866e922494 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= <canaltinova@gmail.com>
Date: Tue, 13 Dec 2022 14:19:07 +0000
Subject: [PATCH] Bug 1803751 - Make some marker fields searchable and bump the
 profile version r=julienw

Differential Revision: https://phabricator.services.mozilla.com/D163714
---
 dom/animation/AnimationEventDispatcher.h             |  3 ++-
 dom/events/EventDispatcher.cpp                       |  8 ++++++--
 dom/media/AsyncLogger.h                              |  4 +++-
 dom/performance/Performance.cpp                      |  3 ++-
 modules/libpref/Preferences.cpp                      |  3 ++-
 mozglue/baseprofiler/core/platform.cpp               |  2 +-
 mozglue/baseprofiler/public/BaseProfilerMarkers.h    |  6 ++++--
 tools/profiler/core/MicroGeckoProfiler.cpp           | 12 ++++++++----
 tools/profiler/core/platform.cpp                     |  5 +++--
 tools/profiler/gecko/ProfilerIOInterposeObserver.cpp |  3 +++
 .../tests/xpcshell/test_feature_mainthreadio.js      |  6 ++++++
 xpcom/base/Logging.cpp                               |  7 +++++--
 xpcom/threads/TaskController.cpp                     |  3 ++-
 xpcom/threads/nsThread.cpp                           |  4 +++-
 14 files changed, 50 insertions(+), 19 deletions(-)

diff --git a/dom/animation/AnimationEventDispatcher.h b/dom/animation/AnimationEventDispatcher.h
index e0e5259b07bd8..c591758c8359f 100644
--- a/dom/animation/AnimationEventDispatcher.h
+++ b/dom/animation/AnimationEventDispatcher.h
@@ -58,7 +58,8 @@ struct CSSAnimationMarker {
   static MarkerSchema MarkerTypeDisplay() {
     using MS = MarkerSchema;
     MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable};
-    schema.AddKeyFormat("Name", MS::Format::String);
+    schema.AddKeyFormatSearchable("Name", MS::Format::String,
+                                  MS::Searchable::Searchable);
     schema.AddKeyLabelFormat("properties", "Animated Properties",
                              MS::Format::String);
     schema.AddKeyLabelFormat("oncompositor", "Can Run on Compositor",
diff --git a/dom/events/EventDispatcher.cpp b/dom/events/EventDispatcher.cpp
index ca2ef06c8cc4b..7ec36a97864de 100644
--- a/dom/events/EventDispatcher.cpp
+++ b/dom/events/EventDispatcher.cpp
@@ -1089,10 +1089,14 @@ nsresult EventDispatcher::Dispatch(nsISupports* aTarget,
               schema.SetTooltipLabel("{marker.data.eventType} - DOMEvent");
               schema.SetTableLabel(
                   "{marker.data.eventType} - {marker.data.target}");
-              schema.AddKeyLabelFormat("target", "Event Target",
-                                       MS::Format::String);
+              schema.AddKeyLabelFormatSearchable("target", "Event Target",
+                                                 MS::Format::String,
+                                                 MS::Searchable::Searchable);
               schema.AddKeyLabelFormat("latency", "Latency",
                                        MS::Format::Duration);
+              schema.AddKeyLabelFormatSearchable("eventType", "Event Type",
+                                                 MS::Format::String,
+                                                 MS::Searchable::Searchable);
               return schema;
             }
           };
diff --git a/dom/media/AsyncLogger.h b/dom/media/AsyncLogger.h
index e377910638d1b..adc41013822fc 100644
--- a/dom/media/AsyncLogger.h
+++ b/dom/media/AsyncLogger.h
@@ -217,7 +217,9 @@ class AsyncLogger {
               MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable};
               schema.SetChartLabel("{marker.data.name}");
               schema.SetTableLabel("{marker.name} - {marker.data.name}");
-              schema.AddKeyLabelFormat("name", "Comment", MS::Format::String);
+              schema.AddKeyLabelFormatSearchable("name", "Comment",
+                                                 MS::Format::String,
+                                                 MS::Searchable::Searchable);
               return schema;
             }
           };
diff --git a/dom/performance/Performance.cpp b/dom/performance/Performance.cpp
index e041b5093d0b3..d6a4101502ae8 100644
--- a/dom/performance/Performance.cpp
+++ b/dom/performance/Performance.cpp
@@ -335,7 +335,8 @@ struct UserTimingMarker {
     schema.SetAllLabels("{marker.data.name}");
     schema.AddStaticLabelValue("Marker", "UserTiming");
     schema.AddKeyLabelFormat("entryType", "Entry Type", MS::Format::String);
-    schema.AddKeyLabelFormat("name", "Name", MS::Format::String);
+    schema.AddKeyLabelFormatSearchable("name", "Name", MS::Format::String,
+                                       MS::Searchable::Searchable);
     schema.AddKeyLabelFormat("startMark", "Start Mark", MS::Format::String);
     schema.AddKeyLabelFormat("endMark", "End Mark", MS::Format::String);
     schema.AddStaticLabelValue("Description",
diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp
index 7b4fa2a6adab0..a6cdb89aea755 100644
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -4618,7 +4618,8 @@ struct Internals {
     static MarkerSchema MarkerTypeDisplay() {
       using MS = MarkerSchema;
       MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable};
-      schema.AddKeyLabelFormat("prefName", "Name", MS::Format::String);
+      schema.AddKeyLabelFormatSearchable("prefName", "Name", MS::Format::String,
+                                         MS::Searchable::Searchable);
       schema.AddKeyLabelFormat("prefKind", "Kind", MS::Format::String);
       schema.AddKeyLabelFormat("prefType", "Type", MS::Format::String);
       schema.AddKeyLabelFormat("prefValue", "Value", MS::Format::String);
diff --git a/mozglue/baseprofiler/core/platform.cpp b/mozglue/baseprofiler/core/platform.cpp
index 99d2d11dab783..267589a969364 100644
--- a/mozglue/baseprofiler/core/platform.cpp
+++ b/mozglue/baseprofiler/core/platform.cpp
@@ -1841,7 +1841,7 @@ static void StreamMetaJSCustomObject(PSLockRef aLock,
                                      bool aIsShuttingDown) {
   MOZ_RELEASE_ASSERT(CorePS::Exists() && ActivePS::Exists(aLock));
 
-  aWriter.IntProperty("version", 25);
+  aWriter.IntProperty("version", 26);
 
   // The "startTime" field holds the number of milliseconds since midnight
   // January 1, 1970 GMT. This grotty code computes (Now - (Now -
diff --git a/mozglue/baseprofiler/public/BaseProfilerMarkers.h b/mozglue/baseprofiler/public/BaseProfilerMarkers.h
index 406bf019833ec..5821997e7cbb8 100644
--- a/mozglue/baseprofiler/public/BaseProfilerMarkers.h
+++ b/mozglue/baseprofiler/public/BaseProfilerMarkers.h
@@ -148,7 +148,8 @@ struct TextMarker {
     MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable};
     schema.SetChartLabel("{marker.data.name}");
     schema.SetTableLabel("{marker.name} - {marker.data.name}");
-    schema.AddKeyLabelFormat("name", "Details", MS::Format::String);
+    schema.AddKeyLabelFormatSearchable("name", "Details", MS::Format::String,
+                                       MS::Searchable::Searchable);
     return schema;
   }
 };
@@ -169,7 +170,8 @@ struct Tracing {
     using MS = MarkerSchema;
     MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable,
               MS::Location::TimelineOverview};
-    schema.AddKeyLabelFormat("category", "Type", MS::Format::String);
+    schema.AddKeyLabelFormatSearchable("category", "Type", MS::Format::String,
+                                       MS::Searchable::Searchable);
     return schema;
   }
 };
diff --git a/tools/profiler/core/MicroGeckoProfiler.cpp b/tools/profiler/core/MicroGeckoProfiler.cpp
index a045793485bb9..bedb75574220f 100644
--- a/tools/profiler/core/MicroGeckoProfiler.cpp
+++ b/tools/profiler/core/MicroGeckoProfiler.cpp
@@ -78,10 +78,14 @@ struct TraceMarker {
     schema.SetTableLabel(
         "{marker.name}  {marker.data.name1} {marker.data.val1}  "
         "{marker.data.name2} {marker.data.val2}");
-    schema.AddKeyLabelFormat("name1", "Key 1", MS::Format::String);
-    schema.AddKeyLabelFormat("val1", "Value 1", MS::Format::String);
-    schema.AddKeyLabelFormat("name2", "Key 2", MS::Format::String);
-    schema.AddKeyLabelFormat("val2", "Value 2", MS::Format::String);
+    schema.AddKeyLabelFormatSearchable("name1", "Key 1", MS::Format::String,
+                                       MS::Searchable::Searchable);
+    schema.AddKeyLabelFormatSearchable("val1", "Value 1", MS::Format::String,
+                                       MS::Searchable::Searchable);
+    schema.AddKeyLabelFormatSearchable("name2", "Key 2", MS::Format::String,
+                                       MS::Searchable::Searchable);
+    schema.AddKeyLabelFormatSearchable("val2", "Value 2", MS::Format::String,
+                                       MS::Searchable::Searchable);
     return schema;
   }
 };
diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp
index d411378fcdc44..b080a4b2df4c8 100644
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -2804,7 +2804,7 @@ static void StreamMetaJSCustomObject(
     const PreRecordedMetaInformation& aPreRecordedMetaInformation) {
   MOZ_RELEASE_ASSERT(CorePS::Exists() && ActivePS::Exists(aLock));
 
-  aWriter.IntProperty("version", 25);
+  aWriter.IntProperty("version", 26);
 
   // The "startTime" field holds the number of milliseconds since midnight
   // January 1, 1970 GMT. This grotty code computes (Now - (Now -
@@ -3055,7 +3055,8 @@ struct JavaMarkerWithDetails {
     schema.SetTooltipLabel("{marker.name}");
     schema.SetChartLabel("{marker.data.name}");
     schema.SetTableLabel("{marker.name} - {marker.data.name}");
-    schema.AddKeyLabelFormat("name", "Details", MS::Format::String);
+    schema.AddKeyLabelFormatSearchable("name", "Details", MS::Format::String,
+                                       MS::Searchable::Searchable);
     return schema;
   }
 };
diff --git a/tools/profiler/gecko/ProfilerIOInterposeObserver.cpp b/tools/profiler/gecko/ProfilerIOInterposeObserver.cpp
index cda053d90e9de..d675c87b5dd51 100644
--- a/tools/profiler/gecko/ProfilerIOInterposeObserver.cpp
+++ b/tools/profiler/gecko/ProfilerIOInterposeObserver.cpp
@@ -50,6 +50,9 @@ struct FileIOMarker {
     schema.AddKeyLabelFormatSearchable("filename", "Filename",
                                        MS::Format::FilePath,
                                        MS::Searchable::Searchable);
+    schema.AddKeyLabelFormatSearchable("threadId", "Thread ID",
+                                       MS::Format::String,
+                                       MS::Searchable::Searchable);
     return schema;
   }
 };
diff --git a/tools/profiler/tests/xpcshell/test_feature_mainthreadio.js b/tools/profiler/tests/xpcshell/test_feature_mainthreadio.js
index ad6c11257450c..8ff5c9206dc75 100644
--- a/tools/profiler/tests/xpcshell/test_feature_mainthreadio.js
+++ b/tools/profiler/tests/xpcshell/test_feature_mainthreadio.js
@@ -39,6 +39,12 @@ add_task(async () => {
           format: "file-path",
           searchable: true,
         },
+        {
+          key: "threadId",
+          label: "Thread ID",
+          format: "string",
+          searchable: true,
+        },
       ],
     });
   }
diff --git a/xpcom/base/Logging.cpp b/xpcom/base/Logging.cpp
index e2a11532002f3..44f74686a90b3 100644
--- a/xpcom/base/Logging.cpp
+++ b/xpcom/base/Logging.cpp
@@ -632,8 +632,11 @@ class LogModuleManager {
           using MS = MarkerSchema;
           MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable};
           schema.SetTableLabel("({marker.data.module}) {marker.data.name}");
-          schema.AddKeyLabelFormat("module", "Module", MS::Format::String);
-          schema.AddKeyLabelFormat("name", "Name", MS::Format::String);
+          schema.AddKeyLabelFormatSearchable("module", "Module",
+                                             MS::Format::String,
+                                             MS::Searchable::Searchable);
+          schema.AddKeyLabelFormatSearchable("name", "Name", MS::Format::String,
+                                             MS::Searchable::Searchable);
           return schema;
         }
       };
diff --git a/xpcom/threads/TaskController.cpp b/xpcom/threads/TaskController.cpp
index 7359583fd7fe6..54da04b8a2637 100644
--- a/xpcom/threads/TaskController.cpp
+++ b/xpcom/threads/TaskController.cpp
@@ -75,7 +75,8 @@ struct TaskMarker {
     schema.SetTableLabel(
         "{marker.name} - {marker.data.name} - priority: "
         "{marker.data.priorityName} ({marker.data.priority})");
-    schema.AddKeyLabelFormat("name", "Task Name", MS::Format::String);
+    schema.AddKeyLabelFormatSearchable("name", "Task Name", MS::Format::String,
+                                       MS::Searchable::Searchable);
     schema.AddKeyLabelFormat("priorityName", "Priority Name",
                              MS::Format::String);
     schema.AddKeyLabelFormat("priority", "Priority level", MS::Format::Integer);
diff --git a/xpcom/threads/nsThread.cpp b/xpcom/threads/nsThread.cpp
index d38c0121585d7..ea85c59765ba3 100644
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -1577,7 +1577,9 @@ void PerformanceCounterState::MaybeReportAccumulatedTime(TimeStamp aNow) {
         static MarkerSchema MarkerTypeDisplay() {
           using MS = MarkerSchema;
           MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable};
-          schema.AddKeyLabelFormat("category", "Type", MS::Format::String);
+          schema.AddKeyLabelFormatSearchable("category", "Type",
+                                             MS::Format::String,
+                                             MS::Searchable::Searchable);
           return schema;
         }
       };
-- 
GitLab