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

Unified Diff: gpu/command_buffer/client/mapped_memory.cc

Issue 116863003: gpu: Reuse transfer buffers more aggresively (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years 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
Index: gpu/command_buffer/client/mapped_memory.cc
diff --git a/gpu/command_buffer/client/mapped_memory.cc b/gpu/command_buffer/client/mapped_memory.cc
index 15584aaaf07daebf1bf20ba5225e086bfc1da4db..890732c916f1b969475802f0df977a2fcce55312 100644
--- a/gpu/command_buffer/client/mapped_memory.cc
+++ b/gpu/command_buffer/client/mapped_memory.cc
@@ -13,19 +13,22 @@
namespace gpu {
-MemoryChunk::MemoryChunk(
- int32 shm_id, gpu::Buffer shm, CommandBufferHelper* helper)
+MemoryChunk::MemoryChunk(int32 shm_id,
+ gpu::Buffer shm,
+ bool aggressive_reuse,
+ CommandBufferHelper* helper)
: shm_id_(shm_id),
shm_(shm),
- allocator_(shm.size, helper, shm.ptr) {
+ allocator_(shm.size, aggressive_reuse, helper, shm.ptr) {
}
MappedMemoryManager::MappedMemoryManager(CommandBufferHelper* helper,
- size_t unused_memory_reclaim_limit)
+ MappedMemoryManagerSettings settings)
: chunk_size_multiple_(1),
helper_(helper),
allocated_memory_(0),
- max_free_bytes_(unused_memory_reclaim_limit) {
+ max_free_bytes_(settings.unused_memory_reclaim_limit),
+ aggressive_reuse_(settings.aggressive_reuse) {
}
MappedMemoryManager::~MappedMemoryManager() {
@@ -48,7 +51,10 @@ void* MappedMemoryManager::Alloc(
MemoryChunk* chunk = chunks_[ii];
chunk->FreeUnused();
total_bytes_in_use += chunk->bytes_in_use();
- if (chunk->GetLargestFreeSizeWithoutWaiting() >= size) {
+ unsigned int largest_size =
+ aggressive_reuse_ ? chunk->GetLargestFreeSizeWithWaiting()
+ : chunk->GetLargestFreeSizeWithoutWaiting();
+ if (largest_size >= size) {
void* mem = chunk->Alloc(size);
DCHECK(mem);
*shm_id = chunk->shm_id();
@@ -60,7 +66,7 @@ void* MappedMemoryManager::Alloc(
// If there is a memory limit being enforced and total free
// memory (allocated_memory_ - total_bytes_in_use) is larger than
// the limit try waiting.
- if (max_free_bytes_ != kNoLimit &&
+ if (!aggressive_reuse_ && max_free_bytes_ != kNoLimit &&
(allocated_memory_ - total_bytes_in_use) >= max_free_bytes_) {
TRACE_EVENT0("gpu", "MappedMemoryManager::Alloc::wait");
for (size_t ii = 0; ii < chunks_.size(); ++ii) {
@@ -85,7 +91,7 @@ void* MappedMemoryManager::Alloc(
gpu::Buffer shm = cmd_buf->CreateTransferBuffer(chunk_size, &id);
if (id < 0)
return NULL;
- MemoryChunk* mc = new MemoryChunk(id, shm, helper_);
+ MemoryChunk* mc = new MemoryChunk(id, shm, aggressive_reuse_, helper_);
allocated_memory_ += mc->GetSize();
chunks_.push_back(mc);
void* mem = mc->Alloc(size);
« gpu/command_buffer/client/fenced_allocator.h ('K') | « gpu/command_buffer/client/mapped_memory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698