From 275c3402314b21caf660dcd0af0bf5fc5e2b6207 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 2 Sep 2013 09:24:34 +0000 Subject: [PATCH] make socket buffer sizes affect the udp socket as well. for high_performance_seed preset, set 1 MB socket buffers. only run test_rate() in proper release mode (without invariant checks and debug-iterators). lower the time limit of test_rate. update regression tests to disable invariant checks and debug iterators when building release mode --- .regression.yml | 2 +- src/session.cpp | 3 +++ src/session_impl.cpp | 27 +++++++++++++++++++++++++++ src/utp_stream.cpp | 4 ++-- test/test_transfer.cpp | 12 ++++++++++-- 5 files changed, 43 insertions(+), 5 deletions(-) diff --git a/.regression.yml b/.regression.yml index f05c85c1f..9a4d4bd01 100644 --- a/.regression.yml +++ b/.regression.yml @@ -11,7 +11,7 @@ clean: time_limit: 180 features: - - variant=release asserts=production + - variant=release asserts=production invariant-checks=off debug-iterators=off - encryption=openssl statistics=on logging=verbose disk-stats=on dht=logging request-log=on - ipv6=off dht=off extensions=off logging=none deprecated-functions=off diff --git a/src/session.cpp b/src/session.cpp index 944bb420d..456726ef3 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -255,6 +255,9 @@ namespace libtorrent set.max_rejects = 10; + set.recv_socket_buffer_size = 1024 * 1024; + set.send_socket_buffer_size = 1024 * 1024; + set.optimize_hashing_for_speed = true; // don't let connections linger for too long diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 739147b10..d6733c4cd 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -2082,6 +2082,21 @@ namespace aux { #endif } + if (m_settings.send_socket_buffer_size != s.send_socket_buffer_size) + { + error_code ec; + stream_socket::send_buffer_size option( + m_settings.send_socket_buffer_size); + m_udp_socket.set_option(option, ec); + } + if (m_settings.recv_socket_buffer_size != s.recv_socket_buffer_size) + { + error_code ec; + stream_socket::receive_buffer_size option( + m_settings.recv_socket_buffer_size); + m_udp_socket.set_option(option, ec); + } + bool reopen_listen_port = false; if (m_settings.ssl_listen != s.ssl_listen) reopen_listen_port = true; @@ -2464,6 +2479,18 @@ retry: (*m_logger) << ">>> SET_TOS[ udp_socket tos: " << m_settings.peer_tos << " e: " << ec.message() << " ]\n"; #endif ec.clear(); + if (m_settings.send_socket_buffer_size) + { + stream_socket::send_buffer_size option( + m_settings.send_socket_buffer_size); + m_udp_socket.set_option(option, ec); + } + if (m_settings.recv_socket_buffer_size) + { + stream_socket::receive_buffer_size option( + m_settings.recv_socket_buffer_size); + m_udp_socket.set_option(option, ec); + } // initiate accepting on the listen sockets for (std::list::iterator i = m_listen_sockets.begin() diff --git a/src/utp_stream.cpp b/src/utp_stream.cpp index 47f94cd97..6c72b6f19 100644 --- a/src/utp_stream.cpp +++ b/src/utp_stream.cpp @@ -2667,7 +2667,7 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size { // LOSS - UTP_LOGV("%8p: Packet %d lost.\n", this, m_fast_resend_seq_nr); + UTP_LOGV("%8p: Packet %d lost. (%d duplicate acks, trigger fast-resend)\n", this, m_fast_resend_seq_nr, m_duplicate_acks); // resend the lost packet packet* p = (packet*)m_outbuf.at(m_fast_resend_seq_nr); @@ -3253,7 +3253,7 @@ void utp_socket_impl::tick(ptime const& now) p->need_resend = true; TORRENT_ASSERT(m_bytes_in_flight >= p->size - p->header_size); m_bytes_in_flight -= p->size - p->header_size; - UTP_LOGV("%8p: Packet %d lost.\n", this, i); + UTP_LOGV("%8p: Packet %d lost (timeout).\n", this, i); } TORRENT_ASSERT(m_bytes_in_flight == 0); diff --git a/test/test_transfer.cpp b/test/test_transfer.cpp index bd74cc3d4..8479efd3a 100644 --- a/test/test_transfer.cpp +++ b/test/test_transfer.cpp @@ -101,12 +101,17 @@ void test_rate() peer_disconnects = 0; + session_settings sett = high_performance_seed(); + ses1.set_settings(sett); + ses2.set_settings(sett); + boost::tie(tor1, tor2, ignore) = setup_transfer(&ses1, &ses2, 0 , true, false, true, "_transfer", 0, &t); ptime start = time_now(); - for (int i = 0; i < 70; ++i) + // it shouldn't take more than 2 seconds + for (int i = 0; i < 20; ++i) { print_alerts(ses1, "ses1", true, true, true, &on_alert); print_alerts(ses2, "ses2", true, true, true, &on_alert); @@ -622,9 +627,12 @@ int test_main() { using namespace libtorrent; -#ifdef NDEBUG +#if !defined TORRENT_DEBUG \ + && defined TORRENT_DISABLE_INVARIANT_CHECKS \ + && !defined _GLIBCXX_DEBUG // test rate only makes sense in release mode test_rate(); + return 0; #endif // test with all kinds of proxies