Skip to content

Commit

Permalink
Add top queued IPC message name in dump provider
Browse files Browse the repository at this point in the history
BUG=874530

Change-Id: I869e9b6adccdf1c42406c7fd9a8c493ee39c36cd
Reviewed-on: https://chromium-review.googlesource.com/1227361
Reviewed-by: Ken Rockot <[email protected]>
Commit-Queue: Siddhartha S <[email protected]>
Cr-Commit-Position: refs/heads/master@{#591832}
  • Loading branch information
ssiddhartha authored and Commit Bot committed Sep 17, 2018
1 parent e28445f commit d1cfec1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ipc/ipc_mojo_bootstrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ class ChannelAssociatedGroupController
return outgoing_messages_.size();
}

std::pair<uint32_t, size_t> GetTopQueuedMessageNameAndCount() {
std::unordered_map<uint32_t, size_t> counts;
std::pair<uint32_t, size_t> top_message_name_and_count = {0, 0};
base::AutoLock lock(outgoing_messages_lock_);
for (const auto& message : outgoing_messages_) {
auto it_and_inserted = counts.emplace(message.name(), 0);
it_and_inserted.first->second++;
if (it_and_inserted.first->second > top_message_name_and_count.second)
top_message_name_and_count = *it_and_inserted.first;
}
return top_message_name_and_count;
}

void Bind(mojo::ScopedMessagePipeHandle handle) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(task_runner_->BelongsToCurrentThread());
Expand Down Expand Up @@ -969,6 +982,12 @@ bool ControllerMemoryDumpProvider::OnMemoryDump(
dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount,
base::trace_event::MemoryAllocatorDump::kUnitsObjects,
controller->GetQueuedMessageCount());
auto top_message_name_and_count =
controller->GetTopQueuedMessageNameAndCount();
dump->AddScalar("top_message_name", "id", top_message_name_and_count.first);
dump->AddScalar("top_message_count",
base::trace_event::MemoryAllocatorDump::kUnitsObjects,
top_message_name_and_count.second);
}

return true;
Expand Down

0 comments on commit d1cfec1

Please sign in to comment.