Commit 3133179d authored by Jianfeng Wang's avatar Jianfeng Wang Committed by Commit Bot

Refactor the code for finalizing a measurement period

Move the code for finalizing the current measurement period to a
separate function. It exports the tracked variables before they are
reset.

Change-Id: If7150cb9095a43e7eeff9cad9e684ed0c8cead15
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1711094
Commit-Queue: Jianfeng Wang <jfwang@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#679721}
parent fcb7f99e
......@@ -276,32 +276,7 @@ void NetworkCongestionAnalyzer::UpdatePeakDelayMapping(
return;
if (ShouldStartNewMeasurement(delay, count_inflight_requests)) {
// This is the logic to export the tracked mapping data from the last
// measurement period.
// Updates the count of in-flight requests that would likely cause a high
// network queueing delay later.
if (peak_queueing_delay_ >=
base::TimeDelta::FromMilliseconds(kHighQueueingDelayMsec)) {
count_inflight_requests_causing_high_delay_ =
count_inflight_requests_for_peak_queueing_delay_;
}
size_t peak_queueing_delay_level =
ComputePeakQueueingDelayLevel(peak_queueing_delay_);
DCHECK_GE(kQueueingDelayLevelMaxVal, peak_queueing_delay_level);
if (peak_queueing_delay_level >= kQueueingDelayLevelMinVal &&
peak_queueing_delay_level <= kQueueingDelayLevelMaxVal &&
peak_count_inflight_requests_measurement_period_ >= 3) {
// Records the count of in-flight requests causing the peak queueing delay
// within the current measurement period. These samples are bucketized
// into 10 peak queueing delay levels.
base::UmaHistogramCounts100(
"NQE.CongestionAnalyzer.CountInflightRequestsForPeakQueueingDelay."
"Level" +
base::NumberToString(peak_queueing_delay_level),
count_inflight_requests_for_peak_queueing_delay_);
}
FinalizeCurrentMeasurementPeriod();
// Resets the tracked data for the new measurement period.
peak_queueing_delay_ = delay;
......@@ -329,6 +304,39 @@ void NetworkCongestionAnalyzer::UpdatePeakDelayMapping(
}
}
void NetworkCongestionAnalyzer::FinalizeCurrentMeasurementPeriod() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Does nothing if the peak count of in-flight requests is less than 3.
if (peak_count_inflight_requests_measurement_period_ < 3)
return;
// Exports the tracked mapping data from the current measurement period.
// Updates the count of in-flight requests that would likely cause a high
// network queueing delay.
if (peak_queueing_delay_ >=
base::TimeDelta::FromMilliseconds(kHighQueueingDelayMsec)) {
count_inflight_requests_causing_high_delay_ =
count_inflight_requests_for_peak_queueing_delay_;
}
size_t peak_queueing_delay_level =
ComputePeakQueueingDelayLevel(peak_queueing_delay_);
DCHECK_GE(kQueueingDelayLevelMaxVal, peak_queueing_delay_level);
if (peak_queueing_delay_level >= kQueueingDelayLevelMinVal &&
peak_queueing_delay_level <= kQueueingDelayLevelMaxVal) {
// Records the count of in-flight requests causing the peak queueing delay
// within the current measurement period. These samples are bucketized
// into 10 peak queueing delay levels.
base::UmaHistogramCounts100(
"NQE.CongestionAnalyzer.CountInflightRequestsForPeakQueueingDelay."
"Level" +
base::NumberToString(peak_queueing_delay_level),
count_inflight_requests_for_peak_queueing_delay_);
}
}
void NetworkCongestionAnalyzer::set_recent_downlink_throughput_kbps(
const int32_t downlink_kbps) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
......
......@@ -109,6 +109,13 @@ class NET_EXPORT_PRIVATE NetworkCongestionAnalyzer {
bool ShouldStartNewMeasurement(const base::TimeDelta& delay,
size_t count_inflight_requests);
// Finalizes the current peak queueing delay measurement period before a new
// measurement period starts. It exports the tracked data, such as the peak
// queueing delay and the count of in-flight requests causing the peak delay
// before they are reset. Only exports data when there are at least 3
// concurrent requests within the current measurement period.
void FinalizeCurrentMeasurementPeriod();
// Starts tracking the peak queueing delay for |request|.
void TrackPeakQueueingDelayBegin(const URLRequest* request);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment