Changeset 179972 in webkit


Ignore:
Timestamp:
Feb 11, 2015 3:57:31 PM (9 years ago)
Author:
Chris Dumez
Message:

[WK2] Add logging to validate the network cache efficacy (Part 2)
https://bugs.webkit.org/show_bug.cgi?id=141345
<rdar://problem/19632080>

Reviewed by Sam Weinig.

Source/WebCore:

Add a few more diagnostic logging keys for the network cache efficacy
logging.

Source/WebKit2:

Add diagnostic logging messages to validate the network cache efficacy.
The following 4 messages are added:

  • networkCache / retrieval / success
  • networkCache / retrieval / unhandledRequestFailure
  • networkCache / retrieval / noLongerInCacheFailure
  • networkCache / retrieval / unusableCachedEntryFailure

The messages are sent via IPC from the NetworkProcess to the UIProcess,
where the WebPageProxy code already handles diagnostic messages sent by
the WebProcess.

Location:
trunk/Source
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r179971 r179972  
     12015-02-11  Chris Dumez  <cdumez@apple.com>
     2
     3        [WK2] Add logging to validate the network cache efficacy (Part 2)
     4        https://bugs.webkit.org/show_bug.cgi?id=141345
     5        <rdar://problem/19632080>
     6
     7        Reviewed by Sam Weinig.
     8
     9        Add a few more diagnostic logging keys for the network cache efficacy
     10        logging.
     11
    1122015-02-11  Sam Weinig  <sam@webkit.org>
    213
  • trunk/Source/WebCore/WebCore.exp.in

    r179919 r179972  
    946946__ZN7WebCore21CrossThreadCopierBaseILb0ELb0ENS_19IDBDatabaseMetadataEE4copyERKS1_
    947947__ZN7WebCore21DiagnosticLoggingKeys10webViewKeyEv
     948__ZN7WebCore21DiagnosticLoggingKeys12retrievalKeyEv
     949__ZN7WebCore21DiagnosticLoggingKeys15networkCacheKeyEv
     950__ZN7WebCore21DiagnosticLoggingKeys25noLongerInCacheFailureKeyEv
     951__ZN7WebCore21DiagnosticLoggingKeys26unhandledRequestFailureKeyEv
     952__ZN7WebCore21DiagnosticLoggingKeys29unusableCachedEntryFailureKeyEv
    948953__ZN7WebCore21DiagnosticLoggingKeys7userKeyEv
    949954__ZN7WebCore21DiagnosticLoggingKeys9zoomedKeyEv
  • trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp

    r179919 r179972  
    104104}
    105105
     106String DiagnosticLoggingKeys::networkCacheKey()
     107{
     108    return ASCIILiteral("networkCache");
     109}
     110
    106111String DiagnosticLoggingKeys::networkKey()
    107112{
     
    134139}
    135140
     141String DiagnosticLoggingKeys::noLongerInCacheFailureKey()
     142{
     143    return ASCIILiteral("noLongerInCacheFailure");
     144}
     145
    136146String DiagnosticLoggingKeys::otherKey()
    137147{
     
    299309}
    300310
     311String DiagnosticLoggingKeys::retrievalKey()
     312{
     313    return ASCIILiteral("retrieval");
     314}
     315
    301316String DiagnosticLoggingKeys::revalidatingKey()
    302317{
     
    334349}
    335350
     351String DiagnosticLoggingKeys::unhandledRequestFailureKey()
     352{
     353    return ASCIILiteral("unhandledRequestFailure");
     354}
     355
     356String DiagnosticLoggingKeys::unusableCachedEntryFailureKey()
     357{
     358    return ASCIILiteral("unusableCachedEntryFailure");
     359}
     360
    336361String DiagnosticLoggingKeys::unusedKey()
    337362{
  • trunk/Source/WebCore/page/DiagnosticLoggingKeys.h

    r179919 r179972  
    6464    static String mustRevalidateIsExpiredKey();
    6565    static String navigationKey();
     66    WEBCORE_EXPORT static String networkCacheKey();
    6667    static String networkKey();
    6768    static String noCacheKey();
    6869    static String noCurrentHistoryItemKey();
    6970    static String noDocumentLoaderKey();
     71    WEBCORE_EXPORT static String noLongerInCacheFailureKey();
    7072    static String noStoreKey();
    7173    static String notInMemoryCacheKey();
     
    9193    static String resourceRequestKey();
    9294    static String resourceResponseKey();
     95    WEBCORE_EXPORT static String retrievalKey();
    9396    static String revalidatingKey();
    9497    static String sameLoadKey();
     
    97100    static String styleSheetKey();
    98101    static String svgDocumentKey();
     102    WEBCORE_EXPORT static String unhandledRequestFailureKey();
     103    WEBCORE_EXPORT static String unusableCachedEntryFailureKey();
    99104    static String unusedKey();
    100105    static String unusedReasonCredentialSettingsKey();
  • trunk/Source/WebKit2/ChangeLog

    r179955 r179972  
     12015-02-11  Chris Dumez  <cdumez@apple.com>
     2
     3        [WK2] Add logging to validate the network cache efficacy (Part 2)
     4        https://bugs.webkit.org/show_bug.cgi?id=141345
     5        <rdar://problem/19632080>
     6
     7        Reviewed by Sam Weinig.
     8
     9        Add diagnostic logging messages to validate the network cache efficacy.
     10        The following 4 messages are added:
     11        - networkCache / retrieval / success
     12        - networkCache / retrieval / unhandledRequestFailure
     13        - networkCache / retrieval / noLongerInCacheFailure
     14        - networkCache / retrieval / unusableCachedEntryFailure
     15
     16        The messages are sent via IPC from the NetworkProcess to the UIProcess,
     17        where the WebPageProxy code already handles diagnostic messages sent by
     18        the WebProcess.
     19
    1202015-02-11  Tim Horton  <timothy_horton@apple.com>
    221
  • trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp

    r179919 r179972  
    302302}
    303303
     304void NetworkProcess::logDiagnosticMessage(uint64_t webPageID, const String& message, const String& description)
     305{
     306    parentProcessConnection()->send(Messages::NetworkProcessProxy::LogDiagnosticMessage(webPageID, message, description), 0);
     307}
     308
     309void NetworkProcess::logDiagnosticMessageWithResult(uint64_t webPageID, const String& message, const String& description, WebCore::DiagnosticLoggingResultType result)
     310{
     311    parentProcessConnection()->send(Messages::NetworkProcessProxy::LogDiagnosticMessageWithResult(webPageID, message, description, result), 0);
     312}
     313
     314void NetworkProcess::logDiagnosticMessageWithValue(uint64_t webPageID, const String& message, const String& description, const String& value)
     315{
     316    parentProcessConnection()->send(Messages::NetworkProcessProxy::LogDiagnosticMessageWithValue(webPageID, message, description, value), 0);
     317}
     318
    304319void NetworkProcess::terminate()
    305320{
  • trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h

    r179919 r179972  
    3434#include "MessageReceiverMap.h"
    3535#include "NetworkResourceLoadScheduler.h"
     36#include <WebCore/DiagnosticLoggingResultType.h>
    3637#include <WebCore/SessionID.h>
    3738#include <memory>
     
    7576    DownloadManager& downloadManager();
    7677    bool canHandleHTTPSServerTrustEvaluation() const { return m_canHandleHTTPSServerTrustEvaluation; }
     78
     79    // Diagnostic messages logging.
     80    void logDiagnosticMessage(uint64_t webPageID, const String& message, const String& description);
     81    void logDiagnosticMessageWithResult(uint64_t webPageID, const String& message, const String& description, WebCore::DiagnosticLoggingResultType);
     82    void logDiagnosticMessageWithValue(uint64_t webPageID, const String& message, const String& description, const String& value);
    7783
    7884private:
  • trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp

    r179919 r179972  
    142142
    143143    RefPtr<NetworkResourceLoader> loader(this);
    144     NetworkCache::singleton().retrieve(originalRequest(), [loader](std::unique_ptr<NetworkCache::Entry> entry) {
     144    NetworkCache::singleton().retrieve(originalRequest(), m_parameters.webPageID, [loader](std::unique_ptr<NetworkCache::Entry> entry) {
    145145        if (loader->hasOneRef()) {
    146146            // The loader has been aborted and is only held alive by this lambda.
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp

    r179919 r179972  
    219219}
    220220
    221 void NetworkCache::retrieve(const WebCore::ResourceRequest& originalRequest, std::function<void (std::unique_ptr<Entry>)> completionHandler)
     221void NetworkCache::retrieve(const WebCore::ResourceRequest& originalRequest, uint64_t webPageID, std::function<void (std::unique_ptr<Entry>)> completionHandler)
    222222{
    223223    ASSERT(isEnabled());
     
    228228    if (!canRetrieve(originalRequest)) {
    229229        if (m_statistics)
    230             m_statistics->recordNotUsingCacheForRequest(storageKey, originalRequest);
     230            m_statistics->recordNotUsingCacheForRequest(webPageID, storageKey, originalRequest);
    231231
    232232        completionHandler(nullptr);
     
    237237    unsigned priority = originalRequest.priority();
    238238
    239     m_storage->retrieve(storageKey, priority, [this, originalRequest, completionHandler, startTime, storageKey](std::unique_ptr<NetworkCacheStorage::Entry> entry) {
     239    m_storage->retrieve(storageKey, priority, [this, originalRequest, completionHandler, startTime, storageKey, webPageID](std::unique_ptr<NetworkCacheStorage::Entry> entry) {
    240240        if (!entry) {
    241241            LOG(NetworkCache, "(NetworkProcess) not found in storage");
    242242
    243243            if (m_statistics)
    244                 m_statistics->recordRetrievalFailure(storageKey, originalRequest);
     244                m_statistics->recordRetrievalFailure(webPageID, storageKey, originalRequest);
    245245
    246246            completionHandler(nullptr);
     
    250250        bool success = !!decodedEntry;
    251251        if (m_statistics)
    252             m_statistics->recordRetrievedCachedEntry(storageKey, originalRequest, success);
     252            m_statistics->recordRetrievedCachedEntry(webPageID, storageKey, originalRequest, success);
    253253
    254254#if !LOG_DISABLED
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h

    r179919 r179972  
    6565    };
    6666    // Completion handler may get called back synchronously on failure.
    67     void retrieve(const WebCore::ResourceRequest&, std::function<void (std::unique_ptr<Entry>)>);
     67    void retrieve(const WebCore::ResourceRequest&, uint64_t webPageID, std::function<void (std::unique_ptr<Entry>)>);
    6868
    6969    struct MappedBody {
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStatistics.h

    r179919 r179972  
    4545    void clear();
    4646
    47     void recordNotUsingCacheForRequest(const NetworkCacheKey&, const WebCore::ResourceRequest&);
    48     void recordRetrievalFailure(const NetworkCacheKey&, const WebCore::ResourceRequest&);
    49     void recordRetrievedCachedEntry(const NetworkCacheKey&, const WebCore::ResourceRequest&, bool success);
     47    void recordNotUsingCacheForRequest(uint64_t webPageID, const NetworkCacheKey&, const WebCore::ResourceRequest&);
     48    void recordRetrievalFailure(uint64_t webPageID, const NetworkCacheKey&, const WebCore::ResourceRequest&);
     49    void recordRetrievedCachedEntry(uint64_t webPageID, const NetworkCacheKey&, const WebCore::ResourceRequest&, bool success);
    5050
    5151private:
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStatisticsCocoa.mm

    r179919 r179972  
    3232#include "NetworkCache.h"
    3333#include "NetworkCacheFileSystemPosix.h"
     34#include "NetworkProcess.h"
     35#include <WebCore/DiagnosticLoggingKeys.h>
     36#include <WebCore/DiagnosticLoggingResultType.h>
    3437#include <WebCore/ResourceRequest.h>
    3538#include <WebCore/SQLiteDatabaseTracker.h>
     
    166169}
    167170
    168 void NetworkCacheStatistics::recordNotUsingCacheForRequest(const NetworkCacheKey& key, const WebCore::ResourceRequest& request)
     171void NetworkCacheStatistics::recordNotUsingCacheForRequest(uint64_t webPageID, const NetworkCacheKey& key, const WebCore::ResourceRequest& request)
    169172{
    170173    String hash = key.hashAsString();
    171174    WebCore::URL requestURL = request.url();
    172     queryWasEverRequested(hash, [this, hash, requestURL](bool wasEverRequested) {
     175    queryWasEverRequested(hash, [this, hash, requestURL, webPageID](bool wasEverRequested) {
    173176        if (wasEverRequested) {
    174             LOG(NetworkCache, "(NetworkProcess) %s was previously requested but is not handled by the cache", requestURL.string().ascii().data());
    175             // FIXME: Do diagnostic logging.
     177            LOG(NetworkCache, "(NetworkProcess) webPageID %llu: %s was previously requested but is not handled by the cache", webPageID, requestURL.string().ascii().data());
     178            NetworkProcess::singleton().logDiagnosticMessageWithValue(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::retrievalKey(), WebCore::DiagnosticLoggingKeys::unhandledRequestFailureKey());
    176179        } else
    177180            markAsRequested(hash);
     
    179182}
    180183
    181 void NetworkCacheStatistics::recordRetrievalFailure(const NetworkCacheKey& key, const WebCore::ResourceRequest& request)
     184void NetworkCacheStatistics::recordRetrievalFailure(uint64_t webPageID, const NetworkCacheKey& key, const WebCore::ResourceRequest& request)
    182185{
    183186    String hash = key.hashAsString();
    184187    WebCore::URL requestURL = request.url();
    185     queryWasEverRequested(hash, [this, hash, requestURL](bool wasPreviouslyRequested) {
     188    queryWasEverRequested(hash, [this, hash, requestURL, webPageID](bool wasPreviouslyRequested) {
    186189        if (wasPreviouslyRequested) {
    187             LOG(NetworkCache, "(NetworkProcess) %s was previously cached but is no longer in the cache", requestURL.string().ascii().data());
    188             // FIXME: Do diagnostic logging.
     190            LOG(NetworkCache, "(NetworkProcess) webPageID %llu: %s was previously cached but is no longer in the cache", webPageID, requestURL.string().ascii().data());
     191            NetworkProcess::singleton().logDiagnosticMessageWithValue(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::retrievalKey(), WebCore::DiagnosticLoggingKeys::noLongerInCacheFailureKey());
    189192        } else
    190193            markAsRequested(hash);
     
    192195}
    193196
    194 void NetworkCacheStatistics::recordRetrievedCachedEntry(const NetworkCacheKey& key, const WebCore::ResourceRequest& request, bool success)
     197void NetworkCacheStatistics::recordRetrievedCachedEntry(uint64_t webPageID, const NetworkCacheKey& key, const WebCore::ResourceRequest& request, bool success)
    195198{
    196199    WebCore::URL requestURL = request.url();
    197     if (success)
    198         LOG(NetworkCache, "(NetworkProcess) %s is in the cache and is used", requestURL.string().ascii().data());
    199     else
    200         LOG(NetworkCache, "(NetworkProcess) %s is in the cache but wasn't used", requestURL.string().ascii().data());
    201     // FIXME: Do diagnostic logging.
     200    if (success) {
     201        LOG(NetworkCache, "(NetworkProcess) webPageID %llu: %s is in the cache and is used", webPageID, requestURL.string().ascii().data());
     202        NetworkProcess::singleton().logDiagnosticMessageWithResult(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::retrievalKey(), WebCore::DiagnosticLoggingResultPass);
     203    } else {
     204        LOG(NetworkCache, "(NetworkProcess) webPageID %llu: %s is in the cache but wasn't used", webPageID, requestURL.string().ascii().data());
     205        NetworkProcess::singleton().logDiagnosticMessageWithValue(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::retrievalKey(), WebCore::DiagnosticLoggingKeys::unusableCachedEntryFailureKey());
     206    }
    202207}
    203208
  • trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp

    r179919 r179972  
    231231}
    232232
     233void NetworkProcessProxy::logDiagnosticMessage(uint64_t pageID, const String& message, const String& description)
     234{
     235    WebPageProxy* page = WebProcessProxy::webPage(pageID);
     236    // FIXME: We do this null-check because by the time the decision to log is made, the page may be gone. We should refactor to avoid this,
     237    // but for now we simply drop the message in the rare case this happens.
     238    if (!page)
     239        return;
     240
     241    page->logDiagnosticMessage(message, description);
     242}
     243
     244void NetworkProcessProxy::logDiagnosticMessageWithResult(uint64_t pageID, const String& message, const String& description, uint32_t result)
     245{
     246    WebPageProxy* page = WebProcessProxy::webPage(pageID);
     247    // FIXME: We do this null-check because by the time the decision to log is made, the page may be gone. We should refactor to avoid this,
     248    // but for now we simply drop the message in the rare case this happens.
     249    if (!page)
     250        return;
     251
     252    page->logDiagnosticMessageWithResult(message, description, result);
     253}
     254
     255void NetworkProcessProxy::logDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, const String& value)
     256{
     257    WebPageProxy* page = WebProcessProxy::webPage(pageID);
     258    // FIXME: We do this null-check because by the time the decision to log is made, the page may be gone. We should refactor to avoid this,
     259    // but for now we simply drop the message in the rare case this happens.
     260    if (!page)
     261        return;
     262
     263    page->logDiagnosticMessageWithValue(message, description, value);
     264}
     265
    233266} // namespace WebKit
    234267
  • trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h

    r179919 r179972  
    9292    void didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const WebCore::AuthenticationChallenge&, uint64_t challengeID);
    9393    void didDeleteWebsiteData(uint64_t callbackID);
     94    void logDiagnosticMessage(uint64_t pageID, const String& message, const String& description);
     95    void logDiagnosticMessageWithResult(uint64_t pageID, const String& message, const String& description, uint32_t result);
     96    void logDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, const String& value);
    9497
    9598    // ProcessLauncher::Client
  • trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.messages.in

    r179919 r179972  
    2929
    3030    DidDeleteWebsiteData(uint64_t callbackID)
     31
     32    # Diagnostic messages logging
     33    LogDiagnosticMessage(uint64_t pageID, String message, String description)
     34    LogDiagnosticMessageWithResult(uint64_t pageID, String message, String description, uint32_t result)
     35    LogDiagnosticMessageWithValue(uint64_t pageID, String message, String description, String value)
    3136}
    3237
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r179919 r179972  
    989989    void setShouldDispatchFakeMouseMoveEvents(bool);
    990990
     991    // Diagnostic messages logging.
     992    void logDiagnosticMessage(const String& message, const String& description);
     993    void logDiagnosticMessageWithResult(const String& message, const String& description, uint32_t result);
     994    void logDiagnosticMessageWithValue(const String& message, const String& description, const String& value);
     995
    991996private:
    992997    WebPageProxy(PageClient&, WebProcessProxy&, uint64_t pageID, const WebPageConfiguration&);
     
    12381243    void setCursorHiddenUntilMouseMoves(bool);
    12391244
    1240     // Diagnostic messages logging.
    1241     void logDiagnosticMessage(const String& message, const String& description);
    1242     void logDiagnosticMessageWithResult(const String& message, const String& description, uint32_t result);
    1243     void logDiagnosticMessageWithValue(const String& message, const String& description, const String& value);
    1244 
    12451245    void didReceiveEvent(uint32_t opaqueType, bool handled);
    12461246    void stopResponsivenessTimer();
Note: See TracChangeset for help on using the changeset viewer.