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

Adds pread_disk_io.cpp and pread_storage.cpp to CMakeList sources #7569

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d8c46d7
add new multi-threaded disk I/O subsystem using preadv and pwritev
arvidn Jul 18, 2022
6220fb7
python binding
arvidn Aug 13, 2022
70ff3d9
add client_test option for disk I/O backend
arvidn Aug 13, 2022
c91aad9
extend benchmark to run on all disk I/O backends
arvidn Aug 13, 2022
08aaedd
update changelog
arvidn Aug 14, 2022
42a4910
fix makefile
arvidn Aug 14, 2022
be2bcc0
fixup pread_storage
arvidn Aug 19, 2022
5bc534d
WIP: read larger buffers when hashing
arvidn Aug 20, 2022
12954f7
fixup
arvidn Sep 19, 2022
8f28e65
fixup error_code
arvidn Dec 30, 2022
9683434
fix sync_file_range
arvidn Dec 30, 2022
041dbe4
no need to set memory priority in pread-diskio
arvidn Dec 30, 2022
5efb9a1
fix warning
arvidn Jan 1, 2023
fded2c9
fixup status_t
arvidn Jan 29, 2023
aa15a09
WIP: disk cache
arvidn Jan 29, 2023
d37955a
wip
arvidn Jan 30, 2023
e20bb7e
WIP: disk cache
arvidn Mar 11, 2023
5ccfc7e
wip
arvidn Mar 26, 2023
2a0478d
wip
arvidn Apr 2, 2023
31507c4
wip
arvidn Apr 23, 2023
ae99237
wip
arvidn Apr 27, 2023
9763c15
wip
arvidn Apr 29, 2023
211baef
wip
arvidn May 7, 2023
94f794d
wip
arvidn May 8, 2023
e6b9b5d
wip
arvidn May 14, 2023
0758693
wip
arvidn May 21, 2023
46f978a
wip
arvidn Jul 3, 2023
5794847
cover multi-index container in debug-iterator and invariant-check bui…
arvidn Jul 5, 2023
eeca1c6
fix release_files job
arvidn Jul 5, 2023
d561cac
wip
arvidn Jul 5, 2023
3880631
wip
arvidn Jul 19, 2023
6354471
wip
arvidn Jul 19, 2023
5215a90
wip
arvidn Jul 20, 2023
e40085c
wip
arvidn Jul 20, 2023
ff0f2f9
optimize buf pointer in cached block entry
arvidn Jul 20, 2023
7716df4
fix
arvidn Jul 20, 2023
d560a23
fenced jobs
arvidn Jul 20, 2023
189d6c3
prep kick hasher
arvidn Jul 20, 2023
7fd1c1f
revert
arvidn Jul 21, 2023
fba86e3
kick_hasher
arvidn Jul 21, 2023
8281094
kick_hasher. allow blocks to be sparse
arvidn Jul 23, 2023
c2c17cd
fix kick_hasher
arvidn Jul 23, 2023
70efaae
wip
arvidn Aug 26, 2023
e2ce1b9
wip
arvidn Aug 26, 2023
a815617
wip
arvidn Aug 27, 2023
fa0ee17
wip
arvidn Sep 3, 2023
c7c4d45
wip
arvidn Sep 9, 2023
1a050d7
WIP
arvidn Sep 17, 2023
6c5ec09
wip
arvidn Oct 17, 2023
a322398
Adds pread_disk_io.cpp and pread_storage.cpp to CMakeList sources
vktr Dec 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ set(libtorrent_aux_include_files
disable_warnings_pop.hpp
disable_warnings_push.hpp
disk_buffer_pool.hpp
disk_cache.hpp
disk_completed_queue.hpp
mmap_disk_job.hpp
disk_job.hpp
Expand Down Expand Up @@ -383,6 +384,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,3 +1,4 @@
* add a multi-threaded, pread()-based, disk I/O backend (pread_disk_io)
* made disk_interface's status_t type a flags type
* optimize resume data format to use less space
* add a simpler overload to bencode() returning a vector<char>
Expand Down
8 changes: 5 additions & 3 deletions Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,8 @@ feature simulator : off on : composite propagated link-incompatible ;
feature.compose <simulator>on : <define>TORRENT_BUILD_SIMULATOR ;

feature invariant-checks : off on full : composite propagated link-incompatible ;
feature.compose <invariant-checks>on : <define>TORRENT_USE_INVARIANT_CHECKS=1 ;
feature.compose <invariant-checks>full : <define>TORRENT_USE_INVARIANT_CHECKS=1 <define>TORRENT_EXPENSIVE_INVARIANT_CHECKS ;
feature.compose <invariant-checks>on : <define>TORRENT_USE_INVARIANT_CHECKS=1 <define>BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING=1 ;
feature.compose <invariant-checks>full : <define>TORRENT_USE_INVARIANT_CHECKS=1 <define>TORRENT_EXPENSIVE_INVARIANT_CHECKS <define>BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING=1 ;

feature utp-log : off on : composite propagated link-incompatible ;
feature.compose <utp-log>on : <define>TORRENT_UTP_LOG_ENABLE ;
Expand Down Expand Up @@ -674,7 +674,7 @@ feature boost-link : default static shared : propagated composite ;
# constructors on some containers when enabling debug iterators, so it's
# possible to turn them off
feature debug-iterators : default off on : composite propagated link-incompatible ;
feature.compose <debug-iterators>on : <define>_GLIBCXX_DEBUG <define>_GLIBCXX_DEBUG_PEDANTIC ;
feature.compose <debug-iterators>on : <define>_GLIBCXX_DEBUG <define>_GLIBCXX_DEBUG_PEDANTIC <defin>BOOST_MULTI_INDEX_ENABLE_SAFE_MODE=1 ;
feature.compose <debug-iterators>off : <define>_ITERATOR_DEBUG_LEVEL=0 ;

feature fpic : off on : composite propagated link-incompatible ;
Expand Down Expand Up @@ -876,6 +876,8 @@ SOURCES =
mmap
mmap_disk_io
mmap_storage
pread_disk_io
pread_storage
posix_disk_io
posix_part_file
posix_storage
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,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 @@ -560,6 +562,7 @@ HEADERS = \
aux_/disable_warnings_pop.hpp \
aux_/disable_warnings_push.hpp \
aux_/disk_buffer_pool.hpp \
aux_/disk_cache.hpp \
aux_/disk_completed_queue.hpp \
aux_/disk_io_thread_pool.hpp \
aux_/disk_job_fence.hpp \
Expand Down Expand Up @@ -626,6 +629,7 @@ HEADERS = \
aux_/portmap.hpp \
aux_/posix_part_file.hpp \
aux_/posix_storage.hpp \
aux_/pread_disk_job.hpp \
aux_/proxy_base.hpp \
aux_/proxy_settings.hpp \
aux_/puff.hpp \
Expand Down
26 changes: 26 additions & 0 deletions bindings/python/src/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include <libtorrent/extensions/ut_metadata.hpp>
#include <libtorrent/extensions/ut_pex.hpp>

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

namespace boost
{
// this fixes mysterious link error on msvc
Expand Down Expand Up @@ -864,6 +868,27 @@ namespace
}
#endif

std::string get_disk_io(session_params const& s)
{
// this field is write-only
return "default_disk_io_constructor";
}

void set_disk_io(session_params& s, std::string disk_io)
{
#if TORRENT_HAVE_MMAP || TORRENT_HAVE_MAP_VIEW_OF_FILE
if (disk_io == "mmap_disk_io_constructor")
s.disk_io_constructor = &lt::mmap_disk_io_constructor;
else
#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;
}

} // anonymous namespace

