Bug 1196237 - Relemetry after dns shutdown. r=dragana

This commit is contained in:
Patrick McManus 2015-08-20 12:14:40 -04:00
parent f1902f433c
commit 2c0ea76ca5
2 changed files with 38 additions and 30 deletions

View File

@ -522,13 +522,13 @@ nsHostResolver::nsHostResolver(uint32_t maxCacheEntries,
, mDefaultGracePeriod(defaultGracePeriod)
, mLock("nsHostResolver.mLock")
, mIdleThreadCV(mLock, "nsHostResolver.mIdleThreadCV")
, mDB(&gHostDB_ops, sizeof(nsHostDBEnt), 0)
, mEvictionQSize(0)
, mShutdown(true)
, mNumIdleThreads(0)
, mThreadCount(0)
, mActiveAnyThreadCount(0)
, mDB(&gHostDB_ops, sizeof(nsHostDBEnt), 0)
, mEvictionQSize(0)
, mPendingCount(0)
, mShutdown(true)
{
mCreationTime = PR_Now();
PR_INIT_CLIST(&mHighQ);
@ -1070,10 +1070,10 @@ nsHostResolver::IssueLookup(nsHostRecord *rec)
rv = ConditionallyCreateThread(rec);
LOG ((" DNS thread counters: total=%d any-live=%d idle=%d pending=%d\n",
mThreadCount,
mActiveAnyThreadCount,
mNumIdleThreads,
mPendingCount));
static_cast<uint32_t>(mThreadCount),
static_cast<uint32_t>(mActiveAnyThreadCount),
static_cast<uint32_t>(mNumIdleThreads),
static_cast<uint32_t>(mPendingCount)));
return rv;
}
@ -1111,7 +1111,7 @@ nsHostResolver::GetHostToLookup(nsHostRecord **result)
{
bool timedOut = false;
PRIntervalTime epoch, now, timeout;
MutexAutoLock lock(mLock);
timeout = (mNumIdleThreads >= HighThreadThreshold) ? mShortIdleTimeout : mLongIdleTimeout;
@ -1179,7 +1179,6 @@ nsHostResolver::GetHostToLookup(nsHostRecord **result)
}
// tell thread to exit...
mThreadCount--;
return false;
}
@ -1411,24 +1410,31 @@ nsHostResolver::ThreadFunc(void *arg)
getTtl);
}
#endif
TimeDuration elapsed = TimeStamp::Now() - startTime;
uint32_t millis = static_cast<uint32_t>(elapsed.ToMilliseconds());
if (NS_SUCCEEDED(status)) {
Telemetry::ID histogramID;
if (!rec->addr_info_gencnt) {
// Time for initial lookup.
histogramID = Telemetry::DNS_LOOKUP_TIME;
} else if (!getTtl) {
// Time for renewal; categorized by expiration strategy.
histogramID = Telemetry::DNS_RENEWAL_TIME;
} else {
// Time to get TTL; categorized by expiration strategy.
histogramID = Telemetry::DNS_RENEWAL_TIME_FOR_TTL;
{ // obtain lock to check shutdown and manage inter-module telemetry
MutexAutoLock lock(resolver->mLock);
if (!resolver->mShutdown) {
TimeDuration elapsed = TimeStamp::Now() - startTime;
uint32_t millis = static_cast<uint32_t>(elapsed.ToMilliseconds());
if (NS_SUCCEEDED(status)) {
Telemetry::ID histogramID;
if (!rec->addr_info_gencnt) {
// Time for initial lookup.
histogramID = Telemetry::DNS_LOOKUP_TIME;
} else if (!getTtl) {
// Time for renewal; categorized by expiration strategy.
histogramID = Telemetry::DNS_RENEWAL_TIME;
} else {
// Time to get TTL; categorized by expiration strategy.
histogramID = Telemetry::DNS_RENEWAL_TIME_FOR_TTL;
}
Telemetry::Accumulate(histogramID, millis);
} else {
Telemetry::Accumulate(Telemetry::DNS_FAILED_LOOKUP_TIME, millis);
}
}
Telemetry::Accumulate(histogramID, millis);
} else {
Telemetry::Accumulate(Telemetry::DNS_FAILED_LOOKUP_TIME, millis);
}
// OnLookupComplete may release "rec", long before we lose it.
@ -1444,6 +1450,7 @@ nsHostResolver::ThreadFunc(void *arg)
rec = nullptr;
}
}
resolver->mThreadCount--;
NS_RELEASE(resolver);
LOG(("DNS lookup thread - queue empty, thread finished.\n"));
}

View File

@ -342,21 +342,22 @@ private:
uint32_t mDefaultGracePeriod; // granularity seconds
mutable Mutex mLock; // mutable so SizeOfIncludingThis can be const
CondVar mIdleThreadCV;
uint32_t mNumIdleThreads;
uint32_t mThreadCount;
uint32_t mActiveAnyThreadCount;
PLDHashTable mDB;
PRCList mHighQ;
PRCList mMediumQ;
PRCList mLowQ;
PRCList mEvictionQ;
uint32_t mEvictionQSize;
uint32_t mPendingCount;
PRTime mCreationTime;
bool mShutdown;
PRIntervalTime mLongIdleTimeout;
PRIntervalTime mShortIdleTimeout;
mozilla::Atomic<bool> mShutdown;
mozilla::Atomic<uint32_t> mNumIdleThreads;
mozilla::Atomic<uint32_t> mThreadCount;
mozilla::Atomic<uint32_t> mActiveAnyThreadCount;
mozilla::Atomic<uint32_t> mPendingCount;
// Set the expiration time stamps appropriately.
void PrepareRecordExpiration(nsHostRecord* rec) const;