Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/disk_cache/backend_impl.h" | 5 #include "net/disk_cache/backend_impl.h" |
| 6 | 6 |
| 7 #include "base/field_trial.h" | 7 #include "base/field_trial.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
| (...skipping 1701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1712 StatsItems stats; | 1712 StatsItems stats; |
| 1713 GetStats(&stats); | 1713 GetStats(&stats); |
| 1714 | 1714 |
| 1715 for (size_t index = 0; index < stats.size(); index++) { | 1715 for (size_t index = 0; index < stats.size(); index++) { |
| 1716 LOG(INFO) << stats[index].first << ": " << stats[index].second; | 1716 LOG(INFO) << stats[index].first << ": " << stats[index].second; |
| 1717 } | 1717 } |
| 1718 } | 1718 } |
| 1719 | 1719 |
| 1720 void BackendImpl::ReportStats() { | 1720 void BackendImpl::ReportStats() { |
| 1721 CACHE_UMA(COUNTS, "Entries", 0, data_->header.num_entries); | 1721 CACHE_UMA(COUNTS, "Entries", 0, data_->header.num_entries); |
| 1722 CACHE_UMA(COUNTS, "Size", 0, data_->header.num_bytes / (1024 * 1024)); | 1722 CACHE_UMA(COUNTS_10000, "Size2", 0, data_->header.num_bytes / (1024 * 1024)); |
|
nsylvain
2010/07/15 05:47:04
What is COUNTS_10000 ?
rvargas (doing something else)
2010/07/15 18:31:50
Counts adjust the scale from 0 to 1 million. count
| |
| 1723 CACHE_UMA(COUNTS, "MaxSize", 0, max_size_ / (1024 * 1024)); | 1723 CACHE_UMA(COUNTS_10000, "MaxSize2", 0, max_size_ / (1024 * 1024)); |
| 1724 | 1724 |
| 1725 CACHE_UMA(COUNTS, "AverageOpenEntries", 0, | 1725 CACHE_UMA(COUNTS_10000, "AverageOpenEntries2", 0, |
| 1726 static_cast<int>(stats_.GetCounter(Stats::OPEN_ENTRIES))); | 1726 static_cast<int>(stats_.GetCounter(Stats::OPEN_ENTRIES))); |
| 1727 CACHE_UMA(COUNTS, "MaxOpenEntries", 0, | 1727 CACHE_UMA(COUNTS_10000, "MaxOpenEntries2", 0, |
| 1728 static_cast<int>(stats_.GetCounter(Stats::MAX_ENTRIES))); | 1728 static_cast<int>(stats_.GetCounter(Stats::MAX_ENTRIES))); |
| 1729 stats_.SetCounter(Stats::MAX_ENTRIES, 0); | 1729 stats_.SetCounter(Stats::MAX_ENTRIES, 0); |
| 1730 | 1730 |
| 1731 if (!data_->header.create_time || !data_->header.lru.filled) | 1731 if (!data_->header.create_time || !data_->header.lru.filled) |
| 1732 return; | 1732 return; |
| 1733 | 1733 |
| 1734 // This is an up to date client that will report FirstEviction() data. After | 1734 // This is an up to date client that will report FirstEviction() data. After |
| 1735 // that event, start reporting this: | 1735 // that event, start reporting this: |
| 1736 | 1736 |
| 1737 int64 total_hours = stats_.GetCounter(Stats::TIMER) / 120; | 1737 int64 total_hours = stats_.GetCounter(Stats::TIMER) / 120; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1749 return; | 1749 return; |
| 1750 | 1750 |
| 1751 CACHE_UMA(HOURS, "UseTime", 0, static_cast<int>(use_hours)); | 1751 CACHE_UMA(HOURS, "UseTime", 0, static_cast<int>(use_hours)); |
| 1752 CACHE_UMA(PERCENTAGE, "HitRatio", 0, stats_.GetHitRatio()); | 1752 CACHE_UMA(PERCENTAGE, "HitRatio", 0, stats_.GetHitRatio()); |
| 1753 | 1753 |
| 1754 int64 trim_rate = stats_.GetCounter(Stats::TRIM_ENTRY) / use_hours; | 1754 int64 trim_rate = stats_.GetCounter(Stats::TRIM_ENTRY) / use_hours; |
| 1755 CACHE_UMA(COUNTS, "TrimRate", 0, static_cast<int>(trim_rate)); | 1755 CACHE_UMA(COUNTS, "TrimRate", 0, static_cast<int>(trim_rate)); |
| 1756 | 1756 |
| 1757 int avg_size = data_->header.num_bytes / GetEntryCount(); | 1757 int avg_size = data_->header.num_bytes / GetEntryCount(); |
| 1758 CACHE_UMA(COUNTS, "EntrySize", 0, avg_size); | 1758 CACHE_UMA(COUNTS, "EntrySize", 0, avg_size); |
| 1759 CACHE_UMA(COUNTS, "EntriesFull", 0, data_->header.num_entries); | |
| 1759 | 1760 |
| 1760 CACHE_UMA(PERCENTAGE, "IndexLoad", 0, | 1761 CACHE_UMA(PERCENTAGE, "IndexLoad", 0, |
| 1761 data_->header.num_entries * 100 / (mask_ + 1)); | 1762 data_->header.num_entries * 100 / (mask_ + 1)); |
| 1762 | 1763 |
| 1763 int large_entries_bytes = stats_.GetLargeEntriesSize(); | 1764 int large_entries_bytes = stats_.GetLargeEntriesSize(); |
| 1764 int large_ratio = large_entries_bytes * 100 / data_->header.num_bytes; | 1765 int large_ratio = large_entries_bytes * 100 / data_->header.num_bytes; |
| 1765 CACHE_UMA(PERCENTAGE, "LargeEntriesRatio", 0, large_ratio); | 1766 CACHE_UMA(PERCENTAGE, "LargeEntriesRatio", 0, large_ratio); |
| 1766 | 1767 |
| 1767 if (new_eviction_) { | 1768 if (new_eviction_) { |
| 1768 CACHE_UMA(PERCENTAGE, "ResurrectRatio", 0, stats_.GetResurrectRatio()); | 1769 CACHE_UMA(PERCENTAGE, "ResurrectRatio", 0, stats_.GetResurrectRatio()); |
| 1769 CACHE_UMA(PERCENTAGE, "NoUseRatio", 0, | 1770 CACHE_UMA(PERCENTAGE, "NoUseRatio", 0, |
| 1770 data_->header.lru.sizes[0] * 100 / data_->header.num_entries); | 1771 data_->header.lru.sizes[0] * 100 / data_->header.num_entries); |
| 1771 CACHE_UMA(PERCENTAGE, "LowUseRatio", 0, | 1772 CACHE_UMA(PERCENTAGE, "LowUseRatio", 0, |
| 1772 data_->header.lru.sizes[1] * 100 / data_->header.num_entries); | 1773 data_->header.lru.sizes[1] * 100 / data_->header.num_entries); |
| 1773 CACHE_UMA(PERCENTAGE, "HighUseRatio", 0, | 1774 CACHE_UMA(PERCENTAGE, "HighUseRatio", 0, |
| 1774 data_->header.lru.sizes[2] * 100 / data_->header.num_entries); | 1775 data_->header.lru.sizes[2] * 100 / data_->header.num_entries); |
| 1775 CACHE_UMA(PERCENTAGE, "DeletedRatio", 0, | 1776 CACHE_UMA(PERCENTAGE, "DeletedRatio", 0, |
| 1776 data_->header.lru.sizes[4] * 100 / data_->header.num_entries); | 1777 data_->header.lru.sizes[4] * 100 / data_->header.num_entries); |
| 1777 } | 1778 } |
| 1778 | 1779 |
| 1779 stats_.ResetRatios(); | 1780 stats_.ResetRatios(); |
| 1780 stats_.SetCounter(Stats::TRIM_ENTRY, 0); | 1781 stats_.SetCounter(Stats::TRIM_ENTRY, 0); |
| 1782 | |
| 1783 if (cache_type_ == net::DISK_CACHE) | |
| 1784 block_files_.ReportStats(); | |
| 1781 } | 1785 } |
| 1782 | 1786 |
| 1783 void BackendImpl::UpgradeTo2_1() { | 1787 void BackendImpl::UpgradeTo2_1() { |
| 1784 // 2.1 is basically the same as 2.0, except that new fields are actually | 1788 // 2.1 is basically the same as 2.0, except that new fields are actually |
| 1785 // updated by the new eviction algorithm. | 1789 // updated by the new eviction algorithm. |
| 1786 DCHECK(0x20000 == data_->header.version); | 1790 DCHECK(0x20000 == data_->header.version); |
| 1787 data_->header.version = 0x20001; | 1791 data_->header.version = 0x20001; |
| 1788 data_->header.lru.sizes[Rankings::NO_USE] = data_->header.num_entries; | 1792 data_->header.lru.sizes[Rankings::NO_USE] = data_->header.num_entries; |
| 1789 } | 1793 } |
| 1790 | 1794 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1837 } | 1841 } |
| 1838 | 1842 |
| 1839 if (data_->header.num_entries < 0) { | 1843 if (data_->header.num_entries < 0) { |
| 1840 LOG(ERROR) << "Invalid number of entries"; | 1844 LOG(ERROR) << "Invalid number of entries"; |
| 1841 return false; | 1845 return false; |
| 1842 } | 1846 } |
| 1843 | 1847 |
| 1844 if (!mask_) | 1848 if (!mask_) |
| 1845 mask_ = data_->header.table_len - 1; | 1849 mask_ = data_->header.table_len - 1; |
| 1846 | 1850 |
| 1847 return true; | 1851 // Load the table into memory with a single read. |
| 1852 scoped_array<char> buf(new char[current_size]); | |
| 1853 return index_->Read(buf.get(), current_size, 0); | |
|
nsylvain
2010/07/15 05:47:04
How much does it help? Or is this just an experime
rvargas (doing something else)
2010/07/15 18:31:50
Hard to tell, because it only affects people with
| |
| 1848 } | 1854 } |
| 1849 | 1855 |
| 1850 int BackendImpl::CheckAllEntries() { | 1856 int BackendImpl::CheckAllEntries() { |
| 1851 int num_dirty = 0; | 1857 int num_dirty = 0; |
| 1852 int num_entries = 0; | 1858 int num_entries = 0; |
| 1853 DCHECK(mask_ < kuint32max); | 1859 DCHECK(mask_ < kuint32max); |
| 1854 for (int i = 0; i <= static_cast<int>(mask_); i++) { | 1860 for (int i = 0; i <= static_cast<int>(mask_); i++) { |
| 1855 Addr address(data_->table[i]); | 1861 Addr address(data_->table[i]); |
| 1856 if (!address.is_initialized()) | 1862 if (!address.is_initialized()) |
| 1857 continue; | 1863 continue; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1884 | 1890 |
| 1885 return num_dirty; | 1891 return num_dirty; |
| 1886 } | 1892 } |
| 1887 | 1893 |
| 1888 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) { | 1894 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) { |
| 1889 RankingsNode* rankings = cache_entry->rankings()->Data(); | 1895 RankingsNode* rankings = cache_entry->rankings()->Data(); |
| 1890 return !rankings->dummy; | 1896 return !rankings->dummy; |
| 1891 } | 1897 } |
| 1892 | 1898 |
| 1893 } // namespace disk_cache | 1899 } // namespace disk_cache |
| OLD | NEW |