mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 711297 - report age of startup cache via telemetry; r=taras
This commit is contained in:
parent
445668e0c7
commit
bcb406168d
@ -40,6 +40,7 @@
|
||||
#include "prio.h"
|
||||
#include "prtypes.h"
|
||||
#include "pldhash.h"
|
||||
#include "nsXPCOMStrings.h"
|
||||
#include "mozilla/scache/StartupCache.h"
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
@ -66,6 +67,7 @@
|
||||
#include "mozilla/Omnijar.h"
|
||||
#include "prenv.h"
|
||||
#include "mozilla/FunctionTimer.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "nsIProtocolHandler.h"
|
||||
@ -237,7 +239,7 @@ StartupCache::Init()
|
||||
false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = LoadArchive();
|
||||
rv = LoadArchive(RECORD_AGE);
|
||||
|
||||
// Sometimes we don't have a cache yet, that's ok.
|
||||
// If it's corrupted, just remove it and start over.
|
||||
@ -258,7 +260,7 @@ StartupCache::Init()
|
||||
* LoadArchive can be called from the main thread or while reloading cache on write thread.
|
||||
*/
|
||||
nsresult
|
||||
StartupCache::LoadArchive()
|
||||
StartupCache::LoadArchive(enum TelemetrifyAge flag)
|
||||
{
|
||||
bool exists;
|
||||
mArchive = NULL;
|
||||
@ -267,7 +269,34 @@ StartupCache::LoadArchive()
|
||||
return NS_ERROR_FILE_NOT_FOUND;
|
||||
|
||||
mArchive = new nsZipArchive();
|
||||
return mArchive->OpenArchive(mFile);
|
||||
rv = mArchive->OpenArchive(mFile);
|
||||
if (NS_FAILED(rv) || flag == IGNORE_AGE)
|
||||
return rv;
|
||||
|
||||
nsCString comment;
|
||||
if (!mArchive->GetComment(comment)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
const char *data;
|
||||
size_t len = NS_CStringGetData(comment, &data);
|
||||
PRTime creationStamp;
|
||||
// We might not have a comment if the startup cache file was created
|
||||
// before we started recording creation times in the comment.
|
||||
if (len == sizeof(creationStamp)) {
|
||||
memcpy(&creationStamp, data, len);
|
||||
PRTime current = PR_Now();
|
||||
PRInt64 diff = current - creationStamp;
|
||||
|
||||
// We can't use AccumulateTimeDelta here because we have no way of
|
||||
// reifying a TimeStamp from creationStamp.
|
||||
PRInt64 usec_per_hour = PR_USEC_PER_SEC * PRInt64(3600);
|
||||
PRInt64 hour_diff = (diff + usec_per_hour - 1) / usec_per_hour;
|
||||
mozilla::Telemetry::Accumulate(Telemetry::STARTUP_CACHE_AGE_HOURS,
|
||||
hour_diff);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
namespace {
|
||||
@ -435,6 +464,17 @@ StartupCache::WriteToDisk()
|
||||
return;
|
||||
}
|
||||
|
||||
// If we didn't have an mArchive member, that means that we failed to
|
||||
// open the startup cache for reading. Therefore, we need to record
|
||||
// the time of creation in a zipfile comment; this will be useful for
|
||||
// Telemetry statistics.
|
||||
PRTime now = PR_Now();
|
||||
if (!mArchive) {
|
||||
nsCString comment;
|
||||
comment.Assign((char *)&now, sizeof(now));
|
||||
zipW->SetComment(comment);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIStringInputStream> stream
|
||||
= do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -445,7 +485,7 @@ StartupCache::WriteToDisk()
|
||||
CacheWriteHolder holder;
|
||||
holder.stream = stream;
|
||||
holder.writer = zipW;
|
||||
holder.time = PR_Now();
|
||||
holder.time = now;
|
||||
|
||||
mTable.Enumerate(CacheCloseHelper, &holder);
|
||||
|
||||
@ -453,8 +493,8 @@ StartupCache::WriteToDisk()
|
||||
mArchive = NULL;
|
||||
zipW->Close();
|
||||
|
||||
// our reader's view of the archive is outdated now, reload it.
|
||||
LoadArchive();
|
||||
// Our reader's view of the archive is outdated now, reload it.
|
||||
LoadArchive(IGNORE_AGE);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -466,7 +506,7 @@ StartupCache::InvalidateCache()
|
||||
mTable.Clear();
|
||||
mArchive = NULL;
|
||||
mFile->Remove(false);
|
||||
LoadArchive();
|
||||
LoadArchive(IGNORE_AGE);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -164,7 +164,12 @@ private:
|
||||
StartupCache();
|
||||
~StartupCache();
|
||||
|
||||
nsresult LoadArchive();
|
||||
enum TelemetrifyAge {
|
||||
IGNORE_AGE = 0,
|
||||
RECORD_AGE = 1
|
||||
};
|
||||
|
||||
nsresult LoadArchive(enum TelemetrifyAge flag);
|
||||
nsresult Init();
|
||||
void WriteToDisk();
|
||||
nsresult ResetStartupWriteTimer();
|
||||
|
@ -131,6 +131,7 @@ HISTOGRAM(MAC_INITFONTLIST_TOTAL, 1, 30000, 10, EXPONENTIAL, "gfxMacPlatformFont
|
||||
|
||||
HISTOGRAM(SYSTEM_FONT_FALLBACK, 1, 100000, 50, EXPONENTIAL, "System font fallback (us)")
|
||||
HISTOGRAM(SYSTEM_FONT_FALLBACK_FIRST, 1, 40000, 20, EXPONENTIAL, "System font fallback, first call (ms)")
|
||||
HISTOGRAM(STARTUP_CACHE_AGE_HOURS, 1, 3000, 20, EXPONENTIAL, "Startup cache age (hours)")
|
||||
|
||||
/**
|
||||
* Word cache - one count for overall lookups, the other for the number of times a word is found
|
||||
|
Loading…
Reference in New Issue
Block a user