Bug 1757833 - Add PerfStat probes for bytecode cache reads, writes, compression, and decompression r=nbp,necko-reviewers,kershaw

Differential Revision: https://phabricator.services.mozilla.com/D145012
This commit is contained in:
Bryan Thrall
2022-05-20 18:25:42 +00:00
parent e7bd237140
commit ab3bb7fe91
5 changed files with 31 additions and 1 deletions

View File

@@ -19,6 +19,7 @@
#include "mozilla/Encoding.h"
#include "mozilla/Logging.h"
#include "mozilla/NotNull.h"
#include "mozilla/PerfStats.h"
#include "mozilla/ScopeExit.h"
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/Utf8.h"
@@ -121,6 +122,7 @@ ScriptLoadHandler::OnIncrementalData(nsIIncrementalStreamLoader* aLoader,
nsCOMPtr<nsIRequest> channelRequest;
aLoader->GetRequest(getter_AddRefs(channelRequest));
auto firstTime = !mPreloadStartNotified;
if (!mPreloadStartNotified) {
mPreloadStartNotified = true;
mRequest->GetScriptLoadContext()->NotifyStart(channelRequest);
@@ -138,6 +140,10 @@ ScriptLoadHandler::OnIncrementalData(nsIIncrementalStreamLoader* aLoader,
NS_ENSURE_SUCCESS(rv, rv);
}
if (mRequest->IsBytecode() && firstTime) {
PerfStats::RecordMeasurementStart(PerfStats::Metric::JSBC_IO_Read);
}
if (mRequest->IsTextSource()) {
if (!EnsureDecoder(aLoader, aData, aDataLength,
/* aEndOfStream = */ false)) {
@@ -341,6 +347,7 @@ ScriptLoadHandler::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
nsCOMPtr<nsIRequest> channelRequest;
aLoader->GetRequest(getter_AddRefs(channelRequest));
auto firstMessage = !mPreloadStartNotified;
if (!mPreloadStartNotified) {
mPreloadStartNotified = true;
mRequest->GetScriptLoadContext()->NotifyStart(channelRequest);
@@ -356,6 +363,12 @@ ScriptLoadHandler::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
NS_ENSURE_SUCCESS(rv, rv);
}
if (mRequest->IsBytecode() && !firstMessage) {
// if firstMessage, then entire stream is in aData, and PerfStats would
// measure 0 time
PerfStats::RecordMeasurementEnd(PerfStats::Metric::JSBC_IO_Read);
}
if (mRequest->IsTextSource()) {
DebugOnly<bool> encoderSet =
EnsureDecoder(aLoader, aData, aDataLength, /* aEndOfStream = */ true);