forked from mirrors/gecko-dev
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:
parent
93bf2e27d6
commit
edc0fa2360
5 changed files with 31 additions and 1 deletions
|
|
@ -7,6 +7,7 @@
|
|||
#include "zlib.h"
|
||||
#include "ScriptLoadRequest.h"
|
||||
#include "ScriptLoader.h"
|
||||
#include "mozilla/PerfStats.h"
|
||||
#include "mozilla/ProfilerMarkers.h"
|
||||
#include "mozilla/Vector.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
|
|
@ -83,6 +84,8 @@ bool ScriptBytecodeCompress(Vector<uint8_t>& aBytecodeBuf,
|
|||
// TODO probably need to move this to a helper thread
|
||||
|
||||
AUTO_PROFILER_MARKER_TEXT("ScriptBytecodeCompress", JS, {}, ""_ns);
|
||||
PerfStats::AutoMetricRecording<PerfStats::Metric::JSBC_Compression>
|
||||
autoRecording;
|
||||
|
||||
ScriptBytecodeDataLayout uncompressedLayout(aBytecodeBuf, aBytecodeOffset);
|
||||
ScriptBytecodeCompressedDataLayout compressedLayout(
|
||||
|
|
@ -129,6 +132,8 @@ bool ScriptBytecodeDecompress(Vector<uint8_t>& aCompressedBytecodeBuf,
|
|||
size_t aBytecodeOffset,
|
||||
Vector<uint8_t>& aBytecodeBufOut) {
|
||||
AUTO_PROFILER_MARKER_TEXT("ScriptBytecodeDecompress", JS, {}, ""_ns);
|
||||
PerfStats::AutoMetricRecording<PerfStats::Metric::JSBC_Decompression>
|
||||
autoRecording;
|
||||
|
||||
ScriptBytecodeDataLayout uncompressedLayout(aBytecodeBufOut, aBytecodeOffset);
|
||||
ScriptBytecodeCompressedDataLayout compressedLayout(
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/net/AltDataOutputStreamParent.h"
|
||||
#include "mozilla/PerfStats.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "nsIAsyncOutputStream.h"
|
||||
|
||||
|
|
@ -17,6 +18,7 @@ NS_IMPL_ISUPPORTS0(AltDataOutputStreamParent)
|
|||
AltDataOutputStreamParent::AltDataOutputStreamParent(nsIOutputStream* aStream)
|
||||
: mOutputStream(aStream), mStatus(NS_OK), mIPCOpen(true) {
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Main thread only");
|
||||
PerfStats::RecordMeasurementStart(PerfStats::Metric::JSBC_IO_Write);
|
||||
}
|
||||
|
||||
AltDataOutputStreamParent::~AltDataOutputStreamParent() {
|
||||
|
|
@ -45,6 +47,8 @@ mozilla::ipc::IPCResult AltDataOutputStreamParent::RecvWriteData(
|
|||
|
||||
mozilla::ipc::IPCResult AltDataOutputStreamParent::RecvClose(
|
||||
const nsresult& aStatus) {
|
||||
PerfStats::RecordMeasurementEnd(PerfStats::Metric::JSBC_IO_Write);
|
||||
|
||||
if (NS_FAILED(mStatus)) {
|
||||
if (mIPCOpen) {
|
||||
Unused << SendError(mStatus);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,11 @@ static const char* const sMetricNames[] = {"DisplayListBuilding",
|
|||
"Styling",
|
||||
"HttpChannelCompletion",
|
||||
"HttpChannelCompletion_Network",
|
||||
"HttpChannelCompletion_Cache"};
|
||||
"HttpChannelCompletion_Cache",
|
||||
"JSBC_Compression",
|
||||
"JSBC_Decompression",
|
||||
"JSBC_IO_Read",
|
||||
"JSBC_IO_Write"};
|
||||
|
||||
static_assert(sizeof(sMetricNames) / sizeof(sMetricNames[0]) ==
|
||||
static_cast<uint64_t>(PerfStats::Metric::Max));
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@ class PerfStats {
|
|||
HttpChannelCompletion,
|
||||
HttpChannelCompletion_Network,
|
||||
HttpChannelCompletion_Cache,
|
||||
JSBC_Compression,
|
||||
JSBC_Decompression,
|
||||
JSBC_IO_Read,
|
||||
JSBC_IO_Write,
|
||||
Max
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue