Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4673)

Unified Diff: cc/resources/tile_manager.cc

Issue 140673009: CC/GPU: Add a soft limit to the compositor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use CC Setting. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/tile_manager.h ('k') | cc/resources/tile_priority.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/tile_manager.cc
diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc
index 4f9f0aed6545b1792c93111f34313194c1268288..08a1e22d7a6bbb139af41c5ec6cb5e9f984c44a0 100644
--- a/cc/resources/tile_manager.cc
+++ b/cc/resources/tile_manager.cc
@@ -477,12 +477,13 @@ void TileManager::GetTilesWithAssignedBins(PrioritizedTileSet* tiles) {
void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) {
TRACE_EVENT0("cc", "TileManager::ManageTiles");
- // Update internal state.
+ // Update internal state. We use the soft-limit for the resource-pool
+ // such that we will reduce to that limit after going over.
if (state != global_state_) {
global_state_ = state;
prioritized_tiles_dirty_ = true;
resource_pool_->SetResourceUsageLimits(
- global_state_.memory_limit_in_bytes,
+ global_state_.soft_memory_limit_in_bytes,
global_state_.unused_memory_limit_in_bytes,
global_state_.num_resources_limit);
}
@@ -618,21 +619,30 @@ void TileManager::AssignGpuMemoryToTiles(
all_tiles_required_for_activation_have_memory_ = true;
// Cast to prevent overflow.
- int64 bytes_available =
+ int64 soft_bytes_available =
vmpstr 2014/02/12 22:19:36 maybe visible_bytes_available and repaint_bytes_av
vmpstr 2014/02/12 22:20:20 s/repaint/prepaint/
epennerAtGoogle 2014/02/12 23:08:46 Arg! That's what I called it before! ;) I can cha
vmpstr 2014/02/12 23:21:04 Yeah, I see the problem. I guess soft/hard is OK,
static_cast<int64>(bytes_releasable_) +
- static_cast<int64>(global_state_.memory_limit_in_bytes) -
+ static_cast<int64>(global_state_.soft_memory_limit_in_bytes) -
+ static_cast<int64>(resource_pool_->acquired_memory_usage_bytes());
+ int64 hard_bytes_available =
+ static_cast<int64>(bytes_releasable_) +
+ static_cast<int64>(global_state_.hard_memory_limit_in_bytes) -
static_cast<int64>(resource_pool_->acquired_memory_usage_bytes());
int resources_available = resources_releasable_ +
global_state_.num_resources_limit -
resource_pool_->acquired_resource_count();
-
- size_t bytes_allocatable = std::max(static_cast<int64>(0), bytes_available);
+ size_t soft_bytes_allocatable =
+ std::max(static_cast<int64>(0), soft_bytes_available);
+ size_t hard_bytes_allocatable =
+ std::max(static_cast<int64>(0), hard_bytes_available);
size_t resources_allocatable = std::max(0, resources_available);
size_t bytes_that_exceeded_memory_budget = 0;
- size_t bytes_left = bytes_allocatable;
+ int64 soft_bytes_left = soft_bytes_allocatable;
+ int64 hard_bytes_left = hard_bytes_allocatable;
+
size_t resources_left = resources_allocatable;
- bool oomed = false;
+ bool oomed_soft = false;
+ bool oomed_hard = false;
// Memory we assign to raster tasks now will be deducted from our memory
// in future iterations if priorities change. By assigning at most half
@@ -664,12 +674,15 @@ void TileManager::AssignGpuMemoryToTiles(
continue;
}
- size_t bytes_if_allocated = BytesConsumedIfAllocated(tile);
- size_t raster_bytes_if_rastered = raster_bytes + bytes_if_allocated;
+ const size_t bytes_if_allocated = BytesConsumedIfAllocated(tile);
+ const size_t raster_bytes_if_rastered = raster_bytes + bytes_if_allocated;
+ const size_t tile_bytes_left =
+ (mts.bin == NOW_BIN) ? hard_bytes_left : soft_bytes_left;
vmpstr 2014/02/12 22:19:36 So in SMOOTHNESS_TAKES_PRIORITY, we prioritize the
epennerAtGoogle 2014/02/12 23:08:46 I had to deal with this sticky case before when we
vmpstr 2014/02/12 23:21:04 I guess the exception is NEW_CONTENT_TAKES_PRIORIT
size_t tile_bytes = 0;
size_t tile_resources = 0;
+
reveman 2014/02/12 20:08:02 nit: no need for this line. I'm surprised the pres
epennerAtGoogle 2014/02/12 21:54:34 Sorry I didn't rerun git cl format. Done.
// It costs to maintain a resource.
for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) {
if (mts.tile_versions[mode].resource_) {
@@ -691,7 +704,7 @@ void TileManager::AssignGpuMemoryToTiles(
}
// Tile is OOM.
- if (tile_bytes > bytes_left || tile_resources > resources_left) {
+ if (tile_bytes > tile_bytes_left || tile_resources > resources_left) {
FreeResourcesForTile(tile);
// This tile was already on screen and now its resources have been
@@ -700,10 +713,16 @@ void TileManager::AssignGpuMemoryToTiles(
if (mts.visible_and_ready_to_draw)
tile_version.set_rasterize_on_demand();
- oomed = true;
- bytes_that_exceeded_memory_budget += tile_bytes;
+ oomed_soft = true;
+ if (mts.bin == NOW_BIN) {
+ oomed_hard = true;
+ bytes_that_exceeded_memory_budget += tile_bytes;
+ }
} else {
- bytes_left -= tile_bytes;
+ hard_bytes_left -= tile_bytes;
+ soft_bytes_left -= tile_bytes;
+ soft_bytes_left = std::max<int64>(0, soft_bytes_left);
reveman 2014/02/12 20:08:02 does it hurt to let this go negative? in that case
epennerAtGoogle 2014/02/12 21:54:34 Do you mean make it unsigned and add a if-statemen
reveman 2014/02/12 22:14:52 I was thinking you'd keep this signed and just let
+
resources_left -= tile_resources;
if (tile_version.resource_)
@@ -720,7 +739,7 @@ void TileManager::AssignGpuMemoryToTiles(
// 1. Tile size should not impact raster priority.
// 2. Tiles with existing raster task could otherwise incorrectly
// be added as they are not affected by |bytes_allocatable|.
- if (oomed || raster_bytes_if_rastered > max_raster_bytes) {
+ if (oomed_soft || raster_bytes_if_rastered > max_raster_bytes) {
all_tiles_that_need_to_be_rasterized_have_memory_ = false;
if (tile->required_for_activation())
all_tiles_required_for_activation_have_memory_ = false;
@@ -732,22 +751,23 @@ void TileManager::AssignGpuMemoryToTiles(
tiles_that_need_to_be_rasterized->push_back(tile);
}
- ever_exceeded_memory_budget_ |= bytes_that_exceeded_memory_budget > 0;
+ // OOM reporting uses hard-limit, soft-OOM is normal depending on limit.
+ ever_exceeded_memory_budget_ |= oomed_hard;
if (ever_exceeded_memory_budget_) {
TRACE_COUNTER_ID2("cc",
"over_memory_budget",
this,
"budget",
- global_state_.memory_limit_in_bytes,
+ global_state_.hard_memory_limit_in_bytes,
"over",
bytes_that_exceeded_memory_budget);
}
memory_stats_from_last_assign_.total_budget_in_bytes =
- global_state_.memory_limit_in_bytes;
+ global_state_.hard_memory_limit_in_bytes;
memory_stats_from_last_assign_.bytes_allocated =
- bytes_allocatable - bytes_left;
+ hard_bytes_allocatable - hard_bytes_left;
memory_stats_from_last_assign_.bytes_unreleasable =
- bytes_allocatable - bytes_releasable_;
+ hard_bytes_allocatable - bytes_releasable_;
memory_stats_from_last_assign_.bytes_over = bytes_that_exceeded_memory_budget;
}
« no previous file with comments | « cc/resources/tile_manager.h ('k') | cc/resources/tile_priority.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698