mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 723124 - Telemetry for time needed for idle frecency update.
r=dietrich
This commit is contained in:
parent
de261a7af6
commit
03cb8e0aaa
@ -423,5 +423,34 @@ NS_IMPL_THREADSAFE_ISUPPORTS2(
|
||||
, nsIRunnable
|
||||
)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// AsyncStatementCallbackNotifier
|
||||
|
||||
NS_IMETHODIMP
|
||||
AsyncStatementCallbackNotifier::HandleCompletion(PRUint16 aReason)
|
||||
{
|
||||
if (aReason != mozIStorageStatementCallback::REASON_FINISHED)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
if (obs) {
|
||||
(void)obs->NotifyObservers(nsnull, mTopic, nsnull);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// AsyncStatementCallbackNotifier
|
||||
|
||||
NS_IMETHODIMP
|
||||
AsyncStatementTelemetryTimer::HandleCompletion(PRUint16 aReason)
|
||||
{
|
||||
if (aReason == mozIStorageStatementCallback::REASON_FINISHED) {
|
||||
Telemetry::AccumulateTimeDelta(mHistogramId, mStart);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace places
|
||||
} // namespace mozilla
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "nsIURI.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsProxyRelease.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace places {
|
||||
@ -260,6 +261,42 @@ protected:
|
||||
const char* const mTopic;
|
||||
};
|
||||
|
||||
/**
|
||||
* Used to notify a topic to system observers on async execute completion.
|
||||
*/
|
||||
class AsyncStatementCallbackNotifier : public AsyncStatementCallback
|
||||
{
|
||||
public:
|
||||
AsyncStatementCallbackNotifier(const char* aTopic)
|
||||
: mTopic(aTopic)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD HandleCompletion(PRUint16 aReason);
|
||||
|
||||
private:
|
||||
const char* mTopic;
|
||||
};
|
||||
|
||||
/**
|
||||
* Used to notify a topic to system observers on async execute completion.
|
||||
*/
|
||||
class AsyncStatementTelemetryTimer : public AsyncStatementCallback
|
||||
{
|
||||
public:
|
||||
AsyncStatementTelemetryTimer(Telemetry::ID aHistogramId,
|
||||
TimeStamp aStart = TimeStamp::Now())
|
||||
: mHistogramId(aHistogramId)
|
||||
, mStart(aStart)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD HandleCompletion(PRUint16 aReason);
|
||||
|
||||
private:
|
||||
const Telemetry::ID mHistogramId;
|
||||
const TimeStamp mStart;
|
||||
};
|
||||
} // namespace places
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -277,36 +277,6 @@ protected:
|
||||
nsNavHistory& mNavHistory;
|
||||
};
|
||||
|
||||
|
||||
// Used to notify a topic to system observers on async execute completion.
|
||||
class AsyncStatementCallbackNotifier : public AsyncStatementCallback
|
||||
{
|
||||
public:
|
||||
AsyncStatementCallbackNotifier(const char* aTopic)
|
||||
: mTopic(aTopic)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD HandleCompletion(PRUint16 aReason);
|
||||
|
||||
private:
|
||||
const char* mTopic;
|
||||
};
|
||||
|
||||
NS_IMETHODIMP
|
||||
AsyncStatementCallbackNotifier::HandleCompletion(PRUint16 aReason)
|
||||
{
|
||||
if (aReason != mozIStorageStatementCallback::REASON_FINISHED)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
if (obs) {
|
||||
(void)obs->NotifyObservers(nsnull, mTopic, nsnull);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // anonymouse namespace
|
||||
|
||||
|
||||
@ -3988,8 +3958,10 @@ nsNavHistory::DecayFrecency()
|
||||
deleteAdaptive.get()
|
||||
};
|
||||
nsCOMPtr<mozIStoragePendingStatement> ps;
|
||||
rv = mDB->MainConn()->ExecuteAsync(stmts, ArrayLength(stmts), nsnull,
|
||||
getter_AddRefs(ps));
|
||||
nsRefPtr<AsyncStatementTelemetryTimer> cb =
|
||||
new AsyncStatementTelemetryTimer(Telemetry::PLACES_IDLE_FRECENCY_DECAY_TIME_MS);
|
||||
rv = mDB->MainConn()->ExecuteAsync(stmts, ArrayLength(stmts), cb,
|
||||
getter_AddRefs(ps));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -20,35 +20,9 @@ let histograms = {
|
||||
PLACES_DATABASE_SIZE_PER_PAGE_B: function (val) do_check_true(val > 0),
|
||||
PLACES_EXPIRATION_STEPS_TO_CLEAN: function (val) do_check_true(val > 1),
|
||||
//PLACES_AUTOCOMPLETE_1ST_RESULT_TIME_MS: function (val) do_check_true(val > 1),
|
||||
PLACES_IDLE_FRECENCY_DECAY_TIME_MS: function (val) do_check_true(val > 0),
|
||||
}
|
||||
|
||||
// This sucks, but due to nsITelemetry using [implicit_jscontext], it's
|
||||
// impossible to implement it in js, so no fancy service factory replacements.
|
||||
// This mock implements only the telemetry methods used by Places.
|
||||
XPCOMUtils.defineLazyGetter(Services, "telemetry", function () {
|
||||
return {
|
||||
getHistogramById: function FT_getHistogramById(id) {
|
||||
if (id in histograms) {
|
||||
return {
|
||||
add: function FH_add(val) {
|
||||
do_log_info("Testing probe " + id);
|
||||
histograms[id](val);
|
||||
delete histograms[id];
|
||||
if (Object.keys(histograms).length == 0)
|
||||
do_test_finished();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
add: function FH_add(val) {
|
||||
do_log_info("Unknown probe " + id);
|
||||
}
|
||||
};
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
|
||||
@ -120,4 +94,19 @@ function continue_test() {
|
||||
controller.input = new AutoCompleteInput(["history"]);
|
||||
controller.startSearch("moz");
|
||||
*/
|
||||
|
||||
// Test idle probes.
|
||||
PlacesUtils.history.QueryInterface(Ci.nsIObserver)
|
||||
.observe(null, "idle-daily", null);
|
||||
|
||||
waitForAsyncUpdates(check_telemetry);
|
||||
}
|
||||
|
||||
function check_telemetry() {
|
||||
for (let histogramId in histograms) {
|
||||
do_log_info("checking histogram " + histogramId);
|
||||
let validate = histograms[histogramId];
|
||||
validate(Services.telemetry.getHistogramById(histogramId).snapshot().sum);
|
||||
}
|
||||
do_test_finished();
|
||||
}
|
||||
|
@ -287,6 +287,7 @@ HISTOGRAM(PLACES_DATABASE_PAGESIZE_B, 1024, 32768, 10, EXPONENTIAL, "PLACES: Dat
|
||||
HISTOGRAM(PLACES_DATABASE_SIZE_PER_PAGE_B, 500, 10240, 20, EXPONENTIAL, "PLACES: Average size of a place in the database (bytes)")
|
||||
HISTOGRAM(PLACES_EXPIRATION_STEPS_TO_CLEAN, 1, 10, 10, LINEAR, "PLACES: Expiration steps to cleanup the database")
|
||||
HISTOGRAM(PLACES_AUTOCOMPLETE_1ST_RESULT_TIME_MS, 50, 500, 10, EXPONENTIAL, "PLACES: Time for first autocomplete result if > 50ms (ms)")
|
||||
HISTOGRAM(PLACES_IDLE_FRECENCY_DECAY_TIME_MS, 50, 10000, 10, EXPONENTIAL, "PLACES: Time to decay all frecencies values on idle (ms)")
|
||||
|
||||
/**
|
||||
* Updater telemetry.
|
||||
|
Loading…
Reference in New Issue
Block a user