optimize some invariant checks and make test_utp shorted, to complete much faster
This commit is contained in:
parent
a8ac369584
commit
416d064489
|
@ -49,7 +49,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#endif
|
||||
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS || TORRENT_DISK_STATS
|
||||
#include <map>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#endif
|
||||
|
||||
namespace libtorrent
|
||||
|
@ -129,8 +129,8 @@ namespace libtorrent
|
|||
public:
|
||||
void rename_buffer(char* buf, char const* category);
|
||||
protected:
|
||||
std::map<std::string, int> m_categories;
|
||||
std::map<char*, std::string> m_buf_to_category;
|
||||
boost::unordered_map<std::string, int> m_categories;
|
||||
boost::unordered_map<char*, std::string> m_buf_to_category;
|
||||
std::ofstream m_log;
|
||||
private:
|
||||
#endif
|
||||
|
|
|
@ -5883,6 +5883,7 @@ namespace libtorrent
|
|||
// num_requests[i->block].peers.push_back(&p);
|
||||
}
|
||||
}
|
||||
piece_picker::downloading_piece last_piece;
|
||||
for (std::map<piece_block, peer_count_t>::iterator i = num_requests.begin()
|
||||
, end(num_requests.end()); i != end; ++i)
|
||||
{
|
||||
|
@ -5893,12 +5894,18 @@ namespace libtorrent
|
|||
int count_with_nowant = pc.num_peers_with_nowant;
|
||||
(void)count_with_timeouts;
|
||||
(void)count_with_nowant;
|
||||
if (b.piece_index != last_piece.index)
|
||||
t->picker().piece_info(b.piece_index, last_piece);
|
||||
|
||||
// has b been downloaded?
|
||||
if ((last_piece.finished == 0 && last_piece.writing == 0)
|
||||
|| (last_piece.info && last_piece.info[b.block_index].state >= piece_picker::block_info::state_writing))
|
||||
{
|
||||
int picker_count = t->picker().num_peers(b);
|
||||
if (!t->picker().is_downloaded(b))
|
||||
TORRENT_ASSERT(picker_count == count);
|
||||
}
|
||||
}
|
||||
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
||||
}
|
||||
if (m_peer_info && type() == bittorrent_connection)
|
||||
{
|
||||
policy::const_iterator i = t->get_policy().begin_peer();
|
||||
|
@ -5909,7 +5916,6 @@ namespace libtorrent
|
|||
}
|
||||
TORRENT_ASSERT(i != end);
|
||||
}
|
||||
#endif
|
||||
if (t->has_picker() && !t->is_aborted())
|
||||
{
|
||||
// make sure that pieces that have completed the download
|
||||
|
@ -5930,17 +5936,6 @@ namespace libtorrent
|
|||
complete = false;
|
||||
break;
|
||||
}
|
||||
/*
|
||||
// this invariant is not valid anymore since the completion event
|
||||
// might be queued in the io service
|
||||
if (complete && !piece_failed)
|
||||
{
|
||||
disk_io_job ret = m_ses.m_disk_thread.find_job(
|
||||
&t->filesystem(), -1, i->index);
|
||||
TORRENT_ASSERT(ret.action == disk_io_job::hash || ret.action == disk_io_job::write);
|
||||
TORRENT_ASSERT(ret.piece == i->index);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ namespace libtorrent
|
|||
void piece_picker::piece_info(int index, piece_picker::downloading_piece& st) const
|
||||
{
|
||||
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
||||
TORRENT_PIECE_PICKER_INVARIANT_CHECK;
|
||||
// TORRENT_PIECE_PICKER_INVARIANT_CHECK;
|
||||
#endif
|
||||
|
||||
TORRENT_ASSERT(index >= 0);
|
||||
|
@ -153,7 +153,7 @@ namespace libtorrent
|
|||
std::vector<downloading_piece>::const_iterator piece = find_dl_piece(index);
|
||||
TORRENT_ASSERT(piece != m_downloads.end());
|
||||
st = *piece;
|
||||
st.info = 0;
|
||||
// st.info = 0;
|
||||
return;
|
||||
}
|
||||
st.info = 0;
|
||||
|
|
|
@ -100,7 +100,7 @@ void test_transfer()
|
|||
|
||||
create_directory("./tmp1_utp", ec);
|
||||
std::ofstream file("./tmp1_utp/temporary");
|
||||
boost::intrusive_ptr<torrent_info> t = ::create_torrent(&file, 512 * 1024, 20, false);
|
||||
boost::intrusive_ptr<torrent_info> t = ::create_torrent(&file, 128 * 1024, 6, false);
|
||||
file.close();
|
||||
|
||||
// for performance testing
|
||||
|
|
Loading…
Reference in New Issue