Chromium Code Reviews| Index: net/disk_cache/backend_impl.cc |
| =================================================================== |
| --- net/disk_cache/backend_impl.cc (revision 97896) |
| +++ net/disk_cache/backend_impl.cc (working copy) |
| @@ -47,6 +47,9 @@ |
| const int kBaseTableLen = 64 * 1024; |
| const int kDefaultCacheSize = 80 * 1024 * 1024; |
| +// Avoid trimming the cache for the first 5 minutes (10 timer ticks). |
| +const int kTrimDelay = 10; |
|
gavinp
2011/08/31 03:01:20
I'm also made a bit grumpy that these are in multi
rvargas (doing something else)
2011/08/31 18:06:35
I see your point, but right now 30 seconds is kind
|
| + |
| int DesiredIndexTableLen(int32 storage_size) { |
| if (storage_size <= k64kEntriesStore) |
| return kBaseTableLen; |
| @@ -366,7 +369,7 @@ |
| block_files_(path), |
| mask_(0), |
| max_size_(0), |
| - io_delay_(0), |
| + up_ticks_(0), |
| cache_type_(net::DISK_CACHE), |
| uma_report_(0), |
| user_flags_(0), |
| @@ -392,7 +395,7 @@ |
| block_files_(path), |
| mask_(mask), |
| max_size_(0), |
| - io_delay_(0), |
| + up_ticks_(0), |
| cache_type_(net::DISK_CACHE), |
| uma_report_(0), |
| user_flags_(kMask), |
| @@ -975,7 +978,8 @@ |
| void BackendImpl::OnEntryDestroyEnd() { |
| DecreaseNumRefs(); |
| - if (data_->header.num_bytes > max_size_ && !read_only_) |
| + if (data_->header.num_bytes > max_size_ && !read_only_ && |
| + (up_ticks_ > kTrimDelay || user_flags_ & disk_cache::kNoRandom)) |
| eviction_.TrimCache(false); |
| } |
| @@ -1190,6 +1194,8 @@ |
| CACHE_UMA(COUNTS, "ByteIORate", 0, byte_count_ / 1024); |
| entry_count_ = 0; |
| byte_count_ = 0; |
| + if (up_ticks_ < kTrimDelay * 2) // No need to count forever. |
|
gavinp
2011/08/31 02:20:32
Nit: Why not count forever? Seems easier and less
rvargas (doing something else)
2011/08/31 02:33:19
Not easier because then I would have to either cla
gavinp
2011/08/31 03:01:20
I'm not convinced a clamp is necessary, because if
rvargas (doing something else)
2011/08/31 18:06:35
Convinced. Clamp gone.
|
| + up_ticks_++; |
| if (!data_) |
| first_timer_ = false; |