forked from premiere/premiere-libtorrent
disk stats fix
This commit is contained in:
parent
c81a4f3430
commit
62a7946968
|
@ -189,6 +189,10 @@ namespace libtorrent
|
||||||
{ return m_allocations; }
|
{ return m_allocations; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef TORRENT_DISK_STATS
|
||||||
|
std::ofstream m_disk_access_log;
|
||||||
|
#endif
|
||||||
|
|
||||||
void release_memory();
|
void release_memory();
|
||||||
|
|
||||||
int in_use() const { return m_in_use; }
|
int in_use() const { return m_in_use; }
|
||||||
|
@ -269,10 +273,6 @@ namespace libtorrent
|
||||||
void check_invariant() const;
|
void check_invariant() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TORRENT_DISK_STATS
|
|
||||||
std::ofstream m_disk_access_log;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct cached_block_entry
|
struct cached_block_entry
|
||||||
{
|
{
|
||||||
cached_block_entry(): buf(0) {}
|
cached_block_entry(): buf(0) {}
|
||||||
|
|
|
@ -62,6 +62,9 @@ namespace libtorrent
|
||||||
m_log.open("disk_buffers.log", std::ios::trunc);
|
m_log.open("disk_buffers.log", std::ios::trunc);
|
||||||
m_categories["read cache"] = 0;
|
m_categories["read cache"] = 0;
|
||||||
m_categories["write 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
|
#endif
|
||||||
#ifdef TORRENT_DEBUG
|
#ifdef TORRENT_DEBUG
|
||||||
m_magic = 0x1337;
|
m_magic = 0x1337;
|
||||||
|
@ -282,10 +285,6 @@ namespace libtorrent
|
||||||
, m_work(io_service::work(m_ios))
|
, m_work(io_service::work(m_ios))
|
||||||
, m_disk_io_thread(boost::ref(*this))
|
, 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()
|
disk_io_thread::~disk_io_thread()
|
||||||
|
|
|
@ -1206,16 +1206,22 @@ ret:
|
||||||
, int num_bufs)
|
, int num_bufs)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_DISK_STATS
|
#ifdef TORRENT_DISK_STATS
|
||||||
disk_io_thread* iothread = (disk_io_thread*)disk_pool();
|
disk_buffer_pool* pool = disk_pool();
|
||||||
iothread->m_disk_access_log << log_time() << " write "
|
if (pool)
|
||||||
|
{
|
||||||
|
pool->m_disk_access_log << log_time() << " write "
|
||||||
<< (size_type(slot) * m_files.piece_length() + offset) << std::endl;
|
<< (size_type(slot) * m_files.piece_length() + offset) << std::endl;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
fileop op = { &file::writev, &storage::write_unaligned
|
fileop op = { &file::writev, &storage::write_unaligned
|
||||||
, m_settings ? settings().disk_io_write_mode : 0, file::read_write };
|
, m_settings ? settings().disk_io_write_mode : 0, file::read_write };
|
||||||
#ifdef TORRENT_DISK_STATS
|
#ifdef TORRENT_DISK_STATS
|
||||||
int ret = readwritev(bufs, slot, offset, num_bufs, op);
|
int ret = readwritev(bufs, slot, offset, num_bufs, op);
|
||||||
iothread->m_disk_access_log << log_time() << " write_end "
|
if (pool)
|
||||||
|
{
|
||||||
|
pool->m_disk_access_log << log_time() << " write_end "
|
||||||
<< (size_type(slot) * m_files.piece_length() + offset + ret) << std::endl;
|
<< (size_type(slot) * m_files.piece_length() + offset + ret) << std::endl;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
return readwritev(bufs, slot, offset, num_bufs, op);
|
return readwritev(bufs, slot, offset, num_bufs, op);
|
||||||
|
@ -1226,16 +1232,22 @@ ret:
|
||||||
, int num_bufs)
|
, int num_bufs)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_DISK_STATS
|
#ifdef TORRENT_DISK_STATS
|
||||||
disk_io_thread* iothread = (disk_io_thread*)disk_pool();
|
disk_buffer_pool* pool = disk_pool();
|
||||||
iothread->m_disk_access_log << log_time() << " read "
|
if (pool)
|
||||||
|
{
|
||||||
|
pool->m_disk_access_log << log_time() << " read "
|
||||||
<< (size_type(slot) * m_files.piece_length() + offset) << std::endl;
|
<< (size_type(slot) * m_files.piece_length() + offset) << std::endl;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
fileop op = { &file::readv, &storage::read_unaligned
|
fileop op = { &file::readv, &storage::read_unaligned
|
||||||
, m_settings ? settings().disk_io_read_mode : 0, file::read_only };
|
, m_settings ? settings().disk_io_read_mode : 0, file::read_only };
|
||||||
#ifdef TORRENT_DISK_STATS
|
#ifdef TORRENT_DISK_STATS
|
||||||
int ret = readwritev(bufs, slot, offset, num_bufs, op);
|
int ret = readwritev(bufs, slot, offset, num_bufs, op);
|
||||||
iothread->m_disk_access_log << log_time() << " read_end "
|
if (pool)
|
||||||
|
{
|
||||||
|
pool->m_disk_access_log << log_time() << " read_end "
|
||||||
<< (size_type(slot) * m_files.piece_length() + offset + ret) << std::endl;
|
<< (size_type(slot) * m_files.piece_length() + offset + ret) << std::endl;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
return readwritev(bufs, slot, offset, num_bufs, op);
|
return readwritev(bufs, slot, offset, num_bufs, op);
|
||||||
|
|
Loading…
Reference in New Issue