Changeset 179804 in webkit
- Timestamp:
- Feb 8, 2015 2:06:06 PM (9 years ago)
- Location:
- trunk/Source
- Files:
-
- 3 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r179796 r179804 1 2015-02-08 Chris Dumez <cdumez@apple.com> 2 3 [WK2] Add logging to validate the network cache efficacy (Part 1) 4 https://bugs.webkit.org/show_bug.cgi?id=141269 5 <rdar://problem/19632080> 6 7 Reviewed by Antti Koivisto. 8 9 Export an extra symbol. 10 11 * WebCore.exp.in: 12 1 13 2015-02-07 Chris Fleizach <cfleizach@apple.com> 2 14 -
trunk/Source/WebCore/WebCore.exp.in
r179792 r179804 2263 2263 2264 2264 #if !ASSERT_DISABLED 2265 __ZN7WebCore21SQLiteDatabaseTracker24hasTransactionInProgressEv 2265 2266 __ZN7WebCore27NoExceptionAssertionCheckerC1EPKci 2266 2267 __ZN7WebCore27NoExceptionAssertionCheckerD1Ev -
trunk/Source/WebKit2/ChangeLog
r179791 r179804 1 2015-02-08 Chris Dumez <cdumez@apple.com> 2 3 [WK2] Add logging to validate the network cache efficacy (Part 1) 4 https://bugs.webkit.org/show_bug.cgi?id=141269 5 <rdar://problem/19632080> 6 7 Reviewed by Antti Koivisto. 8 9 Add console logging to validate the network cache efficacy. This will 10 tell us if how the network cache satisties requests, in particular: 11 - Request cannot be handled by the cache 12 - Entry was not in the cache but is no longer there (pruned) 13 - Entry is in the cache but is not usable 14 - Entry is in the cache and is used. 15 16 This patch introduces a SQLite-based network cache statistics storage 17 that is used to store requests we have seen before, and query if we 18 have seen a request before. The storage is lightweight as it only 19 stores hashes in the database, in a background thread. 20 21 The statistics cache is initially bootstapped from the network disk 22 cache so that we have data initially and get as accurate statistics 23 as possible from the start. 24 25 To maintain an acceptable level of performance, we have a hard limit 26 on the number of unique requests that are retained set to 100000. 27 28 Diagnostic logging for this will be added in a follow-up patch. 29 1 30 2015-02-07 Chris Dumez <cdumez@apple.com> 2 31 -
trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp
r179780 r179804 31 31 #include "Logging.h" 32 32 #include "NetworkCacheCoders.h" 33 #include "NetworkCacheStatistics.h" 33 34 #include "NetworkCacheStorage.h" 34 35 #include "NetworkResourceLoader.h" … … 50 51 } 51 52 52 bool NetworkCache::initialize(const String& cachePath )53 bool NetworkCache::initialize(const String& cachePath, bool enableEfficacyLogging) 53 54 { 54 55 m_storage = NetworkCacheStorage::open(cachePath); 56 57 if (enableEfficacyLogging) 58 m_statistics = NetworkCacheStatistics::open(cachePath); 55 59 56 60 LOG(NetworkCache, "(NetworkProcess) opened cache storage, success %d", !!m_storage); … … 221 225 LOG(NetworkCache, "(NetworkProcess) retrieving %s priority %u", originalRequest.url().string().ascii().data(), originalRequest.priority()); 222 226 227 NetworkCacheKey storageKey = makeCacheKey(originalRequest); 223 228 if (!canRetrieve(originalRequest)) { 229 if (m_statistics) 230 m_statistics->recordNotUsingCacheForRequest(storageKey, originalRequest); 231 224 232 completionHandler(nullptr); 225 233 return; … … 227 235 228 236 auto startTime = std::chrono::system_clock::now(); 229 NetworkCacheKey storageKey = makeCacheKey(originalRequest);230 237 unsigned priority = originalRequest.priority(); 231 238 232 m_storage->retrieve(storageKey, priority, [this, originalRequest, completionHandler, startTime ](std::unique_ptr<NetworkCacheStorage::Entry> entry) {239 m_storage->retrieve(storageKey, priority, [this, originalRequest, completionHandler, startTime, storageKey](std::unique_ptr<NetworkCacheStorage::Entry> entry) { 233 240 if (!entry) { 234 241 LOG(NetworkCache, "(NetworkProcess) not found in storage"); 242 243 if (m_statistics) 244 m_statistics->recordRetrievalFailure(storageKey, originalRequest); 245 235 246 completionHandler(nullptr); 236 247 return false; … … 238 249 auto decodedEntry = decodeStorageEntry(*entry, originalRequest); 239 250 bool success = !!decodedEntry; 251 if (m_statistics) 252 m_statistics->recordRetrievedCachedEntry(storageKey, originalRequest, success); 253 240 254 #if !LOG_DISABLED 241 255 auto elapsedMS = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - startTime).count(); … … 332 346 if (m_storage) 333 347 m_storage->clear(); 334 } 335 336 } 337 338 #endif 348 if (m_statistics) 349 m_statistics->clear(); 350 } 351 352 String NetworkCache::storagePath() const 353 { 354 return m_storage ? m_storage->directoryPath() : String(); 355 } 356 357 } 358 359 #endif -
trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h
r179708 r179804 42 42 namespace WebKit { 43 43 44 class NetworkCacheStatistics; 45 44 46 class NetworkCache { 45 47 WTF_MAKE_NONCOPYABLE(NetworkCache); … … 48 50 static NetworkCache& singleton(); 49 51 50 bool initialize(const String& cachePath );52 bool initialize(const String& cachePath, bool enableEfficacyLogging); 51 53 void setMaximumSize(size_t); 52 54 … … 76 78 void clear(); 77 79 80 String storagePath() const; 81 78 82 private: 79 83 NetworkCache() = default; … … 81 85 82 86 std::unique_ptr<NetworkCacheStorage> m_storage; 87 std::unique_ptr<NetworkCacheStatistics> m_statistics; 83 88 }; 84 89 -
trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h
r179779 r179804 156 156 static const unsigned version = 2; 157 157 158 const String& directoryPath() const { return m_directoryPath; } 159 158 160 private: 159 161 NetworkCacheStorage(const String& directoryPath); -
trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorageCocoa.mm
r179779 r179804 31 31 #include "Logging.h" 32 32 #include "NetworkCacheCoders.h" 33 #include <WebCore/FileSystem.h> 34 #include <dirent.h> 33 #include "NetworkCacheFileSystemPosix.h" 35 34 #include <dispatch/dispatch.h> 36 35 #include <sys/mman.h> … … 44 43 static const char networkCacheSubdirectory[] = "WebKitCache"; 45 44 static const char versionDirectoryPrefix[] = "Version "; 46 47 template <typename Function>48 static void traverseDirectory(const String& path, uint8_t type, const Function& function)49 {50 DIR* dir = opendir(WebCore::fileSystemRepresentation(path).data());51 if (!dir)52 return;53 struct dirent* dp;54 while ((dp = readdir(dir))) {55 if (dp->d_type != type)56 continue;57 const char* name = dp->d_name;58 if (!strcmp(name, ".") || !strcmp(name, ".."))59 continue;60 function(String(name));61 }62 closedir(dir);63 }64 65 static void traverseCacheFiles(const String& cachePath, std::function<void (const String& fileName, const String& partitionPath)> function)66 {67 traverseDirectory(cachePath, DT_DIR, [&cachePath, &function](const String& subdirName) {68 String partitionPath = WebCore::pathByAppendingComponent(cachePath, subdirName);69 traverseDirectory(partitionPath, DT_REG, [&function, &partitionPath](const String& fileName) {70 if (fileName.length() != NetworkCacheKey::hashStringLength())71 return;72 function(fileName, partitionPath);73 });74 });75 }76 45 77 46 NetworkCacheStorage::Data::Data(const uint8_t* data, size_t size) -
trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkProcessCocoa.mm
r179409 r179804 65 65 SandboxExtension::consumePermanently(parameters.diskCacheDirectoryExtensionHandle); 66 66 #if ENABLE(NETWORK_CACHE) 67 if (parameters.shouldEnableNetworkCache && NetworkCache::singleton().initialize(m_diskCacheDirectory )) {67 if (parameters.shouldEnableNetworkCache && NetworkCache::singleton().initialize(m_diskCacheDirectory, parameters.shouldEnableNetworkCacheEfficacyLogging)) { 68 68 RetainPtr<NSURLCache> urlCache(adoptNS([[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil])); 69 69 [NSURLCache setSharedURLCache:urlCache.get()]; -
trunk/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.cpp
r179148 r179804 46 46 #if ENABLE(NETWORK_CACHE) 47 47 encoder << shouldEnableNetworkCache; 48 encoder << shouldEnableNetworkCacheEfficacyLogging; 48 49 #endif 49 50 encoder << cookieStorageDirectory; … … 86 87 #if ENABLE(NETWORK_CACHE) 87 88 if (!decoder.decode(result.shouldEnableNetworkCache)) 89 return false; 90 if (!decoder.decode(result.shouldEnableNetworkCacheEfficacyLogging)) 88 91 return false; 89 92 #endif -
trunk/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.h
r179148 r179804 59 59 #if ENABLE(NETWORK_CACHE) 60 60 bool shouldEnableNetworkCache; 61 bool shouldEnableNetworkCacheEfficacyLogging; 61 62 #endif 62 63 -
trunk/Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm
r179409 r179804 82 82 #if ENABLE(NETWORK_CACHE) 83 83 static NSString * const WebKitNetworkCacheEnabledDefaultsKey = @"WebKitNetworkCacheEnabled"; 84 static NSString * const WebKitNetworkCacheEfficacyLoggingEnabledDefaultsKey = @"WebKitNetworkCacheEfficacyLoggingEnabled"; 84 85 #endif 85 86 … … 107 108 #if ENABLE(NETWORK_CACHE) 108 109 [registrationDictionary setObject:[NSNumber numberWithBool:YES] forKey:WebKitNetworkCacheEnabledDefaultsKey]; 110 [registrationDictionary setObject:[NSNumber numberWithBool:YES] forKey:WebKitNetworkCacheEfficacyLoggingEnabledDefaultsKey]; 109 111 #endif 110 112 … … 253 255 #if ENABLE(NETWORK_CACHE) 254 256 parameters.shouldEnableNetworkCache = [[NSUserDefaults standardUserDefaults] boolForKey:WebKitNetworkCacheEnabledDefaultsKey]; 257 parameters.shouldEnableNetworkCacheEfficacyLogging = [[NSUserDefaults standardUserDefaults] boolForKey:WebKitNetworkCacheEfficacyLoggingEnabledDefaultsKey]; 255 258 #endif 256 259 } -
trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
r179786 r179804 1148 1148 7CF47FFF17276AE3008ACB91 /* WKBundlePageBannerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CF47FFD17276AE3008ACB91 /* WKBundlePageBannerMac.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1149 1149 7EC4F0FB18E4ACBB008056AF /* NetworkProcessCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7EC4F0F918E4A945008056AF /* NetworkProcessCocoa.mm */; }; 1150 834B250F1A831A8D00CFB150 /* NetworkCacheFileSystemPosix.h in Headers */ = {isa = PBXBuildFile; fileRef = 834B250E1A831A8D00CFB150 /* NetworkCacheFileSystemPosix.h */; }; 1151 834B25121A842C8700CFB150 /* NetworkCacheStatistics.h in Headers */ = {isa = PBXBuildFile; fileRef = 834B25101A842C8700CFB150 /* NetworkCacheStatistics.h */; }; 1152 834B25131A842C8700CFB150 /* NetworkCacheStatisticsCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 834B25111A842C8700CFB150 /* NetworkCacheStatisticsCocoa.mm */; }; 1150 1153 8372DB251A674C8F00C697C5 /* WKPageDiagnosticLoggingClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 8372DB241A674C8F00C697C5 /* WKPageDiagnosticLoggingClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1151 1154 8372DB281A67562800C697C5 /* WebPageDiagnosticLoggingClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8372DB261A67562800C697C5 /* WebPageDiagnosticLoggingClient.cpp */; }; … … 3322 3325 7CF47FFD17276AE3008ACB91 /* WKBundlePageBannerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundlePageBannerMac.h; sourceTree = "<group>"; }; 3323 3326 7EC4F0F918E4A945008056AF /* NetworkProcessCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = NetworkProcessCocoa.mm; path = NetworkProcess/cocoa/NetworkProcessCocoa.mm; sourceTree = "<group>"; }; 3327 834B250E1A831A8D00CFB150 /* NetworkCacheFileSystemPosix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCacheFileSystemPosix.h; sourceTree = "<group>"; }; 3328 834B25101A842C8700CFB150 /* NetworkCacheStatistics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCacheStatistics.h; sourceTree = "<group>"; }; 3329 834B25111A842C8700CFB150 /* NetworkCacheStatisticsCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkCacheStatisticsCocoa.mm; sourceTree = "<group>"; }; 3324 3330 8372DB241A674C8F00C697C5 /* WKPageDiagnosticLoggingClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPageDiagnosticLoggingClient.h; sourceTree = "<group>"; }; 3325 3331 8372DB261A67562800C697C5 /* WebPageDiagnosticLoggingClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPageDiagnosticLoggingClient.cpp; sourceTree = "<group>"; }; … … 7383 7389 E489D2881A0A2DB80078C06A /* NetworkCacheEncoder.cpp */, 7384 7390 E489D2891A0A2DB80078C06A /* NetworkCacheEncoder.h */, 7391 834B250E1A831A8D00CFB150 /* NetworkCacheFileSystemPosix.h */, 7385 7392 E4436EC01A0CFDB200EAD204 /* NetworkCacheKey.cpp */, 7386 7393 E4436EC11A0CFDB200EAD204 /* NetworkCacheKey.h */, 7394 834B25101A842C8700CFB150 /* NetworkCacheStatistics.h */, 7395 834B25111A842C8700CFB150 /* NetworkCacheStatisticsCocoa.mm */, 7387 7396 E4436EC21A0CFDB200EAD204 /* NetworkCacheStorage.h */, 7388 7397 E4436EC31A0CFDB200EAD204 /* NetworkCacheStorageCocoa.mm */, … … 7501 7510 1AFDD3151891B54000153970 /* APIPolicyClient.h in Headers */, 7502 7511 7CE4D2201A4914CA00C7F152 /* APIProcessPoolConfiguration.h in Headers */, 7512 834B25121A842C8700CFB150 /* NetworkCacheStatistics.h in Headers */, 7503 7513 F634445612A885C8000612D8 /* APISecurityOrigin.h in Headers */, 7504 7514 75A8D2E1187DEC1A00C39C9E /* APISession.h in Headers */, … … 7687 7697 1A2162B111F38971008AD0F5 /* NPRuntimeUtilities.h in Headers */, 7688 7698 1A2D84A3127F6AD1001EB962 /* NPVariantData.h in Headers */, 7699 834B250F1A831A8D00CFB150 /* NetworkCacheFileSystemPosix.h in Headers */, 7689 7700 BC8ACA1316670D89004C1941 /* ObjCObjectGraph.h in Headers */, 7690 7701 BCCF672D12C7EDF7008F9C35 /* OriginAndDatabases.h in Headers */, … … 9886 9897 0F3C725C196F605200AEDD0C /* WKInspectorHighlightView.mm in Sources */, 9887 9898 A54293A5195A43DD002782C7 /* WKInspectorNodeSearchGestureRecognizer.mm in Sources */, 9899 834B25131A842C8700CFB150 /* NetworkCacheStatisticsCocoa.mm in Sources */, 9888 9900 51A9E10A1315CD18009E7031 /* WKKeyValueStorageManager.cpp in Sources */, 9889 9901 33D3A3B51339600B00709BE4 /* WKMediaCacheManager.cpp in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.