Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/quic/quic_connection_logger.h" | 5 #include "net/quic/quic_connection_logger.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 762 int range_start = 0; | 762 int range_start = 0; |
| 763 for (int i = 1; i <= valid_bits_in_mask; ++i) { | 763 for (int i = 1; i <= valid_bits_in_mask; ++i) { |
| 764 bits_so_far += bit_mask_of_packets & 1; | 764 bits_so_far += bit_mask_of_packets & 1; |
| 765 bit_mask_of_packets >>= 1; | 765 bit_mask_of_packets >>= 1; |
| 766 DCHECK_LT(range_start + bits_so_far, kBoundingSampleInCumulativeHistogram); | 766 DCHECK_LT(range_start + bits_so_far, kBoundingSampleInCumulativeHistogram); |
| 767 histogram->Add(range_start + bits_so_far); | 767 histogram->Add(range_start + bits_so_far); |
| 768 range_start += i + 1; | 768 range_start += i + 1; |
| 769 } | 769 } |
| 770 } | 770 } |
| 771 | 771 |
| 772 float QuicConnectionLogger::PacketLossRate() const { | |
|
Ryan Hamilton
2015/03/23 02:31:06
This is the received packet loss rate, right? (As
ramant (doing other things)
2015/03/24 03:07:22
Done.
| |
| 773 // Never received a packet from server, very lossy connection? | |
| 774 if (largest_received_packet_sequence_number_ == 0) | |
| 775 return 1000.0f; | |
| 776 QuicPacketSequenceNumber divisor = largest_received_packet_sequence_number_; | |
| 777 QuicPacketSequenceNumber numerator = divisor - num_packets_received_; | |
| 778 if (divisor < 100000) | |
| 779 numerator *= 1000; | |
| 780 else | |
| 781 divisor /= 1000; | |
| 782 return numerator / divisor; | |
|
Ryan Hamilton
2015/03/23 02:31:06
So the reason this code uses * 1000 or / 1000 is b
ramant (doing other things)
2015/03/24 03:07:22
Done.
| |
| 783 } | |
| 784 | |
| 772 void QuicConnectionLogger::RecordAggregatePacketLossRate() const { | 785 void QuicConnectionLogger::RecordAggregatePacketLossRate() const { |
| 773 // For short connections under 22 packets in length, we'll rely on the | 786 // For short connections under 22 packets in length, we'll rely on the |
| 774 // Net.QuicSession.21CumulativePacketsReceived_* histogram to indicate packet | 787 // Net.QuicSession.21CumulativePacketsReceived_* histogram to indicate packet |
| 775 // loss rates. This way we avoid tremendously anomalous contributions to our | 788 // loss rates. This way we avoid tremendously anomalous contributions to our |
| 776 // histogram. (e.g., if we only got 5 packets, but lost 1, we'd otherwise | 789 // histogram. (e.g., if we only got 5 packets, but lost 1, we'd otherwise |
| 777 // record a 20% loss in this histogram!). We may still get some strange data | 790 // record a 20% loss in this histogram!). We may still get some strange data |
| 778 // (1 loss in 22 is still high :-/). | 791 // (1 loss in 22 is still high :-/). |
| 779 if (largest_received_packet_sequence_number_ <= 21) | 792 if (largest_received_packet_sequence_number_ <= 21) |
| 780 return; | 793 return; |
| 781 | 794 |
| 782 QuicPacketSequenceNumber divisor = largest_received_packet_sequence_number_; | |
| 783 QuicPacketSequenceNumber numerator = divisor - num_packets_received_; | |
| 784 if (divisor < 100000) | |
| 785 numerator *= 1000; | |
| 786 else | |
| 787 divisor /= 1000; | |
| 788 string prefix("Net.QuicSession.PacketLossRate_"); | 795 string prefix("Net.QuicSession.PacketLossRate_"); |
| 789 base::HistogramBase* histogram = base::Histogram::FactoryGet( | 796 base::HistogramBase* histogram = base::Histogram::FactoryGet( |
| 790 prefix + connection_description_, 1, 1000, 75, | 797 prefix + connection_description_, 1, 1000, 75, |
| 791 base::HistogramBase::kUmaTargetedHistogramFlag); | 798 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 792 histogram->Add(static_cast<base::HistogramBase::Sample>(numerator / divisor)); | 799 histogram->Add(static_cast<base::HistogramBase::Sample>(PacketLossRate())); |
| 793 } | 800 } |
| 794 | 801 |
| 795 void QuicConnectionLogger::RecordLossHistograms() const { | 802 void QuicConnectionLogger::RecordLossHistograms() const { |
| 796 if (largest_received_packet_sequence_number_ == 0) | 803 if (largest_received_packet_sequence_number_ == 0) |
| 797 return; // Connection was never used. | 804 return; // Connection was never used. |
| 798 RecordAggregatePacketLossRate(); | 805 RecordAggregatePacketLossRate(); |
| 799 | 806 |
| 800 base::HistogramBase* is_not_ack_histogram = | 807 base::HistogramBase* is_not_ack_histogram = |
| 801 GetPacketSequenceNumberHistogram("IsNotAck_"); | 808 GetPacketSequenceNumberHistogram("IsNotAck_"); |
| 802 base::HistogramBase* is_an_ack_histogram = | 809 base::HistogramBase* is_an_ack_histogram = |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 858 continue; | 865 continue; |
| 859 } | 866 } |
| 860 // Record some overlapping patterns, to get a better picture, since this is | 867 // Record some overlapping patterns, to get a better picture, since this is |
| 861 // not very expensive. | 868 // not very expensive. |
| 862 if (i % 3 == 0) | 869 if (i % 3 == 0) |
| 863 six_packet_histogram->Add(recent_6_mask); | 870 six_packet_histogram->Add(recent_6_mask); |
| 864 } | 871 } |
| 865 } | 872 } |
| 866 | 873 |
| 867 } // namespace net | 874 } // namespace net |
| OLD | NEW |