Skip to content

Commit

Permalink
DevTools Performance Timeline revisited (#1972)
Browse files Browse the repository at this point in the history
The DevTools Performance Timeline is an implementation of a Trace
viewer.

On Chrome, the TracingController has several TracingAgents, each of
which outputs events in the Trace format.
These agents are mainly the Blink Trace agent, and a v8 js sampling
profiler, plus on Android, a java trace agent.

(https://github.com/youtube/cobalt/blob/f0d959a6920a8c481811c15ef4ebdbe8c6d0cc66/base/trace_event/tracing_agent.h#L21).
This CL should make it easier to add an Android tracing agent in the
future.

Previously, the Cobalt implementation did not have a TracingController,
and had a single agent which was plugged directly into the v8 profiler,
so we were blind to the rest of the callstack.

This CL introduces a TracingController with two agents, a
TraceEventsAgent, analogous to the Chrome Blink agent, which captures
the bulk of the data, and also a V8TracingAgent which is still plugged
into V8. I think the V8 agent still needs more work so even though its
implemented here, its currently disabled.

I also think we can lean into CDP (chrome devtools protocol) to get rid
of our custom CVal implmentation, which should get our Performance
testing closer to Chrome.


b/198688218
b/123369438
  • Loading branch information
sideb0ard authored Nov 14, 2023
1 parent a3acc2a commit b01ba22
Show file tree
Hide file tree
Showing 9 changed files with 482 additions and 247 deletions.
4 changes: 2 additions & 2 deletions cobalt/debug/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ static_library("debug") {
"backend/render_overlay.h",
"backend/script_debugger_agent.cc",
"backend/script_debugger_agent.h",
"backend/tracing_agent.cc",
"backend/tracing_agent.h",
"backend/tracing_controller.cc",
"backend/tracing_controller.h",
"command.h",
"console/debug_hub.cc",
"console/debug_hub.h",
Expand Down
11 changes: 6 additions & 5 deletions cobalt/debug/backend/debug_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ constexpr char kDomAgent[] = "DomAgent";
constexpr char kCssAgent[] = "CssAgent";
constexpr char kOverlayAgent[] = "OverlayAgent";
constexpr char kPageAgent[] = "PageAgent";
constexpr char kTracingAgent[] = "TracingAgent";
constexpr char kTracingController[] = "TracingController";

// Move the state for a particular agent out of the dictionary holding the
// state for all agents. Returns a NULL JSONObject if either |agents_state| is
Expand Down Expand Up @@ -161,8 +161,8 @@ void DebugModule::BuildInternal(const ConstructionData& data) {
std::move(page_render_layer),
data.resource_provider));
}
tracing_agent_.reset(
new TracingAgent(debug_dispatcher_.get(), script_debugger_.get()));
tracing_controller_.reset(
new TracingController(debug_dispatcher_.get(), script_debugger_.get()));

// Hook up hybrid agent JavaScript to the DebugBackend.
debug_backend_->BindAgents(css_agent_);
Expand Down Expand Up @@ -190,7 +190,7 @@ void DebugModule::BuildInternal(const ConstructionData& data) {
overlay_agent_->Thaw(RemoveAgentState(kOverlayAgent, agents_state));
if (page_agent_)
page_agent_->Thaw(RemoveAgentState(kPageAgent, agents_state));
tracing_agent_->Thaw(RemoveAgentState(kTracingAgent, agents_state));
tracing_controller_->Thaw(RemoveAgentState(kTracingController, agents_state));

is_frozen_ = false;
}
Expand All @@ -213,7 +213,8 @@ std::unique_ptr<DebuggerState> DebugModule::Freeze() {
StoreAgentState(agents_state, kOverlayAgent, overlay_agent_->Freeze());
if (page_agent_)
StoreAgentState(agents_state, kPageAgent, page_agent_->Freeze());
StoreAgentState(agents_state, kTracingAgent, tracing_agent_->Freeze());
StoreAgentState(agents_state, kTracingController,
tracing_controller_->Freeze());

// Take the clients from the dispatcher last so they still get events that the
// agents might send as part of being frozen.
Expand Down
4 changes: 2 additions & 2 deletions cobalt/debug/backend/debug_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "cobalt/debug/backend/page_agent.h"
#include "cobalt/debug/backend/render_overlay.h"
#include "cobalt/debug/backend/script_debugger_agent.h"
#include "cobalt/debug/backend/tracing_agent.h"
#include "cobalt/debug/backend/tracing_controller.h"
#include "cobalt/debug/json_object.h"
#include "cobalt/dom/window.h"
#include "cobalt/render_tree/resource_provider.h"
Expand Down Expand Up @@ -142,7 +142,7 @@ class DebugModule : public script::ScriptDebugger::Delegate {
std::unique_ptr<OverlayAgent> overlay_agent_;
std::unique_ptr<PageAgent> page_agent_;
std::unique_ptr<ScriptDebuggerAgent> script_debugger_agent_;
std::unique_ptr<TracingAgent> tracing_agent_;
std::unique_ptr<TracingController> tracing_controller_;
};

} // namespace backend
Expand Down
164 changes: 0 additions & 164 deletions cobalt/debug/backend/tracing_agent.cc

This file was deleted.

72 changes: 0 additions & 72 deletions cobalt/debug/backend/tracing_agent.h

This file was deleted.

Loading

0 comments on commit b01ba22

Please sign in to comment.