Changeset 1172
- Timestamp:
- 08/25/10 03:14:19 (18 months ago)
- Location:
- trunk
- Files:
-
- 3 added
- 6 modified
-
libtorrent/src/data/chunk.cc (modified) (2 diffs)
-
libtorrent/src/data/chunk.h (modified) (1 diff)
-
libtorrent/src/data/chunk_part.cc (modified) (1 diff)
-
libtorrent/src/data/chunk_part.h (modified) (1 diff)
-
libtorrent/src/protocol/peer_connection_base.cc (modified) (4 diffs)
-
rtorrent/doc/debugging (added)
-
rtorrent/doc/log_rtorrent.sh (added)
-
rtorrent/doc/log_stats.plot (added)
-
rtorrent/src/command_network.cc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtorrent/src/data/chunk.cc
r1105 r1172 114 114 115 115 uint32_t 116 Chunk::incore_length(uint32_t pos ) {117 uint32_t lengthIncore= 0;116 Chunk::incore_length(uint32_t pos, uint32_t length) { 117 uint32_t result = 0; 118 118 iterator itr = at_position(pos); 119 119 … … 121 121 throw internal_error("Chunk::incore_length(...) at end()"); 122 122 123 do { 124 uint32_t length = itr->incore_length(pos); 125 126 pos += length; 127 lengthIncore += length; 123 length = std::min(length, chunk_size() - pos); 124 125 do { 126 uint32_t incore_len = itr->incore_length(pos, length); 127 128 if (incore_len > length) 129 throw internal_error("Chunk::incore_length(...) incore_len > length."); 130 131 pos += incore_len; 132 length -= incore_len; 133 result += incore_len; 128 134 129 135 } while (pos == itr->position() + itr->size() && ++itr != end()); 130 136 131 return lengthIncore;137 return result; 132 138 } 133 139 -
trunk/libtorrent/src/data/chunk.h
r1171 r1172 85 85 86 86 // Check how much of the chunk is incore from pos. 87 uint32_t incore_length(uint32_t pos );87 uint32_t incore_length(uint32_t pos, uint32_t length = ~uint32_t()); 88 88 89 89 bool sync(int flags); -
trunk/libtorrent/src/data/chunk_part.cc
r939 r1172 62 62 63 63 uint32_t 64 ChunkPart::incore_length(uint32_t pos ) {64 ChunkPart::incore_length(uint32_t pos, uint32_t length) { 65 65 // Do we want to use this? 66 pos -= m_position; 66 length = std::min(length, remaining_from(pos)); 67 pos = pos - m_position; 67 68 68 69 if (pos >= size()) 69 70 throw internal_error("ChunkPart::incore_length(...) got invalid position"); 70 71 71 int length = size() - pos;72 72 int touched = m_chunk.pages_touched(pos, length); 73 73 char buf[touched]; -
trunk/libtorrent/src/data/chunk_part.h
r1171 r1172 65 65 uint32_t position() const { return m_position; } 66 66 67 uint32_t incore_length(uint32_t pos); 67 uint32_t remaining_from(uint32_t pos) const { return size() - (pos - m_position); } 68 69 uint32_t incore_length(uint32_t pos, uint32_t length = ~uint32_t()); 68 70 69 71 private: -
trunk/libtorrent/src/protocol/peer_connection_base.cc
r1145 r1172 38 38 39 39 #include <cstdio> 40 #include <fcntl.h> 40 41 #include <rak/error_number.h> 42 #include <rak/string_manip.h> 41 43 42 44 #include "torrent/exceptions.h" … … 277 279 } 278 280 281 inline static void 282 log_upload_chunk_mincore(Chunk* chunk, const Piece& piece, bool new_index) { 283 #ifdef LT_LOG_MINCORE_FILE 284 static int mincore_fd = -1; 285 static int32_t ticker = rak::timer::current().seconds() / 10 * 10; 286 287 static int counter_incore = 0; 288 static int counter_not_incore = 0; 289 static int counter_incore_new = 0; 290 static int counter_not_incore_new = 0; 291 292 if (rak::timer::current().seconds() >= ticker + 10) { 293 char buffer[256]; 294 295 if (mincore_fd == -1) { 296 snprintf(buffer, 256, "%s.%u", LT_LOG_MINCORE_FILE, getpid()); 297 298 if ((mincore_fd = open(buffer, O_WRONLY | O_CREAT | O_TRUNC)) == -1) 299 throw internal_error("Could not open mincore log file."); 300 } 301 302 // Log the result of mincore for every piece uploaded to a file. 303 unsigned int buf_lenght = snprintf(buffer, 256, "%i %u %u %u %u\n", 304 ticker, counter_incore, counter_incore_new, counter_not_incore, counter_not_incore_new); 305 306 write(mincore_fd, buffer, buf_lenght); 307 308 ticker = rak::timer::current().seconds() / 10 * 10; 309 310 counter_incore = 0; 311 counter_not_incore = 0; 312 counter_incore_new = 0; 313 counter_not_incore_new = 0; 314 } 315 316 bool is_incore = (chunk->incore_length(piece.offset(), piece.length()) == piece.length()); 317 318 counter_incore += !new_index && is_incore; 319 counter_incore_new += new_index && is_incore; 320 counter_not_incore += !new_index && !is_incore; 321 counter_not_incore_new += new_index && !is_incore; 322 #endif 323 } 324 279 325 void 280 326 PeerConnectionBase::load_up_chunk() { … … 282 328 // Better checking needed. 283 329 // m_upChunk.chunk()->preload(m_upPiece.offset(), m_upChunk.chunk()->size()); 330 log_upload_chunk_mincore(m_upChunk.chunk(), m_upPiece, false); 284 331 return; 285 332 } … … 296 343 m_encryptBuffer->reset(); 297 344 } 345 346 log_upload_chunk_mincore(m_upChunk.chunk(), m_upPiece, true); 298 347 299 348 // Also check if we've already preloaded in the recent past, even -
trunk/rtorrent/src/command_network.cc
r1168 r1172 421 421 CMD2_VAR_STRING("connection_seed", "seed"); 422 422 423 CMD2_ANY ("throttle.unchoked_uploads", std::tr1::bind(&torrent::currently_unchoked)); 424 CMD2_ANY ("throttle.unchoked_downloads", std::tr1::bind(&torrent::download_unchoked)); 425 423 426 CMD2_VAR_VALUE ("throttle.min_peers.normal", 40); 424 427 CMD2_VAR_VALUE ("throttle.max_peers.normal", 100);
