Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pread-disk-io #7013

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ set(libtorrent_aux_include_files
disable_warnings_pop.hpp
disable_warnings_push.hpp
disk_buffer_pool.hpp
disk_cache.hpp
visit_block_iovecs.hpp
disk_completed_queue.hpp
mmap_disk_job.hpp
disk_job.hpp
Expand Down Expand Up @@ -226,6 +228,7 @@ set(libtorrent_aux_include_files
portmap.hpp
posix_part_file.hpp
posix_storage.hpp
pread_disk_job.hpp
proxy_base.hpp
proxy_settings.hpp
puff.hpp
Expand Down Expand Up @@ -327,6 +330,7 @@ set(sources
disabled_disk_io.cpp
disk_buffer_holder.cpp
disk_buffer_pool.cpp
disk_cache.cpp
disk_completed_queue.cpp
disk_io_thread_pool.cpp
disk_job_fence.cpp
Expand Down Expand Up @@ -384,6 +388,8 @@ set(sources
posix_disk_io.cpp
posix_part_file.cpp
posix_storage.cpp
pread_disk_io.cpp
pread_storage.cpp
proxy_base.cpp
proxy_settings.cpp
puff.cpp
Expand Down
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
2.1.0 not released

* add a multi-threaded, pread()-based, disk I/O backend (pread_disk_io)
* try harder to bind TCP and UDP sockets to the same port
* made disk_interface's status_t type a flags type
* optimize resume data format to use less space
Expand Down
3 changes: 3 additions & 0 deletions Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ SOURCES =
directory
disk_buffer_holder
disk_buffer_pool
disk_cache
disk_completed_queue
disk_io_thread_pool
disabled_disk_io
Expand Down Expand Up @@ -900,6 +901,8 @@ SOURCES =
mmap
mmap_disk_io
mmap_storage
pread_disk_io
pread_storage
posix_disk_io
posix_part_file
posix_storage
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ SOURCES = \
disabled_disk_io.cpp \
disk_buffer_holder.cpp \
disk_buffer_pool.cpp \
disk_cache.cpp \
disk_completed_queue.cpp \
disk_io_thread_pool.cpp \
disk_job_fence.cpp \
Expand Down Expand Up @@ -379,6 +380,8 @@ SOURCES = \
posix_disk_io.cpp \
posix_part_file.cpp \
posix_storage.cpp \
pread_disk_io.cpp \
pread_storage.cpp \
proxy_base.cpp \
proxy_settings.cpp \
puff.cpp \
Expand Down Expand Up @@ -495,6 +498,7 @@ HEADERS = \
piece_block.hpp \
portmap.hpp \
posix_disk_io.hpp \
pread_disk_io.hpp \
read_resume_data.hpp \
session.hpp \
session_handle.hpp \
Expand Down Expand Up @@ -560,6 +564,8 @@ HEADERS = \
aux_/disable_warnings_pop.hpp \
aux_/disable_warnings_push.hpp \
aux_/disk_buffer_pool.hpp \
aux_/disk_cache.hpp \
aux_/visit_block_iovecs.hpp \
aux_/disk_completed_queue.hpp \
aux_/disk_io_thread_pool.hpp \
aux_/disk_job_fence.hpp \
Expand Down Expand Up @@ -626,6 +632,8 @@ HEADERS = \
aux_/portmap.hpp \
aux_/posix_part_file.hpp \
aux_/posix_storage.hpp \
aux_/pread_disk_job.hpp \
aux_/pread_storage.hpp \
aux_/proxy_base.hpp \
aux_/proxy_settings.hpp \
aux_/puff.hpp \
Expand Down
3 changes: 3 additions & 0 deletions bindings/python/src/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <libtorrent/mmap_disk_io.hpp>
#include <libtorrent/posix_disk_io.hpp>
#include <libtorrent/pread_disk_io.hpp>

namespace boost
{
Expand Down Expand Up @@ -882,6 +883,8 @@ namespace
#endif
if (disk_io == "posix_disk_io_constructor")
s.disk_io_constructor = &lt::posix_disk_io_constructor;
else if (disk_io == "pread_disk_io_constructor")
s.disk_io_constructor = &lt::pread_disk_io_constructor;
else
s.disk_io_constructor = &lt::default_disk_io_constructor;
}
Expand Down
7 changes: 6 additions & 1 deletion examples/client_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ see LICENSE file.

#include "libtorrent/mmap_disk_io.hpp"
#include "libtorrent/posix_disk_io.hpp"
#include "libtorrent/pread_disk_io.hpp"
#include "libtorrent/disabled_disk_io.hpp"

#include "torrent_view.hpp"
Expand Down Expand Up @@ -1347,7 +1348,7 @@ CLIENT OPTIONS
-O print session stats counters to the log
-1 exit on first torrent completing (useful for benchmarks)
-i <disk-io> specify which disk I/O back-end to use. One of:
mmap, posix, disabled
mmap, posix, pread, disabled
)"
#ifdef TORRENT_UTP_LOG_ENABLE
R"(
Expand Down Expand Up @@ -1561,6 +1562,10 @@ int main(int argc, char* argv[])
#endif
if (arg == "posix"_sv)
params.disk_io_constructor = lt::posix_disk_io_constructor;
#if TORRENT_HAVE_PREAD || defined TORRENT_WINDOWS
else if (arg == "pread"_sv)
params.disk_io_constructor = lt::pread_disk_io_constructor;
#endif
else if (arg == "disabled"_sv)
params.disk_io_constructor = lt::disabled_disk_io_constructor;
else
Expand Down
5 changes: 5 additions & 0 deletions include/libtorrent/aux_/debug_disk_thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ see LICENSE file.
#include <string>
#include <sstream>
#include <unordered_map>
#include <thread>

#include "libtorrent/aux_/disk_job.hpp"
#include "libtorrent/disk_interface.hpp"
Expand Down Expand Up @@ -93,6 +94,10 @@ inline std::string print_job(aux::disk_job const& j)
<< " buf-offset:" << j.buffer_offset << " size:" << j.buffer_size << " )";
}

void operator()(job::kick_hasher const& j) const {
m_ss << "kick-hasher( piece:" << j.piece << " )";
}

private:
std::stringstream& m_ss;
};
Expand Down
3 changes: 3 additions & 0 deletions include/libtorrent/aux_/disk_buffer_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ see LICENSE file.
#include <mutex>
#include <functional>
#include <memory>
#include <optional>

#include "libtorrent/io_context.hpp"
#include "libtorrent/span.hpp"
Expand Down Expand Up @@ -54,6 +55,8 @@ namespace aux {
return m_in_use;
}

std::optional<int> flush_request() const;

void set_settings(settings_interface const& sett);

private:
Expand Down