Commit 9bf42619 authored by Jonathan Backer's avatar Jonathan Backer Committed by Commit Bot

Bound time to delete cc::Resource

With OOP-D, we no longer have draw call pressure inducing flushes.
https://crbug.com/c/875319 suggests that there are cases where we
reuse tiles enough in the UI compositor that we never hit the
 unused_resources_.empty() condition in the EvictExpiredResource method.

This CL adds a deadline for the flush, so that we wait at most 1 second.

Bug: 875319
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ifa8d516699be7ae1eff47db01f8be55a0aae92c8
Reviewed-on: https://chromium-review.googlesource.com/c/1284435
Commit-Queue: Jonathan Backer <backer@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600387}
parent 7885649d
......@@ -67,6 +67,7 @@ bool ResourceMeetsSizeRequirements(const gfx::Size& requested_size,
} // namespace
constexpr base::TimeDelta ResourcePool::kDefaultExpirationDelay;
constexpr base::TimeDelta ResourcePool::kDefaultMaxFlushDelay;
void ResourcePool::GpuBacking::InitOverlayCandidateAndTextureTarget(
const viz::ResourceFormat format,
......@@ -95,6 +96,7 @@ ResourcePool::ResourcePool(
resource_expiration_delay_(expiration_delay),
disallow_non_exact_reuse_(disallow_non_exact_reuse),
tracing_id_(g_next_tracing_id.GetNext()),
flush_evicted_resources_deadline_(base::TimeTicks::Max()),
weak_ptr_factory_(this) {
base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
this, "cc::ResourcePool", task_runner_.get());
......@@ -458,6 +460,10 @@ void ResourcePool::DeleteResource(std::unique_ptr<PoolResource> resource) {
resource->size(), resource->format());
total_memory_usage_bytes_ -= resource_bytes;
--total_resource_count_;
if (flush_evicted_resources_deadline_ == base::TimeTicks::Max()) {
flush_evicted_resources_deadline_ =
base::TimeTicks::Now() + kDefaultMaxFlushDelay;
}
}
void ResourcePool::UpdateResourceContentIdAndInvalidation(
......@@ -497,7 +503,9 @@ void ResourcePool::EvictExpiredResources() {
EvictResourcesNotUsedSince(current_time - resource_expiration_delay_);
if (unused_resources_.empty()) {
if (unused_resources_.empty() ||
flush_evicted_resources_deadline_ < current_time) {
flush_evicted_resources_deadline_ = base::TimeTicks::Max();
// If nothing is evictable, we have deleted one (and possibly more)
// resources without any new activity. Flush to ensure these deletions are
// processed.
......@@ -510,9 +518,12 @@ void ResourcePool::EvictExpiredResources() {
}
// If we still have evictable resources, schedule a call to
// EvictExpiredResources at the time when the LRU buffer expires.
ScheduleEvictExpiredResourcesIn(GetUsageTimeForLRUResource() +
resource_expiration_delay_ - current_time);
// EvictExpiredResources for either (a) the time when the LRU buffer expires
// or (b) the deadline to explicitly flush previously evicted resources.
ScheduleEvictExpiredResourcesIn(
std::min(GetUsageTimeForLRUResource() + resource_expiration_delay_,
flush_evicted_resources_deadline_) -
current_time);
}
void ResourcePool::EvictResourcesNotUsedSince(base::TimeTicks time_limit) {
......
......@@ -51,6 +51,9 @@ class CC_EXPORT ResourcePool : public base::trace_event::MemoryDumpProvider {
// Delay before a resource is considered expired.
static constexpr base::TimeDelta kDefaultExpirationDelay =
base::TimeDelta::FromSeconds(5);
// Max delay before an evicted resource is flushed.
static constexpr base::TimeDelta kDefaultMaxFlushDelay =
base::TimeDelta::FromSeconds(1);
// A base class to hold ownership of gpu backed PoolResources. Allows the
// client to define destruction semantics.
......@@ -391,6 +394,8 @@ class CC_EXPORT ResourcePool : public base::trace_event::MemoryDumpProvider {
std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_;
base::TimeTicks flush_evicted_resources_deadline_;
base::WeakPtrFactory<ResourcePool> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ResourcePool);
......
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