diff options
Diffstat (limited to 'chromium/net/disk_cache')
21 files changed, 143 insertions, 646 deletions
diff --git a/chromium/net/disk_cache/backend_unittest.cc b/chromium/net/disk_cache/backend_unittest.cc index 8f88d07a799..e64900765eb 100644 --- a/chromium/net/disk_cache/backend_unittest.cc +++ b/chromium/net/disk_cache/backend_unittest.cc @@ -5279,3 +5279,38 @@ TEST_F(DiskCacheBackendTest, SimpleDontLeakPostDoomCreate) { // Should not have leaked files here. } + +TEST_F(DiskCacheBackendTest, BlockFileDelayedWriteFailureRecovery) { + // Test that blockfile recovers appropriately when some entries are + // in a screwed up state due to an error in delayed writeback. + // + // https://crbug.com/1086727 + InitCache(); + + const char kKey[] = "Key2"; + disk_cache::Entry* entry = nullptr; + ASSERT_THAT(CreateEntry(kKey, &entry), IsOk()); + + const int kBufSize = 24320; + scoped_refptr<net::IOBuffer> buffer = + base::MakeRefCounted<net::IOBuffer>(kBufSize); + CacheTestFillBuffer(buffer->data(), kBufSize, true); + + ASSERT_EQ(kBufSize, WriteSparseData(entry, 0, buffer.get(), kBufSize)); + + // Setting the size limit artificially low injects a failure on writing back + // data buffered above. + SetMaxSize(4096); + + // This causes SparseControl to close the child entry corresponding to + // low portion of offset space, triggering the writeback --- which fails + // due to the space cap, and in particular fails to allocate data for + // a stream, so it gets address 0. + ASSERT_EQ(net::ERR_FAILED, WriteSparseData(entry, 16773118, buffer.get(), 4)); + + // Now try reading the broken child. This should report an error, not + // DCHECK. + ASSERT_EQ(net::ERR_FAILED, ReadSparseData(entry, 4, buffer.get(), 4)); + + entry->Close(); +} diff --git a/chromium/net/disk_cache/blockfile/addr.h b/chromium/net/disk_cache/blockfile/addr.h index 32e035eac99..c7a9a2ae614 100644 --- a/chromium/net/disk_cache/blockfile/addr.h +++ b/chromium/net/disk_cache/blockfile/addr.h @@ -11,7 +11,7 @@ #include <stddef.h> #include <stdint.h> -#include "base/logging.h" +#include "base/notreached.h" #include "net/base/net_export.h" #include "net/disk_cache/blockfile/disk_format_base.h" diff --git a/chromium/net/disk_cache/blockfile/entry_impl.cc b/chromium/net/disk_cache/blockfile/entry_impl.cc index 668101caf45..e83e5475851 100644 --- a/chromium/net/disk_cache/blockfile/entry_impl.cc +++ b/chromium/net/disk_cache/blockfile/entry_impl.cc @@ -1064,7 +1064,6 @@ int EntryImpl::InternalReadData(int index, } address.set_value(entry_.Data()->data_addr[index]); - DCHECK(address.is_initialized()); if (!address.is_initialized()) { DoomImpl(); return net::ERR_FAILED; diff --git a/chromium/net/disk_cache/blockfile/in_flight_io.h b/chromium/net/disk_cache/blockfile/in_flight_io.h index 6857d370946..9ab21762baf 100644 --- a/chromium/net/disk_cache/blockfile/in_flight_io.h +++ b/chromium/net/disk_cache/blockfile/in_flight_io.h @@ -7,7 +7,7 @@ #include <set> -#include "base/logging.h" +#include "base/check.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/synchronization/lock.h" diff --git a/chromium/net/disk_cache/blockfile/mapped_file_posix.cc b/chromium/net/disk_cache/blockfile/mapped_file_posix.cc index 99cf49c1890..7921ffdf40f 100644 --- a/chromium/net/disk_cache/blockfile/mapped_file_posix.cc +++ b/chromium/net/disk_cache/blockfile/mapped_file_posix.cc @@ -16,24 +16,24 @@ namespace disk_cache { void* MappedFile::Init(const base::FilePath& name, size_t size) { DCHECK(!init_); if (init_ || !File::Init(name)) - return NULL; + return nullptr; size_t temp_len = size ? size : 4096; if (!size) size = GetLength(); - buffer_ = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, + buffer_ = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, platform_file(), 0); init_ = true; view_size_ = size; DPLOG_IF(FATAL, buffer_ == MAP_FAILED) << "Failed to mmap " << name.value(); if (buffer_ == MAP_FAILED) - buffer_ = 0; + buffer_ = nullptr; // Make sure we detect hardware failures reading the headers. std::unique_ptr<char[]> temp(new char[temp_len]); if (!Read(temp.get(), temp_len, 0)) - return NULL; + return nullptr; return buffer_; } diff --git a/chromium/net/disk_cache/blockfile/stress_support.h b/chromium/net/disk_cache/blockfile/stress_support.h index 2f07de83e0c..b4d3a6be0c6 100644 --- a/chromium/net/disk_cache/blockfile/stress_support.h +++ b/chromium/net/disk_cache/blockfile/stress_support.h @@ -5,7 +5,8 @@ #ifndef NET_DISK_CACHE_BLOCKFILE_STRESS_SUPPORT_H_ #define NET_DISK_CACHE_BLOCKFILE_STRESS_SUPPORT_H_ -#include "base/logging.h" +#include "base/check.h" +#include "base/notreached.h" namespace disk_cache { diff --git a/chromium/net/disk_cache/entry_unittest.cc b/chromium/net/disk_cache/entry_unittest.cc index 1e3226a2642..68b8319898c 100644 --- a/chromium/net/disk_cache/entry_unittest.cc +++ b/chromium/net/disk_cache/entry_unittest.cc @@ -2974,7 +2974,6 @@ bool DiskCacheEntryTest::SimpleCacheMakeBadChecksumEntry(const std::string& key, } TEST_F(DiskCacheEntryTest, SimpleCacheBadChecksum) { - base::HistogramTester histogram_tester; SetSimpleCacheMode(); InitCache(); @@ -2994,14 +2993,10 @@ TEST_F(DiskCacheEntryTest, SimpleCacheBadChecksum) { base::MakeRefCounted<net::IOBuffer>(kLargeSize); EXPECT_EQ(net::ERR_CACHE_CHECKSUM_MISMATCH, ReadData(entry, 1, 0, read_buffer.get(), kLargeSize)); - histogram_tester.ExpectUniqueSample( - "SimpleCache.Http.ReadResult", - disk_cache::READ_RESULT_SYNC_CHECKSUM_FAILURE, 1); } // Tests that an entry that has had an IO error occur can still be Doomed(). TEST_F(DiskCacheEntryTest, SimpleCacheErrorThenDoom) { - base::HistogramTester histogram_tester; SetSimpleCacheMode(); InitCache(); @@ -3020,9 +3015,6 @@ TEST_F(DiskCacheEntryTest, SimpleCacheErrorThenDoom) { base::MakeRefCounted<net::IOBuffer>(kLargeSize); EXPECT_EQ(net::ERR_CACHE_CHECKSUM_MISMATCH, ReadData(entry, 1, 0, read_buffer.get(), kLargeSize)); - histogram_tester.ExpectUniqueSample( - "SimpleCache.Http.ReadResult", - disk_cache::READ_RESULT_SYNC_CHECKSUM_FAILURE, 1); entry->Doom(); // Should not crash. } @@ -5540,22 +5532,17 @@ class DiskCacheSimplePrefetchTest : public DiskCacheEntryTest { } void SetupFullAndTrailerPrefetch(int full_size, - bool trailer_hint, int trailer_speculative_size) { std::map<std::string, std::string> params; params[disk_cache::kSimpleCacheFullPrefetchBytesParam] = base::NumberToString(full_size); - params[disk_cache::kSimpleCacheTrailerPrefetchHintParam] = - trailer_hint ? "true" : "false"; params[disk_cache::kSimpleCacheTrailerPrefetchSpeculativeBytesParam] = base::NumberToString(trailer_speculative_size); scoped_feature_list_.InitAndEnableFeatureWithParameters( disk_cache::kSimpleCachePrefetchExperiment, params); } - void SetupFullPrefetch(int size) { - SetupFullAndTrailerPrefetch(size, false, 0); - } + void SetupFullPrefetch(int size) { SetupFullAndTrailerPrefetch(size, 0); } void InitCacheAndCreateEntry(const std::string& key) { SetSimpleCacheMode(); @@ -5597,12 +5584,21 @@ class DiskCacheSimplePrefetchTest : public DiskCacheEntryTest { entry->Close(); } - void TryRead(const std::string& key) { + void TryRead(const std::string& key, bool expect_preread_stream1) { disk_cache::Entry* entry = nullptr; ASSERT_THAT(OpenEntry(key, &entry), IsOk()); scoped_refptr<net::IOBuffer> read_buf = base::MakeRefCounted<net::IOBuffer>(kEntrySize); - EXPECT_EQ(kEntrySize, ReadData(entry, 1, 0, read_buf.get(), kEntrySize)); + net::TestCompletionCallback cb; + int rv = entry->ReadData(1, 0, read_buf.get(), kEntrySize, cb.callback()); + + // if preload happened, sync reply is expected. + if (expect_preread_stream1) + EXPECT_EQ(kEntrySize, rv); + else + EXPECT_EQ(net::ERR_IO_PENDING, rv); + rv = cb.GetResult(rv); + EXPECT_EQ(kEntrySize, rv); EXPECT_EQ(0, memcmp(read_buf->data(), payload_->data(), kEntrySize)); entry->Close(); } @@ -5618,12 +5614,10 @@ TEST_F(DiskCacheSimplePrefetchTest, NoPrefetch) { const char kKey[] = "a key"; InitCacheAndCreateEntry(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ false); histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncOpenPrefetchMode", disk_cache::OPEN_PREFETCH_NONE, 1); - histogram_tester.ExpectUniqueSample( - "SimpleCache.Http.ReadStream1FromPrefetched", false, 1); } TEST_F(DiskCacheSimplePrefetchTest, YesPrefetch) { @@ -5632,12 +5626,10 @@ TEST_F(DiskCacheSimplePrefetchTest, YesPrefetch) { const char kKey[] = "a key"; InitCacheAndCreateEntry(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ true); histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncOpenPrefetchMode", disk_cache::OPEN_PREFETCH_FULL, 1); - histogram_tester.ExpectUniqueSample( - "SimpleCache.Http.ReadStream1FromPrefetched", true, 1); } TEST_F(DiskCacheSimplePrefetchTest, YesPrefetchNoRead) { @@ -5653,12 +5645,6 @@ TEST_F(DiskCacheSimplePrefetchTest, YesPrefetchNoRead) { histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncOpenPrefetchMode", disk_cache::OPEN_PREFETCH_FULL, 1); - // Have to use GetHistogramSamplesSinceCreation here since it's the only - // API that handles the cases where the histogram hasn't even been created. - std::unique_ptr<base::HistogramSamples> samples( - histogram_tester.GetHistogramSamplesSinceCreation( - "SimpleCache.Http.ReadStream1FromPrefetched")); - EXPECT_EQ(0, samples->TotalCount()); } // This makes sure we detect checksum error on entry that's small enough to be @@ -5685,11 +5671,8 @@ TEST_F(DiskCacheSimplePrefetchTest, ChecksumNoPrefetch) { SetupFullPrefetch(0); const char kKey[] = "a key"; InitCacheAndCreateEntry(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ false); - // Expect 2 CRCs --- stream 0 and stream 1. - histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncCheckEOFHasCrc", - true, 2); histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncCheckEOFResult", disk_cache::CHECK_EOF_RESULT_SUCCESS, 2); } @@ -5700,14 +5683,8 @@ TEST_F(DiskCacheSimplePrefetchTest, NoChecksumNoPrefetch) { SetupFullPrefetch(0); const char kKey[] = "a key"; InitCacheAndCreateEntryWithNoCrc(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ false); - // Stream 0 has CRC, stream 1 doesn't. - histogram_tester.ExpectBucketCount("SimpleCache.Http.SyncCheckEOFHasCrc", - true, 1); - histogram_tester.ExpectBucketCount("SimpleCache.Http.SyncCheckEOFHasCrc", - false, 1); - // EOF check is recorded even if there is no CRC there. histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncCheckEOFResult", disk_cache::CHECK_EOF_RESULT_SUCCESS, 2); } @@ -5718,11 +5695,8 @@ TEST_F(DiskCacheSimplePrefetchTest, ChecksumPrefetch) { SetupFullPrefetch(2 * kEntrySize); const char kKey[] = "a key"; InitCacheAndCreateEntry(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ true); - // Expect 2 CRCs --- stream 0 and stream 1. - histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncCheckEOFHasCrc", - true, 2); histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncCheckEOFResult", disk_cache::CHECK_EOF_RESULT_SUCCESS, 2); } @@ -5733,13 +5707,8 @@ TEST_F(DiskCacheSimplePrefetchTest, NoChecksumPrefetch) { SetupFullPrefetch(2 * kEntrySize); const char kKey[] = "a key"; InitCacheAndCreateEntryWithNoCrc(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ true); - // Stream 0 has CRC, stream 1 doesn't. - histogram_tester.ExpectBucketCount("SimpleCache.Http.SyncCheckEOFHasCrc", - true, 1); - histogram_tester.ExpectBucketCount("SimpleCache.Http.SyncCheckEOFHasCrc", - false, 1); // EOF check is recorded even if there is no CRC there. histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncCheckEOFResult", disk_cache::CHECK_EOF_RESULT_SUCCESS, 2); @@ -5765,240 +5734,119 @@ TEST_F(DiskCacheSimplePrefetchTest, PrefetchReadsSync) { entry->Close(); } -TEST_F(DiskCacheSimplePrefetchTest, NoFullNoHintNoSpeculative) { - base::HistogramTester histogram_tester; - SetupFullAndTrailerPrefetch(0, false, 0); - - const char kKey[] = "a key"; - InitCacheAndCreateEntry(kKey); - TryRead(kKey); - - histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncOpenPrefetchMode", - disk_cache::OPEN_PREFETCH_NONE, 1); - histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerPrefetchSize", - 0); - histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerSize", 1); - histogram_tester.ExpectTotalCount( - "SimpleCache.Http.EntryTrailerPrefetchDelta", 0); - histogram_tester.ExpectUniqueSample( - "SimpleCache.Http.ReadStream1FromPrefetched", false, 1); -} - -TEST_F(DiskCacheSimplePrefetchTest, NoFullYesHintNoSpeculative) { +TEST_F(DiskCacheSimplePrefetchTest, NoFullNoSpeculative) { base::HistogramTester histogram_tester; - // Trailer prefetch hint should do nothing outside of APP_CACHE mode. - SetupFullAndTrailerPrefetch(0, true, 0); + SetupFullAndTrailerPrefetch(0, 0); const char kKey[] = "a key"; InitCacheAndCreateEntry(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ false); histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncOpenPrefetchMode", disk_cache::OPEN_PREFETCH_NONE, 1); histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerPrefetchSize", 0); - histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerSize", 1); histogram_tester.ExpectTotalCount( "SimpleCache.Http.EntryTrailerPrefetchDelta", 0); - histogram_tester.ExpectUniqueSample( - "SimpleCache.Http.ReadStream1FromPrefetched", false, 1); } -TEST_F(DiskCacheSimplePrefetchTest, NoFullNoHintSmallSpeculative) { +TEST_F(DiskCacheSimplePrefetchTest, NoFullSmallSpeculative) { base::HistogramTester histogram_tester; - SetupFullAndTrailerPrefetch(0, false, kEntrySize / 2); + SetupFullAndTrailerPrefetch(0, kEntrySize / 2); const char kKey[] = "a key"; InitCacheAndCreateEntry(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ false); histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncOpenPrefetchMode", disk_cache::OPEN_PREFETCH_TRAILER, 1); histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerPrefetchSize", 1); - histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerSize", 1); histogram_tester.ExpectTotalCount( "SimpleCache.Http.EntryTrailerPrefetchDelta", 1); - histogram_tester.ExpectUniqueSample( - "SimpleCache.Http.ReadStream1FromPrefetched", false, 1); } -TEST_F(DiskCacheSimplePrefetchTest, NoFullNoHintLargeSpeculative) { +TEST_F(DiskCacheSimplePrefetchTest, NoFullLargeSpeculative) { base::HistogramTester histogram_tester; // A large speculative trailer prefetch that exceeds the entry file // size should effectively trigger full prefetch behavior. - SetupFullAndTrailerPrefetch(0, false, kEntrySize * 2); + SetupFullAndTrailerPrefetch(0, kEntrySize * 2); const char kKey[] = "a key"; InitCacheAndCreateEntry(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ true); histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncOpenPrefetchMode", disk_cache::OPEN_PREFETCH_FULL, 1); histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerPrefetchSize", 0); - histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerSize", 1); histogram_tester.ExpectTotalCount( "SimpleCache.Http.EntryTrailerPrefetchDelta", 0); - histogram_tester.ExpectUniqueSample( - "SimpleCache.Http.ReadStream1FromPrefetched", true, 1); } -TEST_F(DiskCacheSimplePrefetchTest, NoFullYesHintSmallSpeculative) { +TEST_F(DiskCacheSimplePrefetchTest, SmallFullNoSpeculative) { base::HistogramTester histogram_tester; - // Trailer prefetch hint should do nothing outside of APP_CACHE mode. - SetupFullAndTrailerPrefetch(0, true, kEntrySize / 2); + SetupFullAndTrailerPrefetch(kEntrySize / 2, 0); const char kKey[] = "a key"; InitCacheAndCreateEntry(kKey); - TryRead(kKey); - - histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncOpenPrefetchMode", - disk_cache::OPEN_PREFETCH_TRAILER, 1); - histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerPrefetchSize", - 1); - histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerSize", 1); - histogram_tester.ExpectTotalCount( - "SimpleCache.Http.EntryTrailerPrefetchDelta", 1); - histogram_tester.ExpectUniqueSample( - "SimpleCache.Http.ReadStream1FromPrefetched", false, 1); -} - -TEST_F(DiskCacheSimplePrefetchTest, NoFullYesHintLargeSpeculative) { - base::HistogramTester histogram_tester; - // Trailer prefetch hint should do nothing outside of APP_CACHE mode. - SetupFullAndTrailerPrefetch(0, true, kEntrySize * 2); - - const char kKey[] = "a key"; - InitCacheAndCreateEntry(kKey); - TryRead(kKey); - - histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncOpenPrefetchMode", - disk_cache::OPEN_PREFETCH_FULL, 1); - histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerPrefetchSize", - 0); - histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerSize", 1); - histogram_tester.ExpectTotalCount( - "SimpleCache.Http.EntryTrailerPrefetchDelta", 0); - histogram_tester.ExpectUniqueSample( - "SimpleCache.Http.ReadStream1FromPrefetched", true, 1); -} - -TEST_F(DiskCacheSimplePrefetchTest, SmallFullNoHintNoSpeculative) { - base::HistogramTester histogram_tester; - SetupFullAndTrailerPrefetch(kEntrySize / 2, false, 0); - - const char kKey[] = "a key"; - InitCacheAndCreateEntry(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ false); histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncOpenPrefetchMode", disk_cache::OPEN_PREFETCH_NONE, 1); histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerPrefetchSize", 0); - histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerSize", 1); histogram_tester.ExpectTotalCount( "SimpleCache.Http.EntryTrailerPrefetchDelta", 0); - histogram_tester.ExpectUniqueSample( - "SimpleCache.Http.ReadStream1FromPrefetched", false, 1); } -TEST_F(DiskCacheSimplePrefetchTest, LargeFullNoHintNoSpeculative) { +TEST_F(DiskCacheSimplePrefetchTest, LargeFullNoSpeculative) { base::HistogramTester histogram_tester; - SetupFullAndTrailerPrefetch(kEntrySize * 2, false, 0); + SetupFullAndTrailerPrefetch(kEntrySize * 2, 0); const char kKey[] = "a key"; InitCacheAndCreateEntry(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ true); histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncOpenPrefetchMode", disk_cache::OPEN_PREFETCH_FULL, 1); histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerPrefetchSize", 0); - histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerSize", 1); histogram_tester.ExpectTotalCount( "SimpleCache.Http.EntryTrailerPrefetchDelta", 0); - histogram_tester.ExpectUniqueSample( - "SimpleCache.Http.ReadStream1FromPrefetched", true, 1); } -TEST_F(DiskCacheSimplePrefetchTest, SmallFullYesHintNoSpeculative) { +TEST_F(DiskCacheSimplePrefetchTest, SmallFullSmallSpeculative) { base::HistogramTester histogram_tester; - // Trailer prefetch hint should do nothing outside of APP_CACHE mode. - SetupFullAndTrailerPrefetch(kEntrySize / 2, true, 0); + SetupFullAndTrailerPrefetch(kEntrySize / 2, kEntrySize / 2); const char kKey[] = "a key"; InitCacheAndCreateEntry(kKey); - TryRead(kKey); - - histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncOpenPrefetchMode", - disk_cache::OPEN_PREFETCH_NONE, 1); - histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerPrefetchSize", - 0); - histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerSize", 1); - histogram_tester.ExpectTotalCount( - "SimpleCache.Http.EntryTrailerPrefetchDelta", 0); - histogram_tester.ExpectUniqueSample( - "SimpleCache.Http.ReadStream1FromPrefetched", false, 1); -} - -TEST_F(DiskCacheSimplePrefetchTest, LargeFullYesHintNoSpeculative) { - base::HistogramTester histogram_tester; - // Trailer prefetch hint should do nothing outside of APP_CACHE mode. - SetupFullAndTrailerPrefetch(kEntrySize * 2, true, 0); - - const char kKey[] = "a key"; - InitCacheAndCreateEntry(kKey); - TryRead(kKey); - - histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncOpenPrefetchMode", - disk_cache::OPEN_PREFETCH_FULL, 1); - histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerPrefetchSize", - 0); - histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerSize", 1); - histogram_tester.ExpectTotalCount( - "SimpleCache.Http.EntryTrailerPrefetchDelta", 0); - histogram_tester.ExpectUniqueSample( - "SimpleCache.Http.ReadStream1FromPrefetched", true, 1); -} - -TEST_F(DiskCacheSimplePrefetchTest, SmallFullNoHintSmallSpeculative) { - base::HistogramTester histogram_tester; - SetupFullAndTrailerPrefetch(kEntrySize / 2, false, kEntrySize / 2); - - const char kKey[] = "a key"; - InitCacheAndCreateEntry(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ false); histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncOpenPrefetchMode", disk_cache::OPEN_PREFETCH_TRAILER, 1); histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerPrefetchSize", 1); - histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerSize", 1); histogram_tester.ExpectTotalCount( "SimpleCache.Http.EntryTrailerPrefetchDelta", 1); - histogram_tester.ExpectUniqueSample( - "SimpleCache.Http.ReadStream1FromPrefetched", false, 1); } -TEST_F(DiskCacheSimplePrefetchTest, LargeFullNoHintSmallSpeculative) { +TEST_F(DiskCacheSimplePrefetchTest, LargeFullSmallSpeculative) { base::HistogramTester histogram_tester; // Full prefetch takes precedence over a trailer speculative prefetch. - SetupFullAndTrailerPrefetch(kEntrySize * 2, false, kEntrySize / 2); + SetupFullAndTrailerPrefetch(kEntrySize * 2, kEntrySize / 2); const char kKey[] = "a key"; InitCacheAndCreateEntry(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ true); histogram_tester.ExpectUniqueSample("SimpleCache.Http.SyncOpenPrefetchMode", disk_cache::OPEN_PREFETCH_FULL, 1); histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerPrefetchSize", 0); - histogram_tester.ExpectTotalCount("SimpleCache.Http.EntryTrailerSize", 1); histogram_tester.ExpectTotalCount( "SimpleCache.Http.EntryTrailerPrefetchDelta", 0); - histogram_tester.ExpectUniqueSample( - "SimpleCache.Http.ReadStream1FromPrefetched", true, 1); } class DiskCacheSimpleAppCachePrefetchTest : public DiskCacheSimplePrefetchTest { @@ -6007,237 +5855,119 @@ class DiskCacheSimpleAppCachePrefetchTest : public DiskCacheSimplePrefetchTest { net::CacheType SimpleCacheType() const override { return net::APP_CACHE; } }; -TEST_F(DiskCacheSimpleAppCachePrefetchTest, NoFullNoHintNoSpeculative) { +TEST_F(DiskCacheSimpleAppCachePrefetchTest, NoFullNoSpeculative) { base::HistogramTester histogram_tester; - SetupFullAndTrailerPrefetch(0, false, 0); + SetupFullAndTrailerPrefetch(0, 0); const char kKey[] = "a key"; InitCacheAndCreateEntry(kKey); - TryRead(kKey); - - histogram_tester.ExpectUniqueSample("SimpleCache.App.SyncOpenPrefetchMode", - disk_cache::OPEN_PREFETCH_NONE, 1); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchSize", - 0); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerSize", 1); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchDelta", - 0); - histogram_tester.ExpectUniqueSample( - "SimpleCache.App.ReadStream1FromPrefetched", false, 1); -} - -TEST_F(DiskCacheSimpleAppCachePrefetchTest, NoFullYesHintNoSpeculative) { - base::HistogramTester histogram_tester; - SetupFullAndTrailerPrefetch(0, true, 0); - - const char kKey[] = "a key"; - InitCacheAndCreateEntry(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ false); histogram_tester.ExpectUniqueSample("SimpleCache.App.SyncOpenPrefetchMode", disk_cache::OPEN_PREFETCH_TRAILER, 1); histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchSize", 1); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerSize", 1); histogram_tester.ExpectUniqueSample( "SimpleCache.App.EntryTrailerPrefetchDelta", 0, 1); - histogram_tester.ExpectUniqueSample( - "SimpleCache.App.ReadStream1FromPrefetched", false, 1); -} - -TEST_F(DiskCacheSimpleAppCachePrefetchTest, NoFullNoHintSmallSpeculative) { - base::HistogramTester histogram_tester; - SetupFullAndTrailerPrefetch(0, false, kEntrySize / 2); - - const char kKey[] = "a key"; - InitCacheAndCreateEntry(kKey); - TryRead(kKey); - - histogram_tester.ExpectUniqueSample("SimpleCache.App.SyncOpenPrefetchMode", - disk_cache::OPEN_PREFETCH_TRAILER, 1); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchSize", - 1); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerSize", 1); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchDelta", - 1); - histogram_tester.ExpectUniqueSample( - "SimpleCache.App.ReadStream1FromPrefetched", false, 1); -} - -TEST_F(DiskCacheSimpleAppCachePrefetchTest, NoFullNoHintLargeSpeculative) { - base::HistogramTester histogram_tester; - // A large speculative trailer prefetch that exceeds the entry file - // size should effectively trigger full prefetch behavior. - SetupFullAndTrailerPrefetch(0, false, kEntrySize * 2); - - const char kKey[] = "a key"; - InitCacheAndCreateEntry(kKey); - TryRead(kKey); - - histogram_tester.ExpectUniqueSample("SimpleCache.App.SyncOpenPrefetchMode", - disk_cache::OPEN_PREFETCH_FULL, 1); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchSize", - 0); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerSize", 1); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchDelta", - 0); - histogram_tester.ExpectUniqueSample( - "SimpleCache.App.ReadStream1FromPrefetched", true, 1); } -TEST_F(DiskCacheSimpleAppCachePrefetchTest, NoFullYesHintSmallSpeculative) { +TEST_F(DiskCacheSimpleAppCachePrefetchTest, NoFullSmallSpeculative) { base::HistogramTester histogram_tester; - SetupFullAndTrailerPrefetch(0, true, kEntrySize / 2); + SetupFullAndTrailerPrefetch(0, kEntrySize / 2); const char kKey[] = "a key"; InitCacheAndCreateEntry(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ false); histogram_tester.ExpectUniqueSample("SimpleCache.App.SyncOpenPrefetchMode", disk_cache::OPEN_PREFETCH_TRAILER, 1); histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchSize", 1); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerSize", 1); histogram_tester.ExpectUniqueSample( "SimpleCache.App.EntryTrailerPrefetchDelta", 0, 1); - histogram_tester.ExpectUniqueSample( - "SimpleCache.App.ReadStream1FromPrefetched", false, 1); } -TEST_F(DiskCacheSimpleAppCachePrefetchTest, NoFullYesHintLargeSpeculative) { +TEST_F(DiskCacheSimpleAppCachePrefetchTest, NoFullLargeSpeculative) { base::HistogramTester histogram_tester; // Even though the speculative trailer prefetch size is larger than the // file size, the hint should take precedence and still perform a limited // trailer prefetch. - SetupFullAndTrailerPrefetch(0, true, kEntrySize * 2); + SetupFullAndTrailerPrefetch(0, kEntrySize * 2); const char kKey[] = "a key"; InitCacheAndCreateEntry(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ false); histogram_tester.ExpectUniqueSample("SimpleCache.App.SyncOpenPrefetchMode", disk_cache::OPEN_PREFETCH_TRAILER, 1); histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchSize", 1); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerSize", 1); histogram_tester.ExpectUniqueSample( "SimpleCache.App.EntryTrailerPrefetchDelta", 0, 1); - histogram_tester.ExpectUniqueSample( - "SimpleCache.App.ReadStream1FromPrefetched", false, 1); } -TEST_F(DiskCacheSimpleAppCachePrefetchTest, SmallFullNoHintNoSpeculative) { +TEST_F(DiskCacheSimpleAppCachePrefetchTest, SmallFullNoSpeculative) { base::HistogramTester histogram_tester; - SetupFullAndTrailerPrefetch(kEntrySize / 2, false, 0); + SetupFullAndTrailerPrefetch(kEntrySize / 2, 0); const char kKey[] = "a key"; InitCacheAndCreateEntry(kKey); - TryRead(kKey); - - histogram_tester.ExpectUniqueSample("SimpleCache.App.SyncOpenPrefetchMode", - disk_cache::OPEN_PREFETCH_NONE, 1); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchSize", - 0); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerSize", 1); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchDelta", - 0); - histogram_tester.ExpectUniqueSample( - "SimpleCache.App.ReadStream1FromPrefetched", false, 1); -} - -TEST_F(DiskCacheSimpleAppCachePrefetchTest, LargeFullNoHintNoSpeculative) { - base::HistogramTester histogram_tester; - SetupFullAndTrailerPrefetch(kEntrySize * 2, false, 0); - - const char kKey[] = "a key"; - InitCacheAndCreateEntry(kKey); - TryRead(kKey); - - histogram_tester.ExpectUniqueSample("SimpleCache.App.SyncOpenPrefetchMode", - disk_cache::OPEN_PREFETCH_FULL, 1); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchSize", - 0); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerSize", 1); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchDelta", - 0); - histogram_tester.ExpectUniqueSample( - "SimpleCache.App.ReadStream1FromPrefetched", true, 1); -} - -TEST_F(DiskCacheSimpleAppCachePrefetchTest, SmallFullYesHintNoSpeculative) { - base::HistogramTester histogram_tester; - SetupFullAndTrailerPrefetch(kEntrySize / 2, true, 0); - - const char kKey[] = "a key"; - InitCacheAndCreateEntry(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ false); histogram_tester.ExpectUniqueSample("SimpleCache.App.SyncOpenPrefetchMode", disk_cache::OPEN_PREFETCH_TRAILER, 1); histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchSize", 1); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerSize", 1); histogram_tester.ExpectUniqueSample( "SimpleCache.App.EntryTrailerPrefetchDelta", 0, 1); - histogram_tester.ExpectUniqueSample( - "SimpleCache.App.ReadStream1FromPrefetched", false, 1); } -TEST_F(DiskCacheSimpleAppCachePrefetchTest, LargeFullYesHintNoSpeculative) { +TEST_F(DiskCacheSimpleAppCachePrefetchTest, LargeFullNoSpeculative) { base::HistogramTester histogram_tester; // Full prefetch takes precedence over a trailer hint prefetch. - SetupFullAndTrailerPrefetch(kEntrySize * 2, true, 0); + SetupFullAndTrailerPrefetch(kEntrySize * 2, 0); const char kKey[] = "a key"; InitCacheAndCreateEntry(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ true); histogram_tester.ExpectUniqueSample("SimpleCache.App.SyncOpenPrefetchMode", disk_cache::OPEN_PREFETCH_FULL, 1); histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchSize", 0); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerSize", 1); histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchDelta", 0); - histogram_tester.ExpectUniqueSample( - "SimpleCache.App.ReadStream1FromPrefetched", true, 1); } -TEST_F(DiskCacheSimpleAppCachePrefetchTest, SmallFullNoHintSmallSpeculative) { +TEST_F(DiskCacheSimpleAppCachePrefetchTest, SmallFullSmallSpeculative) { base::HistogramTester histogram_tester; - SetupFullAndTrailerPrefetch(kEntrySize / 2, false, kEntrySize / 2); + SetupFullAndTrailerPrefetch(kEntrySize / 2, kEntrySize / 2); const char kKey[] = "a key"; InitCacheAndCreateEntry(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ false); histogram_tester.ExpectUniqueSample("SimpleCache.App.SyncOpenPrefetchMode", disk_cache::OPEN_PREFETCH_TRAILER, 1); histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchSize", 1); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerSize", 1); histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchDelta", 1); - histogram_tester.ExpectUniqueSample( - "SimpleCache.App.ReadStream1FromPrefetched", false, 1); } -TEST_F(DiskCacheSimpleAppCachePrefetchTest, LargeFullNoHintSmallSpeculative) { +TEST_F(DiskCacheSimpleAppCachePrefetchTest, LargeFullSmallSpeculative) { base::HistogramTester histogram_tester; // Full prefetch takes precedence over a trailer speculative prefetch. - SetupFullAndTrailerPrefetch(kEntrySize * 2, false, kEntrySize / 2); + SetupFullAndTrailerPrefetch(kEntrySize * 2, kEntrySize / 2); const char kKey[] = "a key"; InitCacheAndCreateEntry(kKey); - TryRead(kKey); + TryRead(kKey, /* expect_preread_stream1 */ true); histogram_tester.ExpectUniqueSample("SimpleCache.App.SyncOpenPrefetchMode", disk_cache::OPEN_PREFETCH_FULL, 1); histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchSize", 0); - histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerSize", 1); histogram_tester.ExpectTotalCount("SimpleCache.App.EntryTrailerPrefetchDelta", 0); - histogram_tester.ExpectUniqueSample( - "SimpleCache.App.ReadStream1FromPrefetched", true, 1); } diff --git a/chromium/net/disk_cache/memory/mem_backend_impl.cc b/chromium/net/disk_cache/memory/mem_backend_impl.cc index 51a46a0ee29..ea9789f7d49 100644 --- a/chromium/net/disk_cache/memory/mem_backend_impl.cc +++ b/chromium/net/disk_cache/memory/mem_backend_impl.cc @@ -62,6 +62,7 @@ MemBackendImpl::MemBackendImpl(net::NetLog* net_log) current_size_(0), net_log_(net_log), memory_pressure_listener_( + FROM_HERE, base::BindRepeating(&MemBackendImpl::OnMemoryPressure, base::Unretained(this))) {} diff --git a/chromium/net/disk_cache/simple/post_doom_waiter.cc b/chromium/net/disk_cache/simple/post_doom_waiter.cc index 0f355c33462..8814efbfb0e 100644 --- a/chromium/net/disk_cache/simple/post_doom_waiter.cc +++ b/chromium/net/disk_cache/simple/post_doom_waiter.cc @@ -14,8 +14,7 @@ namespace disk_cache { SimplePostDoomWaiter::SimplePostDoomWaiter() {} SimplePostDoomWaiter::SimplePostDoomWaiter(base::OnceClosure to_run_post_doom) - : time_queued(base::TimeTicks::Now()), - run_post_doom(std::move(to_run_post_doom)) {} + : run_post_doom(std::move(to_run_post_doom)) {} SimplePostDoomWaiter::SimplePostDoomWaiter(SimplePostDoomWaiter&& other) = default; @@ -40,12 +39,7 @@ void SimplePostDoomWaiterTable::OnDoomComplete(uint64_t entry_hash) { to_handle_waiters.swap(it->second); entries_pending_doom_.erase(it); - SIMPLE_CACHE_UMA(COUNTS_1000, "NumOpsBlockedByPendingDoom", cache_type_, - to_handle_waiters.size()); - for (SimplePostDoomWaiter& post_doom : to_handle_waiters) { - SIMPLE_CACHE_UMA(TIMES, "QueueLatency.PendingDoom", cache_type_, - (base::TimeTicks::Now() - post_doom.time_queued)); std::move(post_doom.run_post_doom).Run(); } } diff --git a/chromium/net/disk_cache/simple/post_doom_waiter.h b/chromium/net/disk_cache/simple/post_doom_waiter.h index a7b42682ff2..1dff54bde84 100644 --- a/chromium/net/disk_cache/simple/post_doom_waiter.h +++ b/chromium/net/disk_cache/simple/post_doom_waiter.h @@ -19,13 +19,11 @@ namespace disk_cache { struct SimplePostDoomWaiter { SimplePostDoomWaiter(); - // Also initializes |time_queued|. explicit SimplePostDoomWaiter(base::OnceClosure to_run_post_doom); explicit SimplePostDoomWaiter(SimplePostDoomWaiter&& other); ~SimplePostDoomWaiter(); SimplePostDoomWaiter& operator=(SimplePostDoomWaiter&& other); - base::TimeTicks time_queued; base::OnceClosure run_post_doom; }; diff --git a/chromium/net/disk_cache/simple/simple_entry_impl.cc b/chromium/net/disk_cache/simple/simple_entry_impl.cc index 2e3eadcb2d5..5dfa78c1b07 100644 --- a/chromium/net/disk_cache/simple/simple_entry_impl.cc +++ b/chromium/net/disk_cache/simple/simple_entry_impl.cc @@ -45,17 +45,6 @@ namespace { // the cache. const int64_t kMaxSparseDataSizeDivisor = 10; -// Used in histograms, please only add entries at the end. -enum SimpleEntryWriteResult { - SIMPLE_ENTRY_WRITE_RESULT_SUCCESS = 0, - SIMPLE_ENTRY_WRITE_RESULT_INVALID_ARGUMENT = 1, - SIMPLE_ENTRY_WRITE_RESULT_OVER_MAX_SIZE = 2, - SIMPLE_ENTRY_WRITE_RESULT_BAD_STATE = 3, - SIMPLE_ENTRY_WRITE_RESULT_SYNC_WRITE_FAILURE = 4, - SIMPLE_ENTRY_WRITE_RESULT_FAST_EMPTY_RETURN = 5, - SIMPLE_ENTRY_WRITE_RESULT_MAX = 6, -}; - OpenEntryIndexEnum ComputeIndexState(SimpleBackendImpl* backend, uint64_t entry_hash) { if (!backend->index()->initialized()) @@ -71,17 +60,6 @@ void RecordOpenEntryIndexState(net::CacheType cache_type, INDEX_MAX); } -void RecordReadResult(net::CacheType cache_type, SimpleReadResult result) { - SIMPLE_CACHE_UMA(ENUMERATION, - "ReadResult", cache_type, result, READ_RESULT_MAX); -} - -void RecordWriteResult(net::CacheType cache_type, - SimpleEntryWriteResult result) { - SIMPLE_CACHE_UMA(ENUMERATION, "WriteResult2", cache_type, result, - SIMPLE_ENTRY_WRITE_RESULT_MAX); -} - void RecordHeaderSize(net::CacheType cache_type, int size) { SIMPLE_CACHE_UMA(COUNTS_10000, "HeaderSize", cache_type, size); } @@ -426,7 +404,6 @@ int SimpleEntryImpl::ReadData(int stream_index, net::NetLogEventPhase::NONE, net::ERR_INVALID_ARGUMENT); } - RecordReadResult(cache_type_, READ_RESULT_INVALID_ARGUMENT); return net::ERR_INVALID_ARGUMENT; } @@ -469,7 +446,6 @@ int SimpleEntryImpl::WriteData(int stream_index, net_log_, net::NetLogEventType::SIMPLE_CACHE_ENTRY_WRITE_END, net::NetLogEventPhase::NONE, net::ERR_INVALID_ARGUMENT); } - RecordWriteResult(cache_type_, SIMPLE_ENTRY_WRITE_RESULT_INVALID_ARGUMENT); return net::ERR_INVALID_ARGUMENT; } int end_offset; @@ -480,7 +456,6 @@ int SimpleEntryImpl::WriteData(int stream_index, net_log_, net::NetLogEventType::SIMPLE_CACHE_ENTRY_WRITE_END, net::NetLogEventPhase::NONE, net::ERR_FAILED); } - RecordWriteResult(cache_type_, SIMPLE_ENTRY_WRITE_RESULT_OVER_MAX_SIZE); return net::ERR_FAILED; } ScopedOperationRunner operation_runner(this); @@ -853,7 +828,7 @@ void SimpleEntryImpl::OpenEntryInternal( base::OnceClosure task = base::BindOnce( &SimpleSynchronousEntry::OpenEntry, cache_type_, path_, key_, entry_hash_, - start_time, file_tracker_, trailer_prefetch_size, results.get()); + file_tracker_, trailer_prefetch_size, results.get()); base::OnceClosure reply = base::BindOnce( &SimpleEntryImpl::CreationOperationComplete, this, result_state, @@ -897,9 +872,9 @@ void SimpleEntryImpl::CreateEntryInternal( new SimpleEntryCreationResults(SimpleEntryStat( last_used_, last_modified_, data_size_, sparse_data_size_))); - OnceClosure task = base::BindOnce(&SimpleSynchronousEntry::CreateEntry, - cache_type_, path_, key_, entry_hash_, - start_time, file_tracker_, results.get()); + OnceClosure task = + base::BindOnce(&SimpleSynchronousEntry::CreateEntry, cache_type_, path_, + key_, entry_hash_, file_tracker_, results.get()); OnceClosure reply = base::BindOnce( &SimpleEntryImpl::CreationOperationComplete, this, result_state, std::move(callback), start_time, base::Time(), std::move(results), @@ -958,10 +933,10 @@ void SimpleEntryImpl::OpenOrCreateEntryInternal( } } - base::OnceClosure task = base::BindOnce( - &SimpleSynchronousEntry::OpenOrCreateEntry, cache_type_, path_, key_, - entry_hash_, index_state, optimistic_create, start_time, file_tracker_, - trailer_prefetch_size, results.get()); + base::OnceClosure task = + base::BindOnce(&SimpleSynchronousEntry::OpenOrCreateEntry, cache_type_, + path_, key_, entry_hash_, index_state, optimistic_create, + file_tracker_, trailer_prefetch_size, results.get()); base::OnceClosure reply = base::BindOnce( &SimpleEntryImpl::CreationOperationComplete, this, result_state, @@ -1047,7 +1022,6 @@ int SimpleEntryImpl::ReadDataInternal(bool sync_possible, } if (state_ == STATE_FAILURE || state_ == STATE_UNINITIALIZED) { - RecordReadResult(cache_type_, READ_RESULT_BAD_STATE); if (net_log_.IsCapturing()) { NetLogReadWriteComplete(net_log_, net::NetLogEventType::SIMPLE_CACHE_ENTRY_READ_END, @@ -1061,9 +1035,6 @@ int SimpleEntryImpl::ReadDataInternal(bool sync_possible, } DCHECK_EQ(STATE_READY, state_); if (offset >= GetDataSize(stream_index) || offset < 0 || !buf_len) { - RecordReadResult(cache_type_, sync_possible - ? READ_RESULT_NONBLOCK_EMPTY_RETURN - : READ_RESULT_FAST_EMPTY_RETURN); // If there is nothing to read, we bail out before setting state_ to // STATE_IO_PENDING (so ScopedOperationRunner might start us on next op // here). @@ -1081,12 +1052,6 @@ int SimpleEntryImpl::ReadDataInternal(bool sync_possible, // Sometimes we can read in-ram prefetched stream 1 data immediately, too. if (stream_index == 1) { - if (is_initial_stream1_read_) { - SIMPLE_CACHE_UMA(BOOLEAN, "ReadStream1FromPrefetched", cache_type_, - stream_1_prefetch_data_ != nullptr); - } - is_initial_stream1_read_ = false; - if (stream_1_prefetch_data_) { int rv = ReadFromBuffer(stream_1_prefetch_data_.get(), offset, buf_len, buf); @@ -1143,7 +1108,6 @@ void SimpleEntryImpl::WriteDataInternal(int stream_index, } if (state_ == STATE_FAILURE || state_ == STATE_UNINITIALIZED) { - RecordWriteResult(cache_type_, SIMPLE_ENTRY_WRITE_RESULT_BAD_STATE); if (net_log_.IsCapturing()) { NetLogReadWriteComplete( net_log_, net::NetLogEventType::SIMPLE_CACHE_ENTRY_WRITE_END, @@ -1173,8 +1137,6 @@ void SimpleEntryImpl::WriteDataInternal(int stream_index, if (buf_len == 0) { int32_t data_size = data_size_[stream_index]; if (truncate ? (offset == data_size) : (offset <= data_size)) { - RecordWriteResult(cache_type_, - SIMPLE_ENTRY_WRITE_RESULT_FAST_EMPTY_RETURN); if (!callback.is_null()) { base::SequencedTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::BindOnce(std::move(callback), 0)); @@ -1595,7 +1557,7 @@ void SimpleEntryImpl::ReadOperationComplete( crc_check_state_[stream_index] = CRC_CHECK_NOT_DONE; } } - RecordReadResultConsideringChecksum(read_result); + if (net_log_.IsCapturing()) { NetLogReadWriteComplete(net_log_, net::NetLogEventType::SIMPLE_CACHE_ENTRY_READ_END, @@ -1612,11 +1574,6 @@ void SimpleEntryImpl::WriteOperationComplete( std::unique_ptr<SimpleSynchronousEntry::WriteResult> write_result, net::IOBuffer* buf) { int result = write_result->result; - if (result >= 0) - RecordWriteResult(cache_type_, SIMPLE_ENTRY_WRITE_RESULT_SUCCESS); - else - RecordWriteResult(cache_type_, - SIMPLE_ENTRY_WRITE_RESULT_SYNC_WRITE_FAILURE); if (net_log_.IsCapturing()) { NetLogReadWriteComplete(net_log_, net::NetLogEventType::SIMPLE_CACHE_ENTRY_WRITE_END, @@ -1697,24 +1654,6 @@ void SimpleEntryImpl::DoomOperationComplete( } } -void SimpleEntryImpl::RecordReadResultConsideringChecksum( - const std::unique_ptr<SimpleSynchronousEntry::ReadResult>& read_result) - const { - DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - DCHECK(synchronous_entry_); - DCHECK_EQ(STATE_IO_PENDING, state_); - - if (read_result->result >= 0) { - RecordReadResult(cache_type_, READ_RESULT_SUCCESS); - } else { - if (read_result->crc_updated && read_result->crc_performed_verify && - !read_result->crc_verify_ok) - RecordReadResult(cache_type_, READ_RESULT_SYNC_CHECKSUM_FAILURE); - else - RecordReadResult(cache_type_, READ_RESULT_SYNC_READ_FAILURE); - } -} - void SimpleEntryImpl::CloseOperationComplete( std::unique_ptr<SimpleEntryCloseResults> in_results) { DCHECK(!synchronous_entry_); @@ -1771,7 +1710,6 @@ int SimpleEntryImpl::ReadFromBuffer(net::GrowableIOBuffer* in_buf, memcpy(out_buf->data(), in_buf->data() + offset, buf_len); UpdateDataFromEntryStat(SimpleEntryStat(base::Time::Now(), last_modified_, data_size_, sparse_data_size_)); - RecordReadResult(cache_type_, READ_RESULT_SUCCESS); return buf_len; } @@ -1813,7 +1751,6 @@ int SimpleEntryImpl::SetStream0Data(net::IOBuffer* buf, UpdateDataFromEntryStat( SimpleEntryStat(modification_time, modification_time, data_size_, sparse_data_size_)); - RecordWriteResult(cache_type_, SIMPLE_ENTRY_WRITE_RESULT_SUCCESS); return buf_len; } diff --git a/chromium/net/disk_cache/simple/simple_entry_impl.h b/chromium/net/disk_cache/simple/simple_entry_impl.h index ad2d267da97..2d66478bddd 100644 --- a/chromium/net/disk_cache/simple/simple_entry_impl.h +++ b/chromium/net/disk_cache/simple/simple_entry_impl.h @@ -336,10 +336,6 @@ class NET_EXPORT_PRIVATE SimpleEntryImpl : public Entry, State state_to_restore, int result); - void RecordReadResultConsideringChecksum( - const std::unique_ptr<SimpleSynchronousEntry::ReadResult>& read_result) - const; - // Called after completion of an operation, to either incoproprate file info // received from I/O done on the worker pool, or to simply bump the // timestamps. Updates the metadata both in |this| and in the index. @@ -381,7 +377,6 @@ class NET_EXPORT_PRIVATE SimpleEntryImpl : public Entry, const base::FilePath path_; const uint64_t entry_hash_; const bool use_optimistic_operations_; - bool is_initial_stream1_read_ = true; // used for metrics only. std::string key_; // |last_used_|, |last_modified_| and |data_size_| are copied from the diff --git a/chromium/net/disk_cache/simple/simple_histogram_enums.h b/chromium/net/disk_cache/simple/simple_histogram_enums.h index 0fd28b757b7..01cd170e064 100644 --- a/chromium/net/disk_cache/simple/simple_histogram_enums.h +++ b/chromium/net/disk_cache/simple/simple_histogram_enums.h @@ -8,18 +8,6 @@ namespace disk_cache { // Used in histograms, please only add entries at the end. -enum SimpleReadResult { - READ_RESULT_SUCCESS = 0, - READ_RESULT_INVALID_ARGUMENT = 1, - READ_RESULT_NONBLOCK_EMPTY_RETURN = 2, - READ_RESULT_BAD_STATE = 3, - READ_RESULT_FAST_EMPTY_RETURN = 4, - READ_RESULT_SYNC_READ_FAILURE = 5, - READ_RESULT_SYNC_CHECKSUM_FAILURE = 6, - READ_RESULT_MAX = 7, -}; - -// Used in histograms, please only add entries at the end. enum OpenEntryResult { OPEN_ENTRY_SUCCESS = 0, OPEN_ENTRY_PLATFORM_FILE_ERROR = 1, @@ -72,14 +60,6 @@ enum CloseResult { }; // Used in histograms, please only add entries at the end. -enum class KeySHA256Result { - NOT_PRESENT = 0, - MATCHED = 1, - NO_MATCH = 2, - MAX = 3 -}; - -// Used in histograms, please only add entries at the end. enum FileDescriptorLimiterOp { FD_LIMIT_CLOSE_FILE = 0, FD_LIMIT_REOPEN_FILE = 1, diff --git a/chromium/net/disk_cache/simple/simple_index.cc b/chromium/net/disk_cache/simple/simple_index.cc index 0775f57ff5a..7e65f1aad68 100644 --- a/chromium/net/disk_cache/simple/simple_index.cc +++ b/chromium/net/disk_cache/simple/simple_index.cc @@ -58,11 +58,6 @@ static const int kEstimatedEntryOverhead = 512; namespace disk_cache { -const base::Feature - SimpleIndex::kSimpleCacheDisableEvictionSizeHeuristicForCodeCache{ - "SimpleCacheDisableEvictionSizeHeuristicForCodeCache", - base::FEATURE_DISABLED_BY_DEFAULT}; - EntryMetadata::EntryMetadata() : last_used_time_seconds_since_epoch_(0), entry_size_256b_chunks_(0), @@ -422,11 +417,7 @@ void SimpleIndex::StartEvictionIfNeeded() { MEMORY_KB, "Eviction.MaxCacheSizeOnStart2", cache_type_, static_cast<base::HistogramBase::Sample>(max_size_ / kBytesInKb)); - bool use_size_heuristic = true; - if (cache_type_ == net::GENERATED_BYTE_CODE_CACHE) { - use_size_heuristic = !base::FeatureList::IsEnabled( - kSimpleCacheDisableEvictionSizeHeuristicForCodeCache); - } + bool use_size_heuristic = (cache_type_ != net::GENERATED_BYTE_CODE_CACHE); // Flatten for sorting. std::vector<std::pair<uint64_t, const EntrySet::value_type*>> entries; @@ -603,9 +594,6 @@ void SimpleIndex::MergeInitializingSet( if (load_result->flush_required) WriteToDisk(INDEX_WRITE_REASON_STARTUP_MERGE); - SIMPLE_CACHE_UMA(CUSTOM_COUNTS, - "IndexInitializationWaiters", cache_type_, - to_run_when_initialized_.size(), 0, 100, 20); SIMPLE_CACHE_UMA(CUSTOM_COUNTS, "IndexNumEntriesOnInit", cache_type_, entries_set_.size(), 0, 100000, 50); SIMPLE_CACHE_UMA( @@ -656,19 +644,6 @@ void SimpleIndex::WriteToDisk(IndexWriteToDiskReason reason) { SIMPLE_CACHE_UMA(CUSTOM_COUNTS, "IndexNumEntriesOnWrite", cache_type_, entries_set_.size(), 0, 100000, 50); - const base::TimeTicks start = base::TimeTicks::Now(); - if (!last_write_to_disk_.is_null()) { - if (app_on_background_) { - SIMPLE_CACHE_UMA(MEDIUM_TIMES, - "IndexWriteInterval.Background", cache_type_, - start - last_write_to_disk_); - } else { - SIMPLE_CACHE_UMA(MEDIUM_TIMES, - "IndexWriteInterval.Foreground", cache_type_, - start - last_write_to_disk_); - } - } - last_write_to_disk_ = start; base::OnceClosure after_write; if (cleanup_tracker_) { @@ -680,7 +655,7 @@ void SimpleIndex::WriteToDisk(IndexWriteToDiskReason reason) { } index_file_->WriteToDisk(cache_type_, reason, entries_set_, cache_size_, - start, app_on_background_, std::move(after_write)); + std::move(after_write)); } } // namespace disk_cache diff --git a/chromium/net/disk_cache/simple/simple_index.h b/chromium/net/disk_cache/simple/simple_index.h index f8cdd3c102d..8a62fb1d16e 100644 --- a/chromium/net/disk_cache/simple/simple_index.h +++ b/chromium/net/disk_cache/simple/simple_index.h @@ -14,7 +14,6 @@ #include <vector> #include "base/callback.h" -#include "base/feature_list.h" #include "base/files/file_path.h" #include "base/gtest_prod_util.h" #include "base/memory/ref_counted.h" @@ -297,11 +296,6 @@ class NET_EXPORT_PRIVATE SimpleIndex // enforces this. SEQUENCE_CHECKER(sequence_checker_); - // Timestamp of the last time we wrote the index to disk. - // PostponeWritingToDisk() may give up postponing and allow the write if it - // has been a while since last time we wrote. - base::TimeTicks last_write_to_disk_; - base::OneShotTimer write_to_disk_timer_; base::RepeatingClosure write_to_disk_cb_; @@ -312,9 +306,6 @@ class NET_EXPORT_PRIVATE SimpleIndex // background we can write the index much more frequently, to insure fresh // index on next startup. bool app_on_background_ = false; - - static const base::Feature - kSimpleCacheDisableEvictionSizeHeuristicForCodeCache; }; } // namespace disk_cache diff --git a/chromium/net/disk_cache/simple/simple_index_file.cc b/chromium/net/disk_cache/simple/simple_index_file.cc index 9d53a5e90c5..06a0fff535b 100644 --- a/chromium/net/disk_cache/simple/simple_index_file.cc +++ b/chromium/net/disk_cache/simple/simple_index_file.cc @@ -296,9 +296,7 @@ void SimpleIndexFile::SyncWriteToDisk(net::CacheType cache_type, const base::FilePath& cache_directory, const base::FilePath& index_filename, const base::FilePath& temp_index_filename, - std::unique_ptr<base::Pickle> pickle, - const base::TimeTicks& start_time, - bool app_on_background) { + std::unique_ptr<base::Pickle> pickle) { DCHECK_EQ(index_filename.DirName().value(), temp_index_filename.DirName().value()); base::FilePath index_file_directory = temp_index_filename.DirName(); @@ -327,16 +325,6 @@ void SimpleIndexFile::SyncWriteToDisk(net::CacheType cache_type, // Atomically rename the temporary index file to become the real one. if (!base::ReplaceFile(temp_index_filename, index_filename, nullptr)) return; - - if (app_on_background) { - SIMPLE_CACHE_UMA(TIMES, - "IndexWriteToDiskTime.Background", cache_type, - (base::TimeTicks::Now() - start_time)); - } else { - SIMPLE_CACHE_UMA(TIMES, - "IndexWriteToDiskTime.Foreground", cache_type, - (base::TimeTicks::Now() - start_time)); - } } bool SimpleIndexFile::IndexMetadata::CheckIndexMetadata() { @@ -383,17 +371,14 @@ void SimpleIndexFile::WriteToDisk(net::CacheType cache_type, SimpleIndex::IndexWriteToDiskReason reason, const SimpleIndex::EntrySet& entry_set, uint64_t cache_size, - const base::TimeTicks& start, - bool app_on_background, base::OnceClosure callback) { UmaRecordIndexWriteReason(reason, cache_type_); IndexMetadata index_metadata(reason, entry_set.size(), cache_size); std::unique_ptr<base::Pickle> pickle = Serialize(cache_type, index_metadata, entry_set); - base::OnceClosure task = - base::BindOnce(&SimpleIndexFile::SyncWriteToDisk, cache_type_, - cache_directory_, index_file_, temp_index_file_, - std::move(pickle), start, app_on_background); + base::OnceClosure task = base::BindOnce( + &SimpleIndexFile::SyncWriteToDisk, cache_type_, cache_directory_, + index_file_, temp_index_file_, std::move(pickle)); if (callback.is_null()) cache_runner_->PostTask(FROM_HERE, std::move(task)); else @@ -447,8 +432,6 @@ void SimpleIndexFile::SyncLoadIndexEntries( SyncRestoreFromDisk(cache_type, cache_directory, index_file_path, out_result); SIMPLE_CACHE_UMA(MEDIUM_TIMES, "IndexRestoreTime", cache_type, base::TimeTicks::Now() - start); - SIMPLE_CACHE_UMA(COUNTS_1M, "IndexEntriesRestored", cache_type, - out_result->entries.size()); if (index_file_existed) { out_result->init_method = SimpleIndex::INITIALIZE_METHOD_RECOVERED; diff --git a/chromium/net/disk_cache/simple/simple_index_file.h b/chromium/net/disk_cache/simple/simple_index_file.h index ae9345659e6..0e768f98656 100644 --- a/chromium/net/disk_cache/simple/simple_index_file.h +++ b/chromium/net/disk_cache/simple/simple_index_file.h @@ -13,7 +13,6 @@ #include "base/files/file_path.h" #include "base/gtest_prod_util.h" -#include "base/logging.h" #include "base/macros.h" #include "base/pickle.h" #include "net/base/cache_type.h" @@ -107,8 +106,6 @@ class NET_EXPORT_PRIVATE SimpleIndexFile { SimpleIndex::IndexWriteToDiskReason reason, const SimpleIndex::EntrySet& entry_set, uint64_t cache_size, - const base::TimeTicks& start, - bool app_on_background, base::OnceClosure callback); private: @@ -178,9 +175,7 @@ class NET_EXPORT_PRIVATE SimpleIndexFile { const base::FilePath& cache_directory, const base::FilePath& index_filename, const base::FilePath& temp_index_filename, - std::unique_ptr<base::Pickle> pickle, - const base::TimeTicks& start_time, - bool app_on_background); + std::unique_ptr<base::Pickle> pickle); // Scan the index directory for entries, returning an EntrySet of all entries // found. diff --git a/chromium/net/disk_cache/simple/simple_index_file_unittest.cc b/chromium/net/disk_cache/simple/simple_index_file_unittest.cc index c193f72fd47..a162ca7e564 100644 --- a/chromium/net/disk_cache/simple/simple_index_file_unittest.cc +++ b/chromium/net/disk_cache/simple/simple_index_file_unittest.cc @@ -462,9 +462,9 @@ TEST_F(SimpleIndexFileTest, WriteThenLoadIndex) { net::TestClosure closure; { WrappedSimpleIndexFile simple_index_file(cache_dir.GetPath()); - simple_index_file.WriteToDisk( - net::DISK_CACHE, SimpleIndex::INDEX_WRITE_REASON_SHUTDOWN, entries, - kCacheSize, base::TimeTicks(), false, closure.closure()); + simple_index_file.WriteToDisk(net::DISK_CACHE, + SimpleIndex::INDEX_WRITE_REASON_SHUTDOWN, + entries, kCacheSize, closure.closure()); closure.WaitForResult(); EXPECT_TRUE(base::PathExists(simple_index_file.GetIndexFilePath())); } @@ -637,9 +637,9 @@ TEST_F(SimpleIndexFileTest, OverwritesStaleTempFile) { SimpleIndex::EntrySet entries; SimpleIndex::InsertInEntrySet(11, EntryMetadata(Time(), 11u), &entries); net::TestClosure closure; - simple_index_file.WriteToDisk( - net::DISK_CACHE, SimpleIndex::INDEX_WRITE_REASON_SHUTDOWN, entries, 120U, - base::TimeTicks(), false, closure.closure()); + simple_index_file.WriteToDisk(net::DISK_CACHE, + SimpleIndex::INDEX_WRITE_REASON_SHUTDOWN, + entries, 120U, closure.closure()); closure.WaitForResult(); // Check that the temporary file was deleted and the index file was created. diff --git a/chromium/net/disk_cache/simple/simple_index_unittest.cc b/chromium/net/disk_cache/simple/simple_index_unittest.cc index e6e8e932d64..2f70905c705 100644 --- a/chromium/net/disk_cache/simple/simple_index_unittest.cc +++ b/chromium/net/disk_cache/simple/simple_index_unittest.cc @@ -78,8 +78,6 @@ class MockSimpleIndexFile : public SimpleIndexFile, SimpleIndex::IndexWriteToDiskReason reason, const SimpleIndex::EntrySet& entry_set, uint64_t cache_size, - const base::TimeTicks& start, - bool app_on_background, base::OnceClosure callback) override { disk_writes_++; disk_write_entry_set_ = entry_set; @@ -642,10 +640,6 @@ TEST_F(SimpleIndexTest, EvictBySize) { } TEST_F(SimpleIndexCodeCacheTest, DisableEvictBySize) { - base::test::ScopedFeatureList scoped_feature_list; - scoped_feature_list.InitWithFeatures( - {SimpleIndex::kSimpleCacheDisableEvictionSizeHeuristicForCodeCache}, {}); - base::Time now(base::Time::Now()); index()->SetMaxSize(50000); InsertIntoIndexFileReturn(hashes_.at<1>(), now - base::TimeDelta::FromDays(2), @@ -675,40 +669,6 @@ TEST_F(SimpleIndexCodeCacheTest, DisableEvictBySize) { ASSERT_EQ(2u, last_doom_entry_hashes().size()); } -TEST_F(SimpleIndexCodeCacheTest, EnableEvictBySize) { - base::test::ScopedFeatureList scoped_feature_list; - scoped_feature_list.InitWithFeatures( - {}, {SimpleIndex::kSimpleCacheDisableEvictionSizeHeuristicForCodeCache}); - - base::Time now(base::Time::Now()); - index()->SetMaxSize(50000); - InsertIntoIndexFileReturn(hashes_.at<1>(), now - base::TimeDelta::FromDays(2), - 475u); - InsertIntoIndexFileReturn(hashes_.at<2>(), now - base::TimeDelta::FromDays(1), - 40000u); - ReturnIndexFile(); - WaitForTimeChange(); - - index()->Insert(hashes_.at<3>()); - // Confirm index is as expected: No eviction, everything there. - EXPECT_EQ(3, index()->GetEntryCount()); - EXPECT_EQ(0, doom_entries_calls()); - EXPECT_TRUE(index()->Has(hashes_.at<1>())); - EXPECT_TRUE(index()->Has(hashes_.at<2>())); - EXPECT_TRUE(index()->Has(hashes_.at<3>())); - - // Trigger an eviction, and make sure the right things are tossed. - // This has size-weighting enabled, so it end sup kickicking out entry - // 2, which is biggest, and is enough, even though <1> is older. - index()->UpdateEntrySize(hashes_.at<3>(), 40000u); - EXPECT_EQ(1, doom_entries_calls()); - EXPECT_EQ(2, index()->GetEntryCount()); - EXPECT_TRUE(index()->Has(hashes_.at<1>())); - EXPECT_FALSE(index()->Has(hashes_.at<2>())); - EXPECT_TRUE(index()->Has(hashes_.at<3>())); - ASSERT_EQ(1u, last_doom_entry_hashes().size()); -} - // Same as test above, but using much older entries to make sure that small // things eventually get evictied. TEST_F(SimpleIndexTest, EvictBySize2) { diff --git a/chromium/net/disk_cache/simple/simple_synchronous_entry.cc b/chromium/net/disk_cache/simple/simple_synchronous_entry.cc index 6effe85bb22..140067a5864 100644 --- a/chromium/net/disk_cache/simple/simple_synchronous_entry.cc +++ b/chromium/net/disk_cache/simple/simple_synchronous_entry.cc @@ -60,12 +60,6 @@ void RecordCloseResult(net::CacheType cache_type, CloseResult result) { "SyncCloseResult", cache_type, result, CLOSE_RESULT_MAX); } -void RecordKeySHA256Result(net::CacheType cache_type, KeySHA256Result result) { - SIMPLE_CACHE_UMA(ENUMERATION, "SyncKeySHA256Result", cache_type, - static_cast<int>(result), - static_cast<int>(KeySHA256Result::MAX)); -} - void RecordOpenPrefetchMode(net::CacheType cache_type, OpenPrefetchMode mode) { SIMPLE_CACHE_UMA(ENUMERATION, "SyncOpenPrefetchMode", cache_type, mode, OPEN_PREFETCH_MAX); @@ -208,11 +202,6 @@ const char kSimpleCacheFullPrefetchBytesParam[] = "FullPrefetchBytes"; constexpr base::FeatureParam<int> kSimpleCacheFullPrefetchSize{ &kSimpleCachePrefetchExperiment, kSimpleCacheFullPrefetchBytesParam, 0}; -const char kSimpleCacheTrailerPrefetchHintParam[] = "TrailerPrefetchHint"; -constexpr base::FeatureParam<bool> kSimpleCacheTrailerPrefetchHint{ - &kSimpleCachePrefetchExperiment, kSimpleCacheTrailerPrefetchHintParam, - true}; - const char kSimpleCacheTrailerPrefetchSpeculativeBytesParam[] = "TrailerPrefetchSpeculativeBytes"; constexpr base::FeatureParam<int> kSimpleCacheTrailerPrefetchSpeculativeBytes{ @@ -224,7 +213,7 @@ int GetSimpleCacheFullPrefetchSize() { } int GetSimpleCacheTrailerPrefetchSize(int hint_size) { - if (kSimpleCacheTrailerPrefetchHint.Get() && hint_size > 0) + if (hint_size > 0) return hint_size; return kSimpleCacheTrailerPrefetchSpeculativeBytes.Get(); } @@ -338,13 +327,10 @@ void SimpleSynchronousEntry::OpenEntry( const FilePath& path, const std::string& key, const uint64_t entry_hash, - const base::TimeTicks& time_enqueued, SimpleFileTracker* file_tracker, int32_t trailer_prefetch_size, SimpleEntryCreationResults* out_results) { base::TimeTicks start_sync_open_entry = base::TimeTicks::Now(); - SIMPLE_CACHE_UMA(TIMES, "QueueLatency.OpenEntry", cache_type, - (start_sync_open_entry - time_enqueued)); SimpleSynchronousEntry* sync_entry = new SimpleSynchronousEntry( cache_type, path, key, entry_hash, file_tracker, trailer_prefetch_size); @@ -371,13 +357,10 @@ void SimpleSynchronousEntry::CreateEntry( const FilePath& path, const std::string& key, const uint64_t entry_hash, - const base::TimeTicks& time_enqueued, SimpleFileTracker* file_tracker, SimpleEntryCreationResults* out_results) { DCHECK_EQ(entry_hash, GetEntryHashKey(key)); base::TimeTicks start_sync_create_entry = base::TimeTicks::Now(); - SIMPLE_CACHE_UMA(TIMES, "QueueLatency.CreateEntry", cache_type, - (start_sync_create_entry - time_enqueued)); SimpleSynchronousEntry* sync_entry = new SimpleSynchronousEntry( cache_type, path, key, entry_hash, file_tracker, -1); @@ -404,13 +387,10 @@ void SimpleSynchronousEntry::OpenOrCreateEntry( const uint64_t entry_hash, OpenEntryIndexEnum index_state, bool optimistic_create, - const base::TimeTicks& time_enqueued, SimpleFileTracker* file_tracker, int32_t trailer_prefetch_size, SimpleEntryCreationResults* out_results) { base::TimeTicks start = base::TimeTicks::Now(); - SIMPLE_CACHE_UMA(TIMES, "QueueLatency.OpenOrCreateEntry", cache_type, - (start - time_enqueued)); if (index_state == INDEX_MISS) { // Try to just create. auto sync_entry = base::WrapUnique( @@ -431,8 +411,8 @@ void SimpleSynchronousEntry::OpenOrCreateEntry( // In this case, ::OpenOrCreateEntry already returned claiming it made // a new entry. Try extra-hard to make that the actual case. sync_entry->Doom(); - CreateEntry(cache_type, path, key, entry_hash, time_enqueued, - file_tracker, out_results); + CreateEntry(cache_type, path, key, entry_hash, file_tracker, + out_results); return; } // Otherwise can just try opening. @@ -445,12 +425,11 @@ void SimpleSynchronousEntry::OpenOrCreateEntry( } // Try open, then if that fails create. - OpenEntry(cache_type, path, key, entry_hash, time_enqueued, file_tracker, + OpenEntry(cache_type, path, key, entry_hash, file_tracker, trailer_prefetch_size, out_results); if (out_results->sync_entry) return; - CreateEntry(cache_type, path, key, entry_hash, time_enqueued, file_tracker, - out_results); + CreateEntry(cache_type, path, key, entry_hash, file_tracker, out_results); } // static @@ -628,8 +607,7 @@ void SimpleSynchronousEntry::WriteData(const WriteRequest& in_entry_op, out_write_result->result = net::ERR_CACHE_WRITE_FAILURE; return; } - CreateEntryResult result; - if (!InitializeCreatedFile(file_index, &result)) { + if (!InitializeCreatedFile(file_index)) { RecordWriteResult(cache_type_, SYNC_WRITE_RESULT_LAZY_INITIALIZE_FAILURE); Doom(); out_write_result->result = net::ERR_CACHE_WRITE_FAILURE; @@ -1203,7 +1181,6 @@ bool SimpleSynchronousEntry::OpenFiles(SimpleEntryStat* out_entry_stat) { have_open_files_ = true; base::Time after_open_files = base::Time::Now(); - base::TimeDelta entry_age = after_open_files - base::Time::UnixEpoch(); for (int i = 0; i < kSimpleEntryNormalFileCount; ++i) { if (empty_file_omitted_[i]) { out_entry_stat->set_data_size(i + 1, 0); @@ -1221,11 +1198,6 @@ bool SimpleSynchronousEntry::OpenFiles(SimpleEntryStat* out_entry_stat) { out_entry_stat->set_last_used(file_info.last_accessed); out_entry_stat->set_last_modified(file_info.last_modified); - base::TimeDelta stream_age = - base::Time::Now() - out_entry_stat->last_modified(); - if (stream_age < entry_age) - entry_age = stream_age; - // Two things prevent from knowing the right values for |data_size|: // 1) The key might not be known, hence its length might be unknown. // 2) Stream 0 and stream 1 are in the same file, and the exact size for @@ -1263,9 +1235,6 @@ bool SimpleSynchronousEntry::OpenFiles(SimpleEntryStat* out_entry_stat) { } } } - SIMPLE_CACHE_UMA(CUSTOM_COUNTS, - "SyncOpenEntryAge", cache_type_, - entry_age.InHours(), 1, 1000, 50); return true; } @@ -1274,7 +1243,6 @@ bool SimpleSynchronousEntry::CreateFiles(SimpleEntryStat* out_entry_stat) { for (int i = 0; i < kSimpleEntryNormalFileCount; ++i) { base::File::Error error; if (!MaybeCreateFile(i, FILE_NOT_REQUIRED, &error)) { - RecordSyncCreateResult(CREATE_ENTRY_PLATFORM_FILE_ERROR); SIMPLE_CACHE_UMA(ENUMERATION, "SyncCreatePlatformFileError", cache_type_, -error, -base::File::FILE_ERROR_MAX); @@ -1468,15 +1436,11 @@ int SimpleSynchronousEntry::InitializeForOpen( return net::OK; } -bool SimpleSynchronousEntry::InitializeCreatedFile( - int file_index, - CreateEntryResult* out_result) { +bool SimpleSynchronousEntry::InitializeCreatedFile(int file_index) { SimpleFileTracker::FileHandle file = file_tracker_->Acquire(this, SubFileForFileIndex(file_index)); - if (!file.IsOK()) { - *out_result = CREATE_ENTRY_CANT_WRITE_HEADER; + if (!file.IsOK()) return false; - } SimpleFileHeader header; header.initial_magic_number = kSimpleInitialMagicNumber; @@ -1487,16 +1451,12 @@ bool SimpleSynchronousEntry::InitializeCreatedFile( int bytes_written = file->Write(0, reinterpret_cast<char*>(&header), sizeof(header)); - if (bytes_written != sizeof(header)) { - *out_result = CREATE_ENTRY_CANT_WRITE_HEADER; + if (bytes_written != sizeof(header)) return false; - } bytes_written = file->Write(sizeof(header), key_.data(), key_.size()); - if (bytes_written != base::checked_cast<int>(key_.size())) { - *out_result = CREATE_ENTRY_CANT_WRITE_KEY; + if (bytes_written != base::checked_cast<int>(key_.size())) return false; - } return true; } @@ -1512,13 +1472,9 @@ int SimpleSynchronousEntry::InitializeForCreate( if (empty_file_omitted_[i]) continue; - CreateEntryResult result; - if (!InitializeCreatedFile(i, &result)) { - RecordSyncCreateResult(result); + if (!InitializeCreatedFile(i)) return net::ERR_FAILED; - } } - RecordSyncCreateResult(CREATE_ENTRY_SUCCESS); initialized_ = true; return net::OK; } @@ -1617,12 +1573,9 @@ int SimpleSynchronousEntry::ReadAndValidateStream0AndMaybe1( // Note the exact range needed in order to read the EOF record and stream 0. // In APP_CACHE mode this will be stored directly in the index so we can - // know exactly how much to read next time. Its also reported in a histogram - // so we can tune the speculative trailer prefetching experiment. + // know exactly how much to read next time. computed_trailer_prefetch_size_ = prefetch_data.GetDesiredTrailerPrefetchSize(); - SIMPLE_CACHE_UMA(COUNTS_100000, "EntryTrailerSize", cache_type_, - computed_trailer_prefetch_size_); // If we performed a trailer prefetch, record how accurate the prefetch was // compared to the ideal value. @@ -1663,15 +1616,11 @@ int SimpleSynchronousEntry::ReadAndValidateStream0AndMaybe1( std::memcmp(&hash_value, stream_prefetch_data[0].data->data() + stream_0_size, sizeof(hash_value)) == 0; - if (!matched) { - RecordKeySHA256Result(cache_type_, KeySHA256Result::NO_MATCH); + if (!matched) return net::ERR_FAILED; - } + // Elide header check if we verified sha256(key) via footer. header_and_key_check_needed_[0] = false; - RecordKeySHA256Result(cache_type_, KeySHA256Result::MATCHED); - } else { - RecordKeySHA256Result(cache_type_, KeySHA256Result::NOT_PRESENT); } // Ensure the key is validated before completion. @@ -1733,9 +1682,6 @@ int SimpleSynchronousEntry::GetEOFRecordData(base::File* file, if (!base::IsValueInRangeForNumericType<int32_t>(eof_record->stream_size)) return net::ERR_FAILED; - SIMPLE_CACHE_UMA(BOOLEAN, "SyncCheckEOFHasCrc", cache_type_, - (eof_record->flags & SimpleFileEOF::FLAG_HAS_CRC32) == - SimpleFileEOF::FLAG_HAS_CRC32); return net::OK; } @@ -1781,12 +1727,6 @@ bool SimpleSynchronousEntry::TruncateFilesForEntryHash( return result; } -void SimpleSynchronousEntry::RecordSyncCreateResult(CreateEntryResult result) { - DCHECK_LT(result, CREATE_ENTRY_MAX); - SIMPLE_CACHE_UMA(ENUMERATION, - "SyncCreateResult", cache_type_, result, CREATE_ENTRY_MAX); -} - FilePath SimpleSynchronousEntry::GetFilenameFromFileIndex( int file_index) const { return path_.AppendASCII( diff --git a/chromium/net/disk_cache/simple/simple_synchronous_entry.h b/chromium/net/disk_cache/simple/simple_synchronous_entry.h index 958a052ec39..9e1536b1b42 100644 --- a/chromium/net/disk_cache/simple/simple_synchronous_entry.h +++ b/chromium/net/disk_cache/simple/simple_synchronous_entry.h @@ -38,7 +38,6 @@ namespace disk_cache { NET_EXPORT_PRIVATE extern const base::Feature kSimpleCachePrefetchExperiment; NET_EXPORT_PRIVATE extern const char kSimpleCacheFullPrefetchBytesParam[]; -NET_EXPORT_PRIVATE extern const char kSimpleCacheTrailerPrefetchHintParam[]; NET_EXPORT_PRIVATE extern const char kSimpleCacheTrailerPrefetchSpeculativeBytesParam[]; @@ -191,13 +190,10 @@ class SimpleSynchronousEntry { // Opens a disk cache entry on disk. The |key| parameter is optional, if empty // the operation may be slower. The |entry_hash| parameter is required. - // |time_enqueued| is when this operation was added to the I/O thread pool, - // and is provided only for histograms. static void OpenEntry(net::CacheType cache_type, const base::FilePath& path, const std::string& key, uint64_t entry_hash, - const base::TimeTicks& time_enqueued, SimpleFileTracker* file_tracker, int32_t trailer_prefetch_size, SimpleEntryCreationResults* out_results); @@ -206,7 +202,6 @@ class SimpleSynchronousEntry { const base::FilePath& path, const std::string& key, uint64_t entry_hash, - const base::TimeTicks& time_enqueued, SimpleFileTracker* file_tracker, SimpleEntryCreationResults* out_results); @@ -216,7 +211,6 @@ class SimpleSynchronousEntry { uint64_t entry_hash, OpenEntryIndexEnum index_state, bool optimistic_create, - const base::TimeTicks& time_enqueued, SimpleFileTracker* file_tracker, int32_t trailer_prefetch_size, SimpleEntryCreationResults* out_results); @@ -304,14 +298,6 @@ class SimpleSynchronousEntry { friend class SimpleFileTrackerTest; class PrefetchData; - enum CreateEntryResult { - CREATE_ENTRY_SUCCESS = 0, - CREATE_ENTRY_PLATFORM_FILE_ERROR = 1, - CREATE_ENTRY_CANT_WRITE_HEADER = 2, - CREATE_ENTRY_CANT_WRITE_KEY = 3, - CREATE_ENTRY_MAX = 4, - }; - enum FileRequired { FILE_NOT_REQUIRED, FILE_REQUIRED @@ -368,9 +354,8 @@ class SimpleSynchronousEntry { SimpleStreamPrefetchData stream_prefetch_data[2]); // Writes the header and key to a newly-created stream file. |index| is the - // index of the stream. Returns true on success; returns false and sets - // |*out_result| on failure. - bool InitializeCreatedFile(int index, CreateEntryResult* out_result); + // index of the stream. Returns true on success; returns false and failure. + bool InitializeCreatedFile(int index); // Returns a net error, including net::OK on success and net::FILE_EXISTS // when the entry already exists. @@ -469,8 +454,6 @@ class SimpleSynchronousEntry { static bool TruncateFilesForEntryHash(const base::FilePath& path, uint64_t entry_hash); - void RecordSyncCreateResult(CreateEntryResult result); - base::FilePath GetFilenameFromFileIndex(int file_index) const; bool sparse_file_open() const { return sparse_file_open_; } |