Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: content/browser/loader/resource_scheduler.cc

Issue 2873223002: Record resource scheduler UMA (Closed)
Patch Set: ps Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/loader/resource_scheduler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/loader/resource_scheduler.cc
diff --git a/content/browser/loader/resource_scheduler.cc b/content/browser/loader/resource_scheduler.cc
index 774f698c066db9ea37c4ba26caef154d2667ece8..0f4048919472b0e99c68db21b0c4cbd2cf88ec84 100644
--- a/content/browser/loader/resource_scheduler.cc
+++ b/content/browser/loader/resource_scheduler.cc
@@ -227,6 +227,7 @@ class ResourceScheduler::ScheduledResourceRequest : public ResourceThrottle {
scheduler_(scheduler),
priority_(priority),
fifo_ordering_(0),
+ delayable_requests_in_flight_(0u),
host_port_pair_(net::HostPortPair::FromURL(request->url())),
weak_ptr_factory_(this) {
DCHECK(!request_->GetUserData(kUserDataKey));
@@ -234,6 +235,16 @@ class ResourceScheduler::ScheduledResourceRequest : public ResourceThrottle {
}
~ScheduledResourceRequest() override {
+ if ((attributes_ & kAttributeLayoutBlocking) == kAttributeLayoutBlocking) {
+ UMA_HISTOGRAM_COUNTS_100(
+ "ResourceScheduler.PeakDelayableRequestsInFlight.LayoutBlocking",
+ delayable_requests_in_flight_);
+ }
+ if (!((attributes_ & kAttributeDelayable) == kAttributeDelayable)) {
+ UMA_HISTOGRAM_COUNTS_100(
+ "ResourceScheduler.PeakDelayableRequestsInFlight.NonDelayable",
+ delayable_requests_in_flight_);
+ }
request_->RemoveUserData(kUserDataKey);
scheduler_->RemoveRequest(this);
}
@@ -274,6 +285,11 @@ class ResourceScheduler::ScheduledResourceRequest : public ResourceThrottle {
ready_ = true;
}
+ void UpdateDelayableRequestsInFlight(size_t delayable_requests_in_flight) {
+ delayable_requests_in_flight_ =
+ std::max(delayable_requests_in_flight_, delayable_requests_in_flight);
+ }
+
void set_request_priority_params(const RequestPriorityParams& priority) {
priority_ = priority;
}
@@ -328,6 +344,10 @@ class ResourceScheduler::ScheduledResourceRequest : public ResourceThrottle {
ResourceScheduler* scheduler_;
RequestPriorityParams priority_;
uint32_t fifo_ordering_;
+
+ // True if a delayable request was in-flight at the same when |this| was
+ // in-flight.
Randy Smith (Not in Mondays) 2017/05/21 21:43:56 I think the comment's out of date? Sounds like it
tbansal1 2017/05/25 01:07:46 Thanks. Fixed.
+ size_t delayable_requests_in_flight_;
// Cached to excessive recomputation in ShouldKeepSearching.
const net::HostPortPair host_port_pair_;
@@ -494,9 +514,55 @@ class ResourceScheduler::Client {
YIELD_SCHEDULER
};
+ // Records the metrics related to number of requests in flight.
+ void RecordRequestCountMetrics() const {
+ UMA_HISTOGRAM_COUNTS_100("ResourceScheduler.RequestsCount.All",
+ in_flight_requests_.size());
+ UMA_HISTOGRAM_COUNTS_100("ResourceScheduler.RequestsCount.Delayable",
+ in_flight_delayable_count_);
+
+ size_t non_delayable_in_flight_count =
+ in_flight_requests_.size() - in_flight_delayable_count_;
+
+ UMA_HISTOGRAM_COUNTS_100("ResourceScheduler.RequestsCount.NonDelayable",
+ non_delayable_in_flight_count);
Randy Smith (Not in Mondays) 2017/05/21 21:43:56 I don't have strong objections, but histograms do
tbansal1 2017/05/25 01:07:46 I am not sure if this is duplicate of some other h
Randy Smith (Not in Mondays) 2017/05/25 17:40:12 Good point, though it's possible with some serious
tbansal1 2017/05/31 06:31:21 Yes, for now I think it is useful to record the di
+ UMA_HISTOGRAM_COUNTS_100(
+ "ResourceScheduler.RequestsCount.TotalLayoutBlocking",
+ total_layout_blocking_count_);
+
+ if (total_layout_blocking_count_ > 0) {
+ UMA_HISTOGRAM_COUNTS_100(
+ "ResourceScheduler.RequestsCount.DelayableWhenLayoutBlocking",
+ in_flight_delayable_count_);
+ }
+
+ if (non_delayable_in_flight_count > 0) {
+ UMA_HISTOGRAM_COUNTS_100(
+ "ResourceScheduler.RequestsCount.DelayableWhenNonDelayable",
+ in_flight_delayable_count_);
+ }
+ }
+
void InsertInFlightRequest(ScheduledResourceRequest* request) {
in_flight_requests_.insert(request);
SetRequestAttributes(request, DetermineRequestAttributes(request));
+ RecordRequestCountMetrics();
Randy Smith (Not in Mondays) 2017/05/21 21:43:56 I remain uncertain that you're going to get good s
tbansal1 2017/05/25 01:07:46 I agree with the spirit of this concern. The goal
Randy Smith (Not in Mondays) 2017/05/25 17:40:12 My problem is that I'm not a statistician, though
tbansal1 2017/05/31 06:31:21 Done.
+
+ if (RequestAttributesAreSet(request->attributes(), kAttributeDelayable)) {
+ // Notify all in-flight with the new count of in-flight delayable
+ // requests.
+ for (RequestSet::const_iterator it = in_flight_requests_.begin();
+ it != in_flight_requests_.end(); ++it) {
+ (*it)->UpdateDelayableRequestsInFlight(in_flight_delayable_count_);
+ }
+ }
+
+ if (RequestAttributesAreSet(request->attributes(),
+ kAttributeLayoutBlocking) ||
+ !RequestAttributesAreSet(request->attributes(), kAttributeDelayable)) {
+ // |request| is either a layout blocking or a non-delayable request.
+ request->UpdateDelayableRequestsInFlight(in_flight_delayable_count_);
+ }
}
void EraseInFlightRequest(ScheduledResourceRequest* request) {
@@ -504,12 +570,14 @@ class ResourceScheduler::Client {
DCHECK_EQ(1u, erased);
// Clear any special state that we were tracking for this request.
SetRequestAttributes(request, kAttributeNone);
+ RecordRequestCountMetrics();
}
void ClearInFlightRequests() {
in_flight_requests_.clear();
in_flight_delayable_count_ = 0;
total_layout_blocking_count_ = 0;
+ RecordRequestCountMetrics();
}
size_t CountRequestsWithAttributes(
« no previous file with comments | « no previous file | content/browser/loader/resource_scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698