9 Dec 2006 10:41
Perfomance under VC8
Stas Khirman <staskh <at> comcast.net>
2006-12-09 09:41:55 GMT
2006-12-09 09:41:55 GMT
(I think that it already had been noticed in this list, but apparently no specific solution had been suggested.) Problem: When compiled under VC8 ( VS 2005) with debug support, LibTorrent consume all available CPU. No similar behavior had been observed for VC7 or GCC builds. Discussion: VC8 introduced very extensive ( and expensive) build-in iterator tests. (Interesting to note - some of these test will be active event in the release mode - http://msdn2.microsoft.com/en-US/library/aa985965(VS.80).aspx). As result, LibTorrent invariant checks became extremely expensive operation ( as called in every method entry point). However, switching-off boundary tests or another build-in iterations debug support is not an option, as they are very helpful to debug. Solution: Apparently, the major "CPU hog" is a piece re-count algorithm inside peer_connection::check_invariant (peer_connection.cpp). I suspect ( didn't check it in depth yet) MS made some memory-optimization in vector<bool> implementation that results in expensive checked iterator. The simples fix is to put #ifndef _WIN32 brackets around this portion of code: peer_connection::check_invariant() ...... #ifndef _WIN32 if (t->valid_metadata()) { int piece_count = std::count(m_have_piece.begin() , m_have_piece.end(), true); if (m_num_pieces != piece_count)(Continue reading)
RSS Feed