struct dummy1 {};
Expand Down Expand Up @@ -1040,6 +1065,7 @@ void bind_session()
.def_readwrite("dht_state", &session_params::dht_state)
#endif
.def_readwrite("ip_filter", &session_params::ip_filter)
.add_property("disk_io_constructor", &get_disk_io, &set_disk_io)
;

def("read_session_params", &read_session_params_entry, (arg("dict"), arg("flags")=save_state_flags_t::all()));
Expand Down
7 changes: 7 additions & 0 deletions docs/upgrade_to_2.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,10 @@ to allow reporting the oversized_file condition (which was introduced in
The flags can be found in the ``lt::disk_status`` namespace.

This change affects custom storage implementations.

storage_params
--------------

The storage_params type has two new fields indicating whether the torrent has v1
and/or v2 hashes. this allows disk I/O subsystems to know in advance whether
block-hashes (v2 torrents) or flat piece hashes (v1 torrents) will be required.
39 changes: 31 additions & 8 deletions examples/client_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ see LICENSE file.
#include "libtorrent/write_resume_data.hpp"
#include "libtorrent/string_view.hpp"
#include "libtorrent/disk_interface.hpp" // for open_file_state
#include "libtorrent/disabled_disk_io.hpp" // for disabled_disk_io_constructor
#include "libtorrent/load_torrent.hpp"

#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"
#include "session_view.hpp"
#include "print.hpp"
Expand Down Expand Up @@ -1342,7 +1346,10 @@ CLIENT OPTIONS
-e <loops> exit client after the specified number of iterations
through the main loop
-O print session stats counters to the log
-1 exit on first torrent completing (useful for benchmarks))"
-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, pread, disabled
)"
#ifdef TORRENT_UTP_LOG_ENABLE
R"(
-q Enable uTP transport-level verbose logging
Expand All @@ -1365,12 +1372,7 @@ BITTORRENT OPTIONS
NETWORK OPTIONS
-x <file> loads an emule IP-filter file
-Y Rate limit local peers
)"
#if TORRENT_USE_I2P
R"( -i <i2p-host> the hostname to an I2P SAM bridge to use
)"
#endif
R"(

DISK OPTIONS
-a <mode> sets the allocation mode. [sparse|allocate]
-0 disable disk I/O, read garbage and don't flush to disk
Expand Down Expand Up @@ -1552,6 +1554,27 @@ int main(int argc, char* argv[])
break;
case 'T': max_connections_per_torrent = atoi(arg); break;
case 'r': peer = arg; break;
case 'i': {
#if TORRENT_HAVE_MMAP || TORRENT_HAVE_MAP_VIEW_OF_FILE
if (arg == "mmap"_sv)
params.disk_io_constructor = lt::mmap_disk_io_constructor;
else
#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
{
std::fprintf(stderr, "unknown disk-io subsystem: \"%s\"\n", arg);
std::exit(1);
}
break;
}
case 'e':
{
loop_limit = atoi(arg);
Expand Down
4 changes: 3 additions & 1 deletion examples/connection_tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,9 @@ void generate_data(std::string const path, torrent_info const& ti)
path,
storage_mode_sparse,
priorities,
info_hash
info_hash,
ti.v1(),
ti.v2(),
};

storage_holder st = disk->new_torrent(params, std::shared_ptr<void>());
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
Loading
Loading