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

Unified Diff: content/browser/renderer_host/p2p/socket_host_udp.cc

Issue 693433003: Add a new finch experiment to control the system buffer size. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « content/browser/renderer_host/p2p/socket_host_udp.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/p2p/socket_host_udp.cc
diff --git a/content/browser/renderer_host/p2p/socket_host_udp.cc b/content/browser/renderer_host/p2p/socket_host_udp.cc
index 3bea4dfb2d71d23bb8fd66a3e707aff3b8ea6953..ea188c8ca2bd33490b4f48eee842c7f08045ae11 100644
--- a/content/browser/renderer_host/p2p/socket_host_udp.cc
+++ b/content/browser/renderer_host/p2p/socket_host_udp.cc
@@ -6,7 +6,10 @@
#include "base/bind.h"
#include "base/debug/trace_event.h"
+#include "base/metrics/field_trial.h"
+#include "base/metrics/histogram.h"
#include "base/stl_util.h"
+#include "base/strings/string_number_conversions.h"
#include "content/browser/renderer_host/p2p/socket_host_throttler.h"
#include "content/common/p2p_messages.h"
#include "content/public/browser/content_browser_client.h"
@@ -45,6 +48,14 @@ bool IsTransientError(int error) {
error == net::ERR_INTERNET_DISCONNECTED;
}
+struct AsyncCallRecord {
+ AsyncCallRecord(uint64 packet_id, uint64 ticks_received) {
+ this->packet_id = packet_id;
+ this->ticks_received = ticks_received;
+ }
+ uint64 packet_id;
+ uint64 ticks_received;
+};
} // namespace
namespace content {
@@ -84,6 +95,22 @@ P2PSocketHostUdp::~P2PSocketHostUdp() {
}
}
+void P2PSocketHostUdp::SetSendBufferSize() {
+ unsigned send_buffer_size = 0;
juberti2 2014/11/07 22:24:59 unsigned int
+
+ // In the finch experiment, groups will be named like "2K", "64K",
juberti2 2014/11/07 22:24:59 OOC, would it make more sense to just name the gro
+ // etc. The StringToUint will convert the leading number part.
+ if (base::StringToUint(
+ base::FieldTrialList::FindFullName("WebRTC-SystemUDPSendSocketSize"),
+ &send_buffer_size) &&
Alexei Svitkine (slow) 2014/11/07 22:24:35 I don't think checking the return value of this fu
+ send_buffer_size > 0) {
+ if (!SetOption(P2P_SOCKET_OPT_SNDBUF, send_buffer_size * 1024)) {
+ LOG(WARNING) << "Failed to set socket send buffer size to "
+ << send_buffer_size * 1024;
+ }
+ }
+}
+
bool P2PSocketHostUdp::Init(const net::IPEndPoint& local_address,
const P2PHostAndIPEndPoint& remote_address) {
DCHECK_EQ(state_, STATE_UNINITIALIZED);
@@ -113,6 +140,8 @@ bool P2PSocketHostUdp::Init(const net::IPEndPoint& local_address,
state_ = STATE_OPEN;
+ SetSendBufferSize();
+
// NOTE: Remote address will be same as what renderer provided.
message_sender_->Send(new P2PMsg_OnSocketCreated(
id_, address, remote_address.ip_address));
@@ -245,13 +274,18 @@ void P2PSocketHostUdp::DoSend(const PendingPacket& packet) {
last_dscp_ = net::DSCP_NO_CHANGE;
}
}
+
+ uint64 call_record = reinterpret_cast<uint64>(
+ new AsyncCallRecord(packet.id, base::TimeTicks::Now().ToInternalValue()));
+
packet_processing_helpers::ApplyPacketOptions(
packet.data->data(), packet.size, packet.packet_options, 0);
int result = socket_->SendTo(
packet.data.get(),
packet.size,
packet.to,
- base::Bind(&P2PSocketHostUdp::OnSend, base::Unretained(this), packet.id));
+ base::Bind(
+ &P2PSocketHostUdp::OnSend, base::Unretained(this), call_record));
Alexei Svitkine (slow) 2014/11/07 22:24:35 I think you should be able to bind to the params d
// sendto() may return an error, e.g. if we've received an ICMP Destination
// Unreachable message. When this happens try sending the same packet again,
@@ -261,27 +295,28 @@ void P2PSocketHostUdp::DoSend(const PendingPacket& packet) {
packet.data.get(),
packet.size,
packet.to,
- base::Bind(&P2PSocketHostUdp::OnSend, base::Unretained(this),
- packet.id));
+ base::Bind(
+ &P2PSocketHostUdp::OnSend, base::Unretained(this), call_record));
}
if (result == net::ERR_IO_PENDING) {
send_pending_ = true;
} else {
- HandleSendResult(packet.id, result);
+ HandleSendResult(call_record, result);
}
if (dump_outgoing_rtp_packet_)
DumpRtpPacket(packet.data->data(), packet.size, false);
}
-void P2PSocketHostUdp::OnSend(uint64 packet_id, int result) {
+void P2PSocketHostUdp::OnSend(uint64 call_record, int result) {
DCHECK(send_pending_);
+
DCHECK_NE(result, net::ERR_IO_PENDING);
send_pending_ = false;
- HandleSendResult(packet_id, result);
+ HandleSendResult(call_record, result);
// Send next packets if we have them waiting in the buffer.
while (state_ == STATE_OPEN && !send_queue_.empty() && !send_pending_) {
@@ -292,7 +327,12 @@ void P2PSocketHostUdp::OnSend(uint64 packet_id, int result) {
}
}
-void P2PSocketHostUdp::HandleSendResult(uint64 packet_id, int result) {
+void P2PSocketHostUdp::HandleSendResult(uint64 call_record, int result) {
+ scoped_ptr<AsyncCallRecord> call_record_ptr(
+ reinterpret_cast<AsyncCallRecord*>(call_record));
+ uint64 packet_id = call_record_ptr->packet_id;
+ uint64 ticks_received = call_record_ptr->ticks_received;
+
TRACE_EVENT_ASYNC_END1("p2p", "Send", packet_id,
"result", result);
if (result < 0) {
@@ -304,6 +344,14 @@ void P2PSocketHostUdp::HandleSendResult(uint64 packet_id, int result) {
VLOG(0) << "sendto() has failed twice returning a "
" transient error. Dropping the packet.";
}
+
+ // UMA to track the histograms from 1ms to 1 sec for how long a packet spends
+ // in the browser process.
+ UMA_HISTOGRAM_TIMES(
+ "WebRTC.SystemSendPacketDuration_UDP" /* name */,
+ base::TimeTicks::Now() -
+ base::TimeTicks::FromInternalValue(ticks_received) /* sample */);
+
message_sender_->Send(new P2PMsg_OnSendComplete(id_));
}
« no previous file with comments | « content/browser/renderer_host/p2p/socket_host_udp.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698