Skip to content

Commit

Permalink
Bug 1883391 - add telemetry to collect delta between OnDataFinished a…
Browse files Browse the repository at this point in the history
…nd OnStopRequest in CSSLoader. r=necko-reviewers,valentin

Differential Revision: https://phabricator.services.mozilla.com/D203945
  • Loading branch information
MayyaSunil committed Mar 10, 2024
1 parent e1fbb2d commit 0b8a496
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
11 changes: 11 additions & 0 deletions layout/style/StreamLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "mozilla/css/StreamLoader.h"
#include "mozilla/StaticPrefs_network.h"
#include "mozilla/Encoding.h"
#include "mozilla/glean/GleanMetrics.h"
#include "mozilla/TaskQueue.h"
#include "nsContentUtils.h"
#include "nsIChannel.h"
Expand Down Expand Up @@ -116,6 +117,13 @@ StreamLoader::OnStopRequest(nsIRequest* aRequest, nsresult aStatus) {
// Resolution of parse promise fires onLoadEvent and this should not happen
// before main thread OnStopRequest is dispatched.
if (NS_IsMainThread()) {
if (mOnDataFinishedTime) {
// collect telemetry for the delta between OnDataFinished and
// OnStopRequest
TimeDuration delta = (TimeStamp::Now() - mOnDataFinishedTime);
glean::networking::http_content_cssloader_ondatafinished_to_onstop_delay
.AccumulateRawDuration(delta);
}
mSheetLoadData->mSheet->BlockOrUnblockParsePromise(false);
}

Expand Down Expand Up @@ -230,6 +238,9 @@ void StreamLoader::HandleBOM() {
NS_IMETHODIMP
StreamLoader::OnDataFinished(nsresult aResult) {
if (StaticPrefs::network_send_OnDataFinished_cssLoader()) {
MOZ_ASSERT(mOnDataFinishedTime.IsNull(),
"OnDataFinished should only be called once");
mOnDataFinishedTime = TimeStamp::Now();
return OnStopRequest(mRequest, aResult);
}

Expand Down
2 changes: 2 additions & 0 deletions layout/style/StreamLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class StreamLoader : public nsIThreadRetargetableStreamListener {
bool mOnStopProcessingDone{false};
RefPtr<SheetLoadDataHolder> mMainThreadSheetLoadData;

mozilla::TimeStamp mOnDataFinishedTime;

#ifdef NIGHTLY_BUILD
bool mChannelOpenFailed = false;
#endif
Expand Down
15 changes: 15 additions & 0 deletions netwerk/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,21 @@ networking:
- rjesup@mozilla.com
expires: 130

http_content_cssloader_ondatafinished_to_onstop_delay:
type: timing_distribution
time_unit: millisecond
description: >
The time between processing OnDataFinished and processing OnStopRequest for CSSLoader in the content process
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1883391
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1883391
data_sensitivity:
- technical
notification_emails:
- necko@mozilla.com
expires: 130

http_1_download_throughput:
type: custom_distribution
unit: mbps
Expand Down

0 comments on commit 0b8a496

Please sign in to comment.