disk stats fix

This commit is contained in:
Arvid Norberg 2009-06-14 22:20:23 +00:00
parent c81a4f3430
commit 62a7946968
3 changed files with 29 additions and 18 deletions

View File

@ -189,6 +189,10 @@ namespace libtorrent
{ return m_allocations; }
#endif
#ifdef TORRENT_DISK_STATS
std::ofstream m_disk_access_log;
#endif
void release_memory();
int in_use() const { return m_in_use; }
@ -269,10 +273,6 @@ namespace libtorrent
void check_invariant() const;
#endif
#ifdef TORRENT_DISK_STATS
std::ofstream m_disk_access_log;
#endif
struct cached_block_entry
{
cached_block_entry(): buf(0) {}

View File

@ -62,6 +62,9 @@ namespace libtorrent
m_log.open("disk_buffers.log", std::ios::trunc);
m_categories["read cache"] = 0;
m_categories["write cache"] = 0;
m_log.open("disk_io_thread.log", std::ios::trunc);
m_disk_access_log.open("disk_access.log", std::ios::trunc);
#endif
#ifdef TORRENT_DEBUG
m_magic = 0x1337;
@ -282,10 +285,6 @@ namespace libtorrent
, m_work(io_service::work(m_ios))
, m_disk_io_thread(boost::ref(*this))
{
#ifdef TORRENT_DISK_STATS
m_log.open("disk_io_thread.log", std::ios::trunc);
m_disk_access_log.open("disk_access.log", std::ios::trunc);
#endif
}
disk_io_thread::~disk_io_thread()

View File

@ -1206,16 +1206,22 @@ ret:
, int num_bufs)
{
#ifdef TORRENT_DISK_STATS
disk_io_thread* iothread = (disk_io_thread*)disk_pool();
iothread->m_disk_access_log << log_time() << " write "
<< (size_type(slot) * m_files.piece_length() + offset) << std::endl;
disk_buffer_pool* pool = disk_pool();
if (pool)
{
pool->m_disk_access_log << log_time() << " write "
<< (size_type(slot) * m_files.piece_length() + offset) << std::endl;
}
#endif
fileop op = { &file::writev, &storage::write_unaligned
, m_settings ? settings().disk_io_write_mode : 0, file::read_write };
#ifdef TORRENT_DISK_STATS
int ret = readwritev(bufs, slot, offset, num_bufs, op);
iothread->m_disk_access_log << log_time() << " write_end "
<< (size_type(slot) * m_files.piece_length() + offset + ret) << std::endl;
if (pool)
{
pool->m_disk_access_log << log_time() << " write_end "
<< (size_type(slot) * m_files.piece_length() + offset + ret) << std::endl;
}
return ret;
#else
return readwritev(bufs, slot, offset, num_bufs, op);
@ -1226,16 +1232,22 @@ ret:
, int num_bufs)
{
#ifdef TORRENT_DISK_STATS
disk_io_thread* iothread = (disk_io_thread*)disk_pool();
iothread->m_disk_access_log << log_time() << " read "
<< (size_type(slot) * m_files.piece_length() + offset) << std::endl;
disk_buffer_pool* pool = disk_pool();
if (pool)
{
pool->m_disk_access_log << log_time() << " read "
<< (size_type(slot) * m_files.piece_length() + offset) << std::endl;
}
#endif
fileop op = { &file::readv, &storage::read_unaligned
, m_settings ? settings().disk_io_read_mode : 0, file::read_only };
#ifdef TORRENT_DISK_STATS
int ret = readwritev(bufs, slot, offset, num_bufs, op);
iothread->m_disk_access_log << log_time() << " read_end "
<< (size_type(slot) * m_files.piece_length() + offset + ret) << std::endl;
if (pool)
{
pool->m_disk_access_log << log_time() << " read_end "
<< (size_type(slot) * m_files.piece_length() + offset + ret) << std::endl;
}
return ret;
#else
return readwritev(bufs, slot, offset, num_bufs, op);