Bug 1775358 - Add a profiling marker to nsHttpConnectionMgr::SpeculativeConnect r=necko-reviewers,dragana

Speculative connects can have a significant performance impact so it will be useful to be able to track them.

Differential Revision: https://phabricator.services.mozilla.com/D149992
This commit is contained in:
Andrew Creskey 2023-01-24 15:31:03 +00:00
Родитель e6737c1266
Коммит 1308dc5edb
1 изменённых файлов: 31 добавлений и 0 удалений

Просмотреть файл

@ -20,6 +20,7 @@
#include "NullHttpTransaction.h"
#include "SpeculativeTransaction.h"
#include "mozilla/Components.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/SpinEventLoopUntil.h"
#include "mozilla/StaticPrefs_network.h"
#include "mozilla/Telemetry.h"
@ -49,6 +50,32 @@
#include "nsSocketTransportService2.h"
#include "nsStreamUtils.h"
using namespace mozilla;
namespace geckoprofiler::markers {
struct UrlMarker {
static constexpr Span<const char> MarkerTypeName() {
return MakeStringSpan("Url");
}
static void StreamJSONMarkerData(
mozilla::baseprofiler::SpliceableJSONWriter& aWriter,
const mozilla::ProfilerString8View& aURL) {
if (aURL.Length() != 0) {
aWriter.StringProperty("url", aURL);
}
}
static MarkerSchema MarkerTypeDisplay() {
using MS = MarkerSchema;
MS schema(MS::Location::MarkerChart, MS::Location::MarkerTable);
schema.SetTableLabel("{marker.name} - {marker.data.url}");
schema.AddKeyFormat("url", MS::Format::Url);
return schema;
}
};
} // namespace geckoprofiler::markers
namespace mozilla::net {
//-----------------------------------------------------------------------------
@ -476,6 +503,10 @@ nsresult nsHttpConnectionMgr::SpeculativeConnect(
return NS_OK;
}
nsCString url = ci->EndToEndSSL() ? "https://"_ns : "http://"_ns;
url += ci->GetOrigin();
PROFILER_MARKER("SpeculativeConnect", NETWORK, {}, UrlMarker, url);
RefPtr<SpeculativeConnectArgs> args = new SpeculativeConnectArgs();
// Wrap up the callbacks and the target to ensure they're released on the