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

Unified Diff: net/disk_cache/simple/simple_entry_impl.cc

Issue 2815563002: Avoid cross thread malloc / free pair of IOBuffer on the simple cache (Closed)
Patch Set: Created 3 years, 8 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
Index: net/disk_cache/simple/simple_entry_impl.cc
diff --git a/net/disk_cache/simple/simple_entry_impl.cc b/net/disk_cache/simple/simple_entry_impl.cc
index 2b354cd0f68043a93b4f70956991a7261a2e422b..6b37d3e6ea868bc0af9fe745b8e80cbdac85e4a6 100644
--- a/net/disk_cache/simple/simple_entry_impl.cc
+++ b/net/disk_cache/simple/simple_entry_impl.cc
@@ -973,17 +973,18 @@ void SimpleEntryImpl::WriteDataInternal(int stream_index,
have_written_[0] = true;
std::unique_ptr<int> result(new int());
+
+ // Retain a reference to |buf| in |reply| instead of |task|, so that we can
+ // reduce cross thread malloc/free pairs. The cross thread malloc/free pair
+ // increases the apparent memory usage due to the thread cached free list.
Closure task = base::Bind(
&SimpleSynchronousEntry::WriteData, base::Unretained(synchronous_entry_),
SimpleSynchronousEntry::EntryOperationData(stream_index, offset, buf_len,
truncate, doomed_),
- base::RetainedRef(buf), entry_stat.get(), result.get());
- Closure reply = base::Bind(&SimpleEntryImpl::WriteOperationComplete,
- this,
- stream_index,
- callback,
- base::Passed(&entry_stat),
- base::Passed(&result));
+ base::Unretained(buf), entry_stat.get(), result.get());
+ Closure reply = base::Bind(&SimpleEntryImpl::WriteOperationComplete, this,
+ stream_index, callback, base::Passed(&entry_stat),
+ base::Passed(&result), base::RetainedRef(buf));
worker_pool_->PostTaskAndReply(FROM_HERE, task, reply);
}
@@ -1271,7 +1272,8 @@ void SimpleEntryImpl::WriteOperationComplete(
int stream_index,
const CompletionCallback& completion_callback,
std::unique_ptr<SimpleEntryStat> entry_stat,
- std::unique_ptr<int> result) {
+ std::unique_ptr<int> result,
+ net::IOBuffer* buf) {
if (*result >= 0)
RecordWriteResult(cache_type_, WRITE_RESULT_SUCCESS);
else
« net/disk_cache/simple/simple_entry_impl.h ('K') | « net/disk_cache/simple/simple_entry_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698