Visitar URL original
fix(patch): remove unused legacy tracing backend · electron/electron@2e3a936 · GitHub
Skip to content

Commit 2e3a936

Browse files
ckerrGitHub Copilot
authored andcommitted
fix(patch): remove unused legacy tracing backend
Electron builds Node exclusively with Perfetto since #50591. Wire the upstream Perfetto agent directly and drop the legacy header split and dual-backend source lists. Ref: #50591 Ref: nodejs/node#64565 Co-Authored-By: GitHub Copilot <copilot@github.com>
1 parent a8f9728 commit 2e3a936

7 files changed

Lines changed: 184 additions & 1867 deletions

‎BUILD.gn‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ action("electron_generate_node_defines") {
477477
script = "build/generate_node_defines.py"
478478

479479
inputs = [
480-
"//third_party/electron_node/src/tracing/trace_event_legacy.h",
480+
"//third_party/electron_node/src/tracing/trace_event_common.h",
481481
"//third_party/electron_node/src/tracing/trace_event.h",
482482
"//third_party/electron_node/src/util.h",
483483
]

‎filenames.auto.gni‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,7 @@ auto_filenames = {
422422
"../third_party/electron_node/src/tracing/node_trace_buffer.h",
423423
"../third_party/electron_node/src/tracing/node_trace_writer.h",
424424
"../third_party/electron_node/src/tracing/trace_event.h",
425-
"../third_party/electron_node/src/tracing/trace_event_helper.h",
426-
"../third_party/electron_node/src/tracing/trace_event_legacy.h",
427-
"../third_party/electron_node/src/tracing/trace_event_legacy_inl.h",
425+
"../third_party/electron_node/src/tracing/trace_event_common.h",
428426
"../third_party/electron_node/src/tracing/trace_event_perfetto.h",
429427
"../third_party/electron_node/src/tracing/traced_value.h",
430428
"../third_party/electron_node/src/tty_wrap.h",

‎patches/node/.patches‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ src_migrate_to_setter_definer_interceptor_callbacks_returning.patch
6161
build_perfetto-sdk.patch
6262
lib_add_perfetto_support.patch
6363
src_fix_trace_macro_compatibility.patch
64-
src_rename_legacy_trace_event_headers.patch
6564
src_add_perfetto_trace_agent.patch
6665
src_fix_perfetto_build_on_gettracefilepath.patch
6766
src_test_disable_trace_events_tests_when_perfetto_is_enabled.patch

‎patches/node/src_add_perfetto_trace_agent.patch‎

Lines changed: 134 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,36 @@ Reviewed-By: James M Snell <jasnell@gmail.com>
1010
Reviewed-By: Ryuhei Shima <shimaryuhei@gmail.com>
1111

1212
diff --git a/node.gyp b/node.gyp
13-
index 9c88bbfb8d3f1847b58f35de5b4da4d1b27536be..953007fc24875ca35db54ac4cdd31f5e3b9449c5 100644
13+
index 54ee17622bc979af7c55336206a272852a13ebdd..8fbb5a6a0986584390d086454a2e3e565a656fca 100644
1414
--- a/node.gyp
1515
+++ b/node.gyp
16-
@@ -434,6 +434,10 @@
17-
'src/node_crypto.h',
18-
],
19-
'node_tracing_perfetto_sources': [
16+
@@ -191,10 +191,11 @@
17+
'src/timers.cc',
18+
'src/timer_wrap.cc',
19+
'src/tracing/agent.cc',
20+
- 'src/tracing/agent_legacy.cc',
2021
+ 'src/tracing/agent_perfetto.cc',
21-
+ 'src/tracing/agent_perfetto.h',
22+
'src/tracing/node_trace_buffer.cc',
23+
'src/tracing/node_trace_writer.cc',
24+
'src/tracing/trace_event.cc',
2225
+ 'src/tracing/trace_event_perfetto.cc',
26+
'src/tracing/traced_value.cc',
27+
'src/tty_wrap.cc',
28+
'src/udp_wrap.cc',
29+
@@ -328,11 +329,12 @@
30+
'src/tcp_wrap.h',
31+
'src/timers.h',
32+
'src/tracing/agent.h',
33+
- 'src/tracing/agent_legacy.h',
34+
+ 'src/tracing/agent_perfetto.h',
35+
'src/tracing/node_trace_buffer.h',
36+
'src/tracing/node_trace_writer.h',
37+
'src/tracing/trace_event.h',
38+
'src/tracing/trace_event_common.h',
2339
+ 'src/tracing/trace_event_perfetto.h',
24-
],
25-
'node_tracing_legacy_sources': [
26-
'src/tracing/agent_legacy.cc',
40+
'src/tracing/traced_value.h',
41+
'src/timer_wrap.h',
42+
'src/timer_wrap-inl.h',
2743
diff --git a/src/api/environment.cc b/src/api/environment.cc
2844
index c81ef82c5a23d30ec7430b8726bd28e1be2f225e..75fc97a581b79c87a51adcbe999b937262b422db 100644
2945
--- a/src/api/environment.cc
@@ -79,6 +95,73 @@ index a493f59465d207b4b89d8941807d4ff6acff82ac..88e8a2f401cac75810e3b0fdb776b41e
7995
+ }],
8096
+ ],
8197
}
98+
diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc
99+
index a9e14e53bb6e3f5082a3cf6a0786cf63d9381b5b..3a7fe419cac1d5cec60596ef10a507611a5da9ee 100644
100+
--- a/src/inspector_agent.cc
101+
+++ b/src/inspector_agent.cc
102+
@@ -14,7 +14,9 @@
103+
#include "inspector/runtime_agent.h"
104+
#include "inspector/storage_agent.h"
105+
#include "inspector/target_agent.h"
106+
+#if !defined(V8_USE_PERFETTO)
107+
#include "inspector/tracing_agent.h"
108+
+#endif // !defined(V8_USE_PERFETTO)
109+
#include "inspector/worker_agent.h"
110+
#include "inspector/worker_inspector.h"
111+
#include "inspector_io.h"
112+
@@ -238,9 +240,11 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel,
113+
StringView(),
114+
V8Inspector::ClientTrustLevel::kFullyTrusted);
115+
node_dispatcher_ = std::make_unique<UberDispatcher>(this);
116+
+#if !defined(V8_USE_PERFETTO)
117+
tracing_agent_ =
118+
std::make_unique<protocol::TracingAgent>(env, main_thread_);
119+
tracing_agent_->Wire(node_dispatcher_.get());
120+
+#endif // !defined(V8_USE_PERFETTO)
121+
if (worker_manager) {
122+
worker_agent_ = std::make_unique<protocol::WorkerAgent>(worker_manager);
123+
worker_agent_->Wire(node_dispatcher_.get());
124+
@@ -274,8 +278,10 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel,
125+
}
126+
127+
~ChannelImpl() override {
128+
+#if !defined(V8_USE_PERFETTO)
129+
tracing_agent_->disable();
130+
tracing_agent_.reset(); // Dispose before the dispatchers
131+
+#endif // !defined(V8_USE_PERFETTO)
132+
if (worker_agent_) {
133+
worker_agent_->disable();
134+
worker_agent_.reset(); // Dispose before the dispatchers
135+
@@ -424,7 +430,9 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel,
136+
}
137+
138+
std::unique_ptr<protocol::RuntimeAgent> runtime_agent_;
139+
+#if !defined(V8_USE_PERFETTO)
140+
std::unique_ptr<protocol::TracingAgent> tracing_agent_;
141+
+#endif // !defined(V8_USE_PERFETTO)
142+
std::unique_ptr<protocol::WorkerAgent> worker_agent_;
143+
std::shared_ptr<protocol::TargetAgent> target_agent_;
144+
std::unique_ptr<NetworkInspector> network_inspector_;
145+
diff --git a/src/node_internals.h b/src/node_internals.h
146+
index 8e930a6fecd6589b858293d91b2454ea14ae7c73..24c5dbe405d69ceb0e515aeaa6b26233bb2943a9 100644
147+
--- a/src/node_internals.h
148+
+++ b/src/node_internals.h
149+
@@ -315,6 +315,7 @@ class ThreadPoolWork {
150+
const char* type_;
151+
};
152+
153+
+#if !defined(V8_USE_PERFETTO)
154+
#define TRACING_CATEGORY_NODE "node"
155+
#define TRACING_CATEGORY_NODE1(one) \
156+
TRACING_CATEGORY_NODE "," \
157+
@@ -323,6 +324,7 @@ class ThreadPoolWork {
158+
TRACING_CATEGORY_NODE "," \
159+
TRACING_CATEGORY_NODE "." #one "," \
160+
TRACING_CATEGORY_NODE "." #one "." #two
161+
+ #endif // !defined(V8_USE_PERFETTO)
162+
163+
// Functions defined in node.cc that are exposed via the bootstrapper object
164+
82165
diff --git a/src/node_options.h b/src/node_options.h
83166
index ea75cca72d8c4cf247828414dc08dd0082d3e93c..793ce8fb269ab10b7770d0df54be2b9ff90e0960 100644
84167
--- a/src/node_options.h
@@ -132,37 +215,27 @@ index f47e2a46b66b84938bcbf5b34ffc4a4a4a39af3f..665d2a467e08084837217482f65bb626
132215
v8::PageAllocator* page_allocator_;
133216
std::shared_ptr<WorkerThreadsTaskRunner> worker_thread_task_runner_;
134217
diff --git a/src/tracing/agent.cc b/src/tracing/agent.cc
135-
index 69b956e9bc9d68cab6076dff661b8f8877007ec8..2ffc49f31e6ad9c447491d2c005cf1d90e40a61a 100644
218+
index 69b956e9bc9d68cab6076dff661b8f8877007ec8..6d80a4797461683315f9f51266a34a2c00e4c937 100644
136219
--- a/src/tracing/agent.cc
137220
+++ b/src/tracing/agent.cc
138-
@@ -1,6 +1,12 @@
221+
@@ -1,5 +1,5 @@
139222
#include "tracing/agent.h"
140-
+
141-
+#ifdef V8_USE_PERFETTO
223+
-#include "tracing/agent_legacy.h"
142224
+#include "tracing/agent_perfetto.h"
143-
+#else
144-
#include "tracing/agent_legacy.h"
145-
-#include "tracing/trace_event.h"
146-
+#endif
147-
+
148-
+#include "tracing/trace_event_helper.h"
225+
#include "tracing/trace_event.h"
149226

150227
namespace node {
151-
namespace tracing {
152-
@@ -23,7 +29,11 @@ void Agent::Deleter::operator()(Agent* agent) {
228+
@@ -23,7 +23,7 @@ void Agent::Deleter::operator()(Agent* agent) {
153229
std::unique_ptr<Agent, Agent::Deleter> Agent::CreateDefault() {
154230
CHECK_NULL(g_agent);
155231

156-
+#ifdef V8_USE_PERFETTO
232+
- auto agent = new LegacyTracingAgent();
157233
+ auto agent = new PerfettoTracingAgent();
158-
+#else
159-
auto agent = new LegacyTracingAgent();
160-
+#endif
161234

162235
g_agent = agent;
163236
TraceEventHelper::SetTracingController(agent->GetTracingController());
164237
diff --git a/src/tracing/agent.h b/src/tracing/agent.h
165-
index 78203154c099a56d0d9256f9cade9742dffb141c..60ed6ebf5a8d29552b8dc418fb397fe19dab89ce 100644
238+
index 78203154c099a56d0d9256f9cade9742dffb141c..51d8a992342b54addd892fb77b21a66d09ada486 100644
166239
--- a/src/tracing/agent.h
167240
+++ b/src/tracing/agent.h
168241
@@ -43,9 +43,9 @@ class Agent {
@@ -177,10 +250,11 @@ index 78203154c099a56d0d9256f9cade9742dffb141c..60ed6ebf5a8d29552b8dc418fb397fe1
177250

178251
struct Deleter {
179252
void operator()(Agent* agent);
180-
@@ -88,6 +88,7 @@ class AgentWriterHandle {
253+
@@ -87,7 +87,7 @@ class AgentWriterHandle {
254+
int id_ = 0;
181255

182256
friend class Agent;
183-
friend class LegacyTracingAgent;
257+
- friend class LegacyTracingAgent;
184258
+ friend class PerfettoTracingAgent;
185259
};
186260

@@ -785,26 +859,51 @@ index 0000000000000000000000000000000000000000..0d74ca5332b018e28182f7181289099e
785859
+
786860
+#endif // SRC_TRACING_AGENT_PERFETTO_H_
787861
diff --git a/src/tracing/trace_event.h b/src/tracing/trace_event.h
788-
index 21d158fb16fbdb42681f8f1aa7108dfeee3d62fa..3169505626c05da462ccdd0b1b4e61325d77ee69 100644
862+
index a0f8c695ea0160e5282679e2a15905863731fffe..81608796814522863ff2d9d0a085638729c7960f 100644
789863
--- a/src/tracing/trace_event.h
790864
+++ b/src/tracing/trace_event.h
791-
@@ -1,9 +1,15 @@
865+
@@ -5,10 +5,33 @@
792866
#ifndef SRC_TRACING_TRACE_EVENT_H_
793867
#define SRC_TRACING_TRACE_EVENT_H_
794868

869+
+#if defined(V8_USE_PERFETTO)
870+
+
871+
#include "v8-platform.h"
795872
+#include "tracing/agent.h"
796873
+
797-
#if defined(V8_USE_PERFETTO)
798-
799-
-#error "Perfetto is not supported"
874+
+namespace node::tracing {
875+
+
876+
+class TraceEventHelper {
877+
+ public:
878+
+ static v8::TracingController* GetTracingController();
879+
+ static void SetTracingController(v8::TracingController* controller);
880+
+};
881+
+
882+
+} // namespace node::tracing
883+
+
800884
+#define TRACING_CATEGORY_NODE "node"
801885
+#define TRACING_CATEGORY_NODE1(one) TRACING_CATEGORY_NODE "." #one
802886
+#define TRACING_CATEGORY_NODE2(one, two) TRACING_CATEGORY_NODE "." #one "." #two
803887
+
804888
+#include "tracing/trace_event_perfetto.h"
889+
+
890+
+#else
891+
+
892+
+#include <atomic>
893+
+
894+
#include "tracing/agent_legacy.h"
895+
#include "trace_event_common.h"
896+
-#include <atomic>
805897

806-
#else // defined(V8_USE_PERFETTO)
898+
// This header file defines implementation details of how the trace macros in
899+
// trace_event_common.h collect and store trace events. Anything not
900+
@@ -717,4 +740,6 @@ class ScopedTracer {
901+
} // namespace tracing
902+
} // namespace node
807903

904+
+#endif // defined(V8_USE_PERFETTO)
905+
+
906+
#endif // SRC_TRACING_TRACE_EVENT_H_
808907
diff --git a/src/tracing/trace_event_perfetto.cc b/src/tracing/trace_event_perfetto.cc
809908
new file mode 100644
810909
index 0000000000000000000000000000000000000000..87227b95fd56162a9f577bed4d44bafd0f6a8701
@@ -1011,7 +1110,7 @@ index 0000000000000000000000000000000000000000..8cfcb52182df9a600e5cf2c1466e9ffa
10111110
+ assert(stat.size > 0);
10121111
+}));
10131112
diff --git a/unofficial.gni b/unofficial.gni
1014-
index 6af570a3b9742533903438b71b74cf34cfd5179f..8a6d8cc76d56d093bfd1884a0b1fa18e41abfb38 100644
1113+
index 6af570a3b9742533903438b71b74cf34cfd5179f..f54840a3cf67c9fe3c016ac830deb21c6880e7c9 100644
10151114
--- a/unofficial.gni
10161115
+++ b/unofficial.gni
10171116
@@ -156,6 +156,7 @@ template("node_gn_build") {
@@ -1030,11 +1129,3 @@ index 6af570a3b9742533903438b71b74cf34cfd5179f..8a6d8cc76d56d093bfd1884a0b1fa18e
10301129
]
10311130

10321131
cflags_cc = [
1033-
@@ -202,6 +204,7 @@ template("node_gn_build") {
1034-
"$root_gen_dir/electron_natives.cc",
1035-
"$target_gen_dir/node_javascript.cc",
1036-
] + gypi_values.node_sources
1037-
+ sources += gypi_values.node_tracing_perfetto_sources
1038-
1039-
if (is_win) {
1040-
libs = [ "psapi.lib" ]

0 commit comments

Comments
 (0)