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

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

Issue 2873223002: Record resource scheduler UMA (Closed)
Patch Set: rdsmith comment Created 3 years, 6 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 2e1c500cc10cb84f07534a4aeaf5fe4d72200197..f2b329fc15956d5944af049ed228794848a1efc4 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),
+ peak_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",
+ peak_delayable_requests_in_flight_);
+ }
+ if (!((attributes_ & kAttributeDelayable) == kAttributeDelayable)) {
+ UMA_HISTOGRAM_COUNTS_100(
+ "ResourceScheduler.PeakDelayableRequestsInFlight.NonDelayable",
+ peak_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) {
+ peak_delayable_requests_in_flight_ = std::max(
+ peak_delayable_requests_in_flight_, delayable_requests_in_flight);
+ }
+
void set_request_priority_params(const RequestPriorityParams& priority) {
priority_ = priority;
}
@@ -328,6 +344,9 @@ class ResourceScheduler::ScheduledResourceRequest : public ResourceThrottle {
ResourceScheduler* scheduler_;
RequestPriorityParams priority_;
uint32_t fifo_ordering_;
+
+ // Maximum number of delayable requests in-flight when |this| was in-flight.
+ size_t peak_delayable_requests_in_flight_;
// Cached to excessive recomputation in ShouldKeepSearching.
const net::HostPortPair host_port_pair_;
@@ -494,9 +513,40 @@ 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_);
+ UMA_HISTOGRAM_COUNTS_100(
+ "ResourceScheduler.RequestsCount.NonDelayable",
+ in_flight_requests_.size() - in_flight_delayable_count_);
+ UMA_HISTOGRAM_COUNTS_100(
+ "ResourceScheduler.RequestsCount.TotalLayoutBlocking",
+ total_layout_blocking_count_);
+ }
+
void InsertInFlightRequest(ScheduledResourceRequest* request) {
in_flight_requests_.insert(request);
SetRequestAttributes(request, DetermineRequestAttributes(request));
+ RecordRequestCountMetrics();
+
+ 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) {
« 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