remove buffer stats debugging feature
This commit is contained in:
parent
f15182a737
commit
30713a4a79
3
Jamfile
3
Jamfile
|
@ -402,9 +402,6 @@ feature.compose <request-log>on : <define>TORRENT_REQUEST_LOGGING ;
|
|||
feature disk-stats : off on : composite propagated link-incompatible ;
|
||||
feature.compose <disk-stats>on : <define>TORRENT_DISK_STATS ;
|
||||
|
||||
feature buffer-stats : off on : composite propagated link-incompatible ;
|
||||
feature.compose <buffer-stats>on : <define>TORRENT_BUFFER_STATS ;
|
||||
|
||||
feature simulate-slow-read : off on : composite propagated ;
|
||||
feature.compose <simulate-slow-read>on : <define>TORRENT_SIMULATE_SLOW_READ ;
|
||||
|
||||
|
|
|
@ -1160,15 +1160,6 @@ namespace libtorrent
|
|||
void check_invariant() const;
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
void log_buffer_usage();
|
||||
// used to log send buffer usage statistics
|
||||
std::ofstream m_buffer_usage_logger;
|
||||
std::ofstream& buffer_usage_logger() { return m_buffer_usage_logger; }
|
||||
// the number of send buffers that are allocated
|
||||
int m_buffer_allocations;
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_REQUEST_LOGGING
|
||||
// used to log all requests from peers
|
||||
FILE* m_request_log;
|
||||
|
|
|
@ -51,10 +51,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <boost/pool/pool.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
#include <boost/unordered_map.hpp>
|
||||
#endif
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
namespace aux { struct session_settings; }
|
||||
|
@ -69,7 +65,7 @@ namespace libtorrent
|
|||
, alert_dispatcher* alert_disp);
|
||||
~disk_buffer_pool();
|
||||
|
||||
#if TORRENT_USE_ASSERTS || TORRENT_BUFFER_STATS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
bool is_disk_buffer(char* buffer
|
||||
, mutex::scoped_lock& l) const;
|
||||
bool is_disk_buffer(char* buffer) const;
|
||||
|
@ -196,20 +192,10 @@ namespace libtorrent
|
|||
boost::pool<page_aligned_allocator> m_pool;
|
||||
#endif
|
||||
|
||||
#if defined TORRENT_BUFFER_STATS || defined TORRENT_STATS
|
||||
#if defined TORRENT_STATS
|
||||
int m_allocations;
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
public:
|
||||
void rename_buffer(char* buf, char const* category);
|
||||
boost::unordered_map<std::string, int> m_categories;
|
||||
protected:
|
||||
boost::unordered_map<char*, std::string> m_buf_to_category;
|
||||
FILE* m_log;
|
||||
private:
|
||||
#endif
|
||||
|
||||
// this is specifically exempt from release_asserts
|
||||
// since it's a quite costly check. Only for debug
|
||||
// builds.
|
||||
|
|
|
@ -105,13 +105,9 @@ namespace libtorrent
|
|||
|
||||
virtual file_pool& files() = 0;
|
||||
|
||||
#if TORRENT_USE_ASSERTS || defined TORRENT_BUFFER_STATS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
virtual bool is_disk_buffer(char* buffer) const = 0;
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
virtual void rename_buffer(char* buf, char const* category) = 0;
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -361,15 +361,10 @@ namespace libtorrent
|
|||
|
||||
block_cache* cache() { return &m_disk_cache; }
|
||||
|
||||
#if TORRENT_USE_ASSERTS || defined TORRENT_BUFFER_STATS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
bool is_disk_buffer(char* buffer) const { return m_disk_cache.is_disk_buffer(buffer); }
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
void rename_buffer(char* buf, char const* category)
|
||||
{ m_disk_cache.rename_buffer(buf, category); }
|
||||
#endif
|
||||
|
||||
enum thread_type_t {
|
||||
generic_thread,
|
||||
hasher_thread
|
||||
|
|
|
@ -689,10 +689,6 @@ namespace libtorrent
|
|||
bool is_corked() const { return m_corked; }
|
||||
void uncork_socket();
|
||||
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
void log_buffer_usage(char* buffer, int size, char const* label);
|
||||
#endif
|
||||
|
||||
virtual void append_send_buffer(char* buffer, int size
|
||||
, chained_buffer::free_buffer_fun destructor = &nop
|
||||
, void* userdata = NULL, block_cache_reference ref
|
||||
|
|
|
@ -632,9 +632,6 @@ cached_piece_entry* block_cache::add_dirty_block(disk_io_job* j)
|
|||
}
|
||||
|
||||
b.buf = j->buffer;
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
rename_buffer(j->buffer, "write cache");
|
||||
#endif
|
||||
|
||||
b.dirty = true;
|
||||
++pe->num_blocks;
|
||||
|
@ -679,9 +676,6 @@ void block_cache::blocks_flushed(cached_piece_entry* pe, int const* flushed, int
|
|||
// this is the last reference to it
|
||||
pe->blocks[block].dirty = false;
|
||||
dec_block_refcount(pe, block, block_cache::ref_flushing);
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
rename_buffer(pe->blocks[block].buf, "read cache");
|
||||
#endif
|
||||
}
|
||||
|
||||
m_write_cache_size -= num_flushed;
|
||||
|
@ -1189,9 +1183,6 @@ void block_cache::insert_blocks(cached_piece_entry* pe, int block, file::iovec_t
|
|||
{
|
||||
pe->blocks[block].buf = (char*)iov[i].iov_base;
|
||||
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
rename_buffer(pe->blocks[block].buf, "read cache");
|
||||
#endif
|
||||
TORRENT_PIECE_ASSERT(iov[i].iov_base != NULL, pe);
|
||||
TORRENT_PIECE_ASSERT(pe->blocks[block].dirty == false, pe);
|
||||
++pe->num_blocks;
|
||||
|
@ -1632,13 +1623,6 @@ void block_cache::check_invariant() const
|
|||
TORRENT_ASSERT(m_write_cache_size == cached_write_blocks);
|
||||
TORRENT_ASSERT(m_pinned_blocks == num_pinned);
|
||||
TORRENT_ASSERT(m_write_cache_size + m_read_cache_size <= in_use());
|
||||
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
int read_allocs = m_categories.find(std::string("read cache"))->second;
|
||||
int write_allocs = m_categories.find(std::string("write cache"))->second;
|
||||
TORRENT_ASSERT(cached_read_blocks == read_allocs);
|
||||
TORRENT_ASSERT(cached_write_blocks == write_allocs);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -68,10 +68,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
// http://www.opensource.apple.com/source/xnu/xnu-792.13.8/osfmk/vm/vm_object.c
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
#include "libtorrent/time.hpp"
|
||||
#endif
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
// this is posted to the network thread
|
||||
|
@ -125,14 +121,9 @@ namespace libtorrent
|
|||
, m_pool(block_size, 32)
|
||||
#endif
|
||||
{
|
||||
#if defined TORRENT_BUFFER_STATS || defined TORRENT_STATS
|
||||
#if defined TORRENT_STATS
|
||||
m_allocations = 0;
|
||||
#endif
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
m_log = fopen("disk_buffers.log", "w+");
|
||||
m_categories["read cache"] = 0;
|
||||
m_categories["write cache"] = 0;
|
||||
#endif
|
||||
#if TORRENT_USE_ASSERTS
|
||||
m_magic = 0x1337;
|
||||
m_settings_set = false;
|
||||
|
@ -231,7 +222,7 @@ namespace libtorrent
|
|||
m_ios.post(boost::bind(&watermark_callback, cbs, handlers));
|
||||
}
|
||||
|
||||
#if TORRENT_USE_ASSERTS || defined TORRENT_BUFFER_STATS
|
||||
#if TORRENT_USE_ASSERTS
|
||||
bool disk_buffer_pool::is_disk_buffer(char* buffer
|
||||
, mutex::scoped_lock& l) const
|
||||
{
|
||||
|
@ -248,11 +239,6 @@ namespace libtorrent
|
|||
return m_buffers_in_use.count(buffer) == 1;
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
if (m_buf_to_category.find(buffer)
|
||||
== m_buf_to_category.end()) return false;
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_DEBUG_BUFFERS
|
||||
return page_aligned_allocator::in_use(buffer);
|
||||
#endif
|
||||
|
@ -395,38 +381,14 @@ namespace libtorrent
|
|||
}
|
||||
#endif // TORRENT_USE_MLOCK
|
||||
|
||||
#if defined TORRENT_BUFFER_STATS || defined TORRENT_STATS
|
||||
#if defined TORRENT_STATS
|
||||
++m_allocations;
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
++m_categories[category];
|
||||
m_buf_to_category[ret] = category;
|
||||
fprintf(m_log, "%s %s: %d\n", log_time().c_str(), category, m_categories[category]);
|
||||
#endif
|
||||
TORRENT_ASSERT(is_disk_buffer(ret, l));
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
void disk_buffer_pool::rename_buffer(char* buf, char const* category)
|
||||
{
|
||||
mutex::scoped_lock l(m_pool_mutex);
|
||||
TORRENT_ASSERT(is_disk_buffer(buf, l));
|
||||
TORRENT_ASSERT(m_categories.find(m_buf_to_category[buf])
|
||||
!= m_categories.end());
|
||||
std::string const& prev_category = m_buf_to_category[buf];
|
||||
--m_categories[prev_category];
|
||||
fprintf(m_log, "%s %s: %d\n", log_time().c_str(), prev_category.c_str(), m_categories[category]);
|
||||
|
||||
++m_categories[category];
|
||||
m_buf_to_category[buf] = category;
|
||||
fprintf(m_log, "%s %s: %d\n", log_time().c_str(), category, m_categories[category]);
|
||||
TORRENT_ASSERT(m_categories.find(m_buf_to_category[buf])
|
||||
!= m_categories.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
void disk_buffer_pool::free_multiple_buffers(char** bufvec, int numbufs)
|
||||
{
|
||||
char** end = bufvec + numbufs;
|
||||
|
@ -634,17 +596,9 @@ namespace libtorrent
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined TORRENT_BUFFER_STATS || defined TORRENT_STATS
|
||||
#if defined TORRENT_STATS
|
||||
--m_allocations;
|
||||
#endif
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
TORRENT_ASSERT(m_categories.find(m_buf_to_category[buf])
|
||||
!= m_categories.end());
|
||||
std::string const& category = m_buf_to_category[buf];
|
||||
--m_categories[category];
|
||||
fprintf(m_log, "%s %s: %d\n", log_time().c_str(), category.c_str(), m_categories[category]);
|
||||
m_buf_to_category.erase(buf);
|
||||
#endif
|
||||
|
||||
#if TORRENT_HAVE_MMAP
|
||||
if (m_cache_pool)
|
||||
|
|
|
@ -288,17 +288,6 @@ namespace libtorrent
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
void peer_connection::log_buffer_usage(char* buffer, int size, char const* label)
|
||||
{
|
||||
if (m_disk_thread.is_disk_buffer(buffer))
|
||||
m_disk_thread.rename_buffer(buffer, label);
|
||||
|
||||
m_ses.buffer_usage_logger() << log_time() << " append_send_buffer: " << size << std::endl;
|
||||
m_ses.log_buffer_usage();
|
||||
}
|
||||
#endif
|
||||
|
||||
void peer_connection::increase_est_reciprocation_rate()
|
||||
{
|
||||
m_est_reciprocation_rate += m_est_reciprocation_rate
|
||||
|
@ -5162,11 +5151,6 @@ namespace libtorrent
|
|||
// this burst of disk events
|
||||
// m_ses.cork_burst(this);
|
||||
|
||||
#if TORRENT_BUFFER_STATS
|
||||
if (j->buffer && j->d.io.ref.storage == 0)
|
||||
m_disk_thread.rename_buffer(j->buffer, "received send buffer");
|
||||
#endif
|
||||
|
||||
if (!t)
|
||||
{
|
||||
disconnect(j->error.ec, op_file_read);
|
||||
|
@ -5185,11 +5169,6 @@ namespace libtorrent
|
|||
, r.piece, r.start, r.length);
|
||||
#endif
|
||||
|
||||
#if TORRENT_BUFFER_STATS
|
||||
if (j->buffer && j->d.io.ref.storage == 0)
|
||||
m_disk_thread.rename_buffer(j->buffer, "dispatched send buffer");
|
||||
#endif
|
||||
|
||||
// we probably just pulled this piece into the cache.
|
||||
// if it's rare enough to make it into the suggested piece
|
||||
// push another piece out
|
||||
|
@ -5742,9 +5721,6 @@ namespace libtorrent
|
|||
, chained_buffer::free_buffer_fun destructor, void* userdata
|
||||
, block_cache_reference ref, bool encrypted)
|
||||
{
|
||||
#if defined TORRENT_BUFFER_STATS
|
||||
log_buffer_usage(buffer, size, "queued send buffer");
|
||||
#endif
|
||||
// bittorrent connections should never use this function, since
|
||||
// they might be encrypted and this would circumvent the actual
|
||||
// encryption. bt_peer_connection overrides this function with
|
||||
|
@ -5760,11 +5736,6 @@ namespace libtorrent
|
|||
{
|
||||
m_send_buffer.append_buffer((char*)buffer, size, size, destructor
|
||||
, userdata, ref);
|
||||
|
||||
#if defined TORRENT_STATS && defined TORRENT_BUFFER_STATS
|
||||
m_ses.buffer_usage_logger() << log_time() << " append_const_send_buffer: " << size << std::endl;
|
||||
m_ses.log_buffer_usage();
|
||||
#endif
|
||||
}
|
||||
|
||||
void session_free_buffer(char* buffer, void* userdata, block_cache_reference)
|
||||
|
@ -5788,18 +5759,9 @@ namespace libtorrent
|
|||
if (fun) fun(dst, free_space, userdata);
|
||||
size -= free_space;
|
||||
buf += free_space;
|
||||
#if defined TORRENT_STATS && defined TORRENT_BUFFER_STATS
|
||||
m_ses.buffer_usage_logger() << log_time() << " send_buffer: "
|
||||
<< free_space << std::endl;
|
||||
m_ses.log_buffer_usage();
|
||||
#endif
|
||||
}
|
||||
if (size <= 0) return;
|
||||
|
||||
#if defined TORRENT_STATS && defined TORRENT_BUFFER_STATS
|
||||
m_ses.buffer_usage_logger() << log_time() << " send_buffer_alloc: " << size << std::endl;
|
||||
m_ses.log_buffer_usage();
|
||||
#endif
|
||||
int i = 0;
|
||||
while (size > 0)
|
||||
{
|
||||
|
|
|
@ -725,10 +725,6 @@ namespace aux {
|
|||
|
||||
rotate_stats_log();
|
||||
#endif
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
m_buffer_usage_logger.open("buffer_stats.log", std::ios::trunc);
|
||||
m_buffer_allocations = 0;
|
||||
#endif
|
||||
|
||||
#if TORRENT_USE_RLIMIT
|
||||
// ---- auto-cap max connections ----
|
||||
|
@ -7693,12 +7689,6 @@ retry:
|
|||
{
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
TORRENT_ASSERT(m_buffer_allocations >= 0);
|
||||
m_buffer_allocations++;
|
||||
m_buffer_usage_logger << log_time() << " protocol_buffer: "
|
||||
<< (m_buffer_allocations * send_buffer_size()) << std::endl;
|
||||
#endif
|
||||
#ifdef TORRENT_DISABLE_POOL_ALLOCATOR
|
||||
int num_bytes = send_buffer_size();
|
||||
return (char*)malloc(num_bytes);
|
||||
|
@ -7707,37 +7697,10 @@ retry:
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
void session_impl::log_buffer_usage()
|
||||
{
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
|
||||
int send_buffer_capacity = 0;
|
||||
int used_send_buffer = 0;
|
||||
for (connection_map::const_iterator i = m_connections.begin()
|
||||
, end(m_connections.end()); i != end; ++i)
|
||||
{
|
||||
send_buffer_capacity += (*i)->send_buffer_capacity();
|
||||
used_send_buffer += (*i)->send_buffer_size();
|
||||
}
|
||||
TORRENT_ASSERT(send_buffer_capacity >= used_send_buffer);
|
||||
m_buffer_usage_logger << log_time() << " send_buffer_size: " << send_buffer_capacity << std::endl;
|
||||
m_buffer_usage_logger << log_time() << " used_send_buffer: " << used_send_buffer << std::endl;
|
||||
m_buffer_usage_logger << log_time() << " send_buffer_utilization: "
|
||||
<< (used_send_buffer * 100.f / (std::max)(send_buffer_capacity, 1)) << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
void session_impl::free_buffer(char* buf)
|
||||
{
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
|
||||
#ifdef TORRENT_BUFFER_STATS
|
||||
m_buffer_allocations--;
|
||||
TORRENT_ASSERT(m_buffer_allocations >= 0);
|
||||
m_buffer_usage_logger << log_time() << " protocol_buffer: "
|
||||
<< (m_buffer_allocations * send_buffer_size()) << std::endl;
|
||||
#endif
|
||||
#ifdef TORRENT_DISABLE_POOL_ALLOCATOR
|
||||
free(buf);
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue