Commit e465409c authored by Sebastien Marchand's avatar Sebastien Marchand Committed by Commit Bot

Add trace events that record the memory pressure sessions

Change-Id: Id32ab0a774dc45ca4459e2b709ff82d54389b3c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2124949
Auto-Submit: Sébastien Marchand <sebmarchand@chromium.org>
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754496}
parent 7084680d
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <numeric> #include <numeric>
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/trace_event/trace_event.h"
namespace util { namespace util {
...@@ -83,7 +84,34 @@ void MemoryPressureVoteAggregator::OnVote( ...@@ -83,7 +84,34 @@ void MemoryPressureVoteAggregator::OnVote(
if (new_vote) if (new_vote)
votes_[new_vote.value()]++; votes_[new_vote.value()]++;
auto old_pressure_level = current_pressure_level_; auto old_pressure_level = current_pressure_level_;
// If the pressure level is not None then an asynchronous event will have been
// started below, it needs to be ended.
// Note that we record this event every time we receive a new vote to ensure
// that the begin event doesn't get dropped during long pressure sessions.
if (old_pressure_level ==
MemoryPressureLevel::MEMORY_PRESSURE_LEVEL_CRITICAL) {
TRACE_EVENT_NESTABLE_ASYNC_END0("base", "MemoryPressure::CriticalPressure",
this);
} else if (old_pressure_level ==
MemoryPressureLevel::MEMORY_PRESSURE_LEVEL_MODERATE) {
TRACE_EVENT_NESTABLE_ASYNC_END0("base", "MemoryPressure::ModeratePressure",
this);
}
current_pressure_level_ = EvaluateVotes(); current_pressure_level_ = EvaluateVotes();
// Start an asynchronous tracing event to record this pressure session.
if (current_pressure_level_ ==
MemoryPressureLevel::MEMORY_PRESSURE_LEVEL_CRITICAL) {
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0("base",
"MemoryPressure::CriticalPressure", this);
} else if (current_pressure_level_ ==
MemoryPressureLevel::MEMORY_PRESSURE_LEVEL_MODERATE) {
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0("base",
"MemoryPressure::ModeratePressure", this);
}
if (old_pressure_level != current_pressure_level_) if (old_pressure_level != current_pressure_level_)
delegate_->OnMemoryPressureLevelChanged(current_pressure_level_); delegate_->OnMemoryPressureLevelChanged(current_pressure_level_);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment