Skip to content

Commit

Permalink
content, base, blink: remove the notion of blame contexts.
Browse files Browse the repository at this point in the history
This change list is a part of a wider effort to remove
TRACE_EVENT_PHASE_(ENTER|LEAVE)_CONTEXT trace events
and associated instrumentation.

BUG=1349313

Change-Id: I8f7630e6dce858f32ba37a338fdac8067c3bd262
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3804884
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Auto-Submit: Joseph Koshy <jkoshy@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1031316}
  • Loading branch information
Joseph Koshy authored and Chromium LUCI CQ committed Aug 4, 2022
1 parent c995948 commit 6d800cf
Show file tree
Hide file tree
Showing 39 changed files with 61 additions and 664 deletions.
3 changes: 0 additions & 3 deletions base/BUILD.gn
Expand Up @@ -2366,8 +2366,6 @@ mixed_component("base") {
if (enable_base_tracing) {
sources += [
"trace_event/auto_open_close_event.h",
"trace_event/blame_context.cc",
"trace_event/blame_context.h",
"trace_event/builtin_categories.cc",
"trace_event/builtin_categories.h",
"trace_event/category_registry.cc",
Expand Down Expand Up @@ -3886,7 +3884,6 @@ test("base_unittests") {
if (enable_base_tracing) {
sources += [
"test/trace_event_analyzer_unittest.cc",
"trace_event/blame_context_unittest.cc",
"trace_event/event_name_filter_unittest.cc",
"trace_event/heap_profiler_allocation_context_tracker_unittest.cc",
"trace_event/memory_allocator_dump_unittest.cc",
Expand Down
28 changes: 0 additions & 28 deletions base/task/sequence_manager/sequence_manager_impl_unittest.cc
Expand Up @@ -3225,34 +3225,6 @@ TEST_P(SequenceManagerTest, CurrentlyExecutingTaskQueue_NestedLoop) {
EXPECT_EQ(nullptr, sequence_manager()->currently_executing_task_queue());
}

#if BUILDFLAG(ENABLE_BASE_TRACING)
TEST_P(SequenceManagerTest, BlameContextAttribution) {
if (GetUnderlyingRunnerType() == RunnerType::kMessagePump)
return;
using trace_analyzer::Query;

auto queue = CreateTaskQueue();

trace_analyzer::Start("*");
{
trace_event::BlameContext blame_context("base", "name", "type", "scope", 0,
nullptr);
blame_context.Initialize();
queue->SetBlameContext(&blame_context);
queue->task_runner()->PostTask(FROM_HERE, BindOnce(&NopTask));
RunLoop().RunUntilIdle();
}
auto analyzer = trace_analyzer::Stop();

trace_analyzer::TraceEventVector events;
Query q = Query::EventPhaseIs(TRACE_EVENT_PHASE_ENTER_CONTEXT) ||
Query::EventPhaseIs(TRACE_EVENT_PHASE_LEAVE_CONTEXT);
analyzer->FindEvents(q, &events);

EXPECT_EQ(2u, events.size());
}
#endif // BUILDFLAG(ENABLE_BASE_TRACING)

TEST_P(SequenceManagerTest, NoWakeUpsForCanceledDelayedTasks) {
auto queue = CreateTaskQueue();

Expand Down
8 changes: 0 additions & 8 deletions base/task/sequence_manager/task_queue.cc
Expand Up @@ -180,7 +180,6 @@ void TaskQueue::ShutdownTaskQueue() {
TakeTaskQueueImpl().reset();
return;
}
impl_->SetBlameContext(nullptr);
sequence_manager_->UnregisterTaskQueueImpl(TakeTaskQueueImpl());
}

Expand Down Expand Up @@ -272,13 +271,6 @@ void TaskQueue::RemoveTaskObserver(TaskObserver* task_observer) {
impl_->RemoveTaskObserver(task_observer);
}

void TaskQueue::SetBlameContext(trace_event::BlameContext* blame_context) {
DCHECK_CALLED_ON_VALID_THREAD(associated_thread_->thread_checker);
if (!impl_)
return;
impl_->SetBlameContext(blame_context);
}

void TaskQueue::InsertFence(InsertFencePosition position) {
DCHECK_CALLED_ON_VALID_THREAD(associated_thread_->thread_checker);
if (!impl_)
Expand Down
9 changes: 0 additions & 9 deletions base/task/sequence_manager/task_queue.h
Expand Up @@ -28,10 +28,6 @@ namespace base {

class TaskObserver;

namespace trace_event {
class BlameContext;
}

namespace sequence_manager {

namespace internal {
Expand Down Expand Up @@ -302,11 +298,6 @@ class BASE_EXPORT TaskQueue : public RefCountedThreadSafe<TaskQueue> {
void AddTaskObserver(TaskObserver* task_observer);
void RemoveTaskObserver(TaskObserver* task_observer);

// Set the blame context which is entered and left while executing tasks from
// this task queue. |blame_context| must be null or outlive this task queue.
// Must be called on the thread this TaskQueue was created by.
void SetBlameContext(trace_event::BlameContext* blame_context);

enum class InsertFencePosition {
kNow, // Tasks posted on the queue up till this point further may run.
// All further tasks are blocked.
Expand Down
9 changes: 0 additions & 9 deletions base/task/sequence_manager/task_queue_impl.cc
Expand Up @@ -936,9 +936,6 @@ void TaskQueueImpl::NotifyWillProcessTask(const Task& task,
bool was_blocked_or_low_priority) {
DCHECK(should_notify_observers_);

if (main_thread_only().blame_context)
main_thread_only().blame_context->Enter();

for (auto& observer : main_thread_only().task_observers)
observer.WillProcessTask(task, was_blocked_or_low_priority);
}
Expand All @@ -947,12 +944,6 @@ void TaskQueueImpl::NotifyDidProcessTask(const Task& task) {
DCHECK(should_notify_observers_);
for (auto& observer : main_thread_only().task_observers)
observer.DidProcessTask(task);
if (main_thread_only().blame_context)
main_thread_only().blame_context->Leave();
}

void TaskQueueImpl::SetBlameContext(trace_event::BlameContext* blame_context) {
main_thread_only().blame_context = blame_context;
}

void TaskQueueImpl::InsertFence(TaskQueue::InsertFencePosition position) {
Expand Down
2 changes: 0 additions & 2 deletions base/task/sequence_manager/task_queue_impl.h
Expand Up @@ -141,7 +141,6 @@ class BASE_EXPORT TaskQueueImpl {
TaskQueue::QueuePriority GetQueuePriority() const;
void AddTaskObserver(TaskObserver* task_observer);
void RemoveTaskObserver(TaskObserver* task_observer);
void SetBlameContext(trace_event::BlameContext* blame_context);
void InsertFence(TaskQueue::InsertFencePosition position);
void InsertFenceAt(TimeTicks time);
void RemoveFence();
Expand Down Expand Up @@ -434,7 +433,6 @@ class BASE_EXPORT TaskQueueImpl {
ObserverList<TaskObserver>::Unchecked task_observers;
HeapHandle heap_handle;
bool is_enabled = true;
raw_ptr<trace_event::BlameContext> blame_context = nullptr; // Not owned.
absl::optional<Fence> current_fence;
absl::optional<TimeTicks> delayed_fence;
// Snapshots the next sequence number when the queue is unblocked, otherwise
Expand Down
1 change: 0 additions & 1 deletion base/trace_event/base_tracing.h
Expand Up @@ -15,7 +15,6 @@
#if BUILDFLAG(ENABLE_BASE_TRACING)
// Update the check in //base/PRESUBMIT.py when adding new headers here.
// TODO(crbug/1006541): Switch to perfetto for trace event implementation.
#include "base/trace_event/blame_context.h" // nogncheck
#include "base/trace_event/heap_profiler.h" // nogncheck
#include "base/trace_event/interned_args_helper.h" // nogncheck
#include "base/trace_event/memory_allocator_dump_guid.h" // nogncheck
Expand Down
1 change: 0 additions & 1 deletion base/trace_event/base_tracing_forward.h
Expand Up @@ -37,7 +37,6 @@ struct check_traced_value_support {
namespace base {
namespace trace_event {

class BlameContext;
class ConvertableToTraceFormat;
class TracedValue;

Expand Down
117 changes: 0 additions & 117 deletions base/trace_event/blame_context.cc

This file was deleted.

0 comments on commit 6d800cf

Please sign in to comment.