From 675d16a2c33d18798789e4fa08ab55e68d53fba8 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 25 Oct 2016 08:02:34 -0400 Subject: [PATCH] remove remainder of eviction/ghost torrent feature (#1251) remove remainder of eviction/ghost torrent feature --- docs/gen_stats_doc.py | 8 ++++ docs/manual.rst | 37 ----------------- examples/client_test.cpp | 16 -------- examples/torrent_view.cpp | 2 +- include/libtorrent/aux_/session_impl.hpp | 44 ++++++++++++--------- include/libtorrent/performance_counters.hpp | 2 + include/libtorrent/session_handle.hpp | 3 +- include/libtorrent/settings_pack.hpp | 20 ++++++---- simulation/test_swarm.cpp | 3 -- src/session_handle.cpp | 2 +- src/session_stats.cpp | 2 + src/settings_pack.cpp | 2 +- tools/parse_session_stats.py | 2 +- 13 files changed, 56 insertions(+), 87 deletions(-) diff --git a/docs/gen_stats_doc.py b/docs/gen_stats_doc.py index 901e78087..16093a476 100755 --- a/docs/gen_stats_doc.py +++ b/docs/gen_stats_doc.py @@ -85,6 +85,14 @@ for l in f: l = l.strip() + if mode == 'ignore': + if '#endif' in l: mode = '' + continue + + if 'TORRENT_NO_DEPRECATE' in l: + mode = 'ignore' + continue + if description_line == True: if len(names) > 0: render_section(names, description, types) diff --git a/docs/manual.rst b/docs/manual.rst index e17498919..be4c12bcb 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -564,43 +564,6 @@ aligned. .. _`BEP 17`: http://bittorrent.org/beps/bep_0017.html .. _`BEP 19`: http://bittorrent.org/beps/bep_0019.html -dynamic loading of torrent files -================================ - -libtorrent has a feature that can unload idle torrents from memory. The purpose -of this is to support being active on many more torrents than the RAM permits. -This is useful for both embedded devices that have limited RAM and servers -seeding tens of thousands of torrents. - -The most significant parts of loaded torrents that use RAM are the piece -hashes (20 bytes per piece) and the file list. The entire info-dictionary -of the .torrent file is kept in RAM. - -In order to activate the dynamic loading of torrent files, set the load -function on the session. See set_load_function(). - -When a load function is set on the session, the dynamic load/unload -feature is enabled. Torrents are kept in an LRU. Every time an operation -is performed, on a torrent or from a peer, that requires the metadata of -the torrent to be loaded, the torrent is bumped up in the LRU. When a torrent -is paused or queued, it is demoted to the least recently used torrent in -the LRU, since it's a good candidate for eviction. - -To configure how many torrents are allowed to be loaded at the same time, -set settings_pack::active_loaded_limit on the session. - -Torrents can be exempt from being unloaded by being *pinned*. Pinned torrents -still count against the limit, but are never considered for eviction. -You can either pin a torrent when adding it, in ``add_torrent_params`` -(see async_add_torrent() and add_torrent()), or after ading it with the -set_pinned() function on torrent_handle. - -Torrents that start out without metadata (e.g. magnet links or http downloads) -are automatically pinned. This is important in order to give the client a -chance to save the metadata to disk once it's received (see metadata_received_alert). - -Once the metadata is saved to disk, it might make sense to unpin the torrent. - piece picker ============ diff --git a/examples/client_test.cpp b/examples/client_test.cpp index e7ae87dbc..7b7c0b163 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -573,20 +573,6 @@ void signal_handler(int) quit = true; } -void load_torrent(libtorrent::sha1_hash const& ih, std::vector& buf, libtorrent::error_code& ec) -{ - files_t::iterator i = hash_to_filename.find(ih); - if (i == hash_to_filename.end()) - { - // for magnet links and torrents downloaded via - // URL, the metadata is saved in the resume file - // TODO: pick up metadata from the resume file - ec.assign(boost::system::errc::no_such_file_or_directory, boost::system::generic_category()); - return; - } - load_file(i->second, buf, ec); -} - // if non-empty, a peer that will be added to all torrents std::string peer; @@ -1213,7 +1199,6 @@ int main(int argc, char* argv[]) settings_pack settings; settings.set_int(settings_pack::cache_size, cache_size); - settings.set_int(settings_pack::active_loaded_limit, 20); settings.set_int(settings_pack::choking_algorithm, settings_pack::rate_based_choker); int refresh_delay = 500; @@ -1393,7 +1378,6 @@ int main(int argc, char* argv[]) } ses.set_ip_filter(loaded_ip_filter); - ses.set_load_function(&load_torrent); error_code ec; diff --git a/examples/torrent_view.cpp b/examples/torrent_view.cpp index 58f39baf2..0c7759a9c 100644 --- a/examples/torrent_view.cpp +++ b/examples/torrent_view.cpp @@ -254,7 +254,7 @@ void torrent_view::print_tabs() char str[400]; int pos = 0; char const* filter_names[] = { "all", "downloading", "non-paused" - , "seeding", "queued", "stopped", "checking", "loaded"}; + , "seeding", "queued", "stopped", "checking"}; for (int i = 0; i < int(sizeof(filter_names)/sizeof(filter_names[0])); ++i) { pos += std::snprintf(str+ pos, sizeof(str) - pos, "%s[%s]%s" diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 2857e1bb0..e3b6bc004 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -221,9 +221,6 @@ namespace libtorrent void start_session(settings_pack pack); - void set_load_function(user_load_function_t fun) - { m_user_load_torrent = fun; } - void init_peer_class_filter(bool unlimited_local); #ifndef TORRENT_DISABLE_EXTENSIONS @@ -295,6 +292,12 @@ namespace libtorrent std::weak_ptr find_torrent(sha1_hash const& info_hash) const override; #ifndef TORRENT_NO_DEPRECATE //deprecated in 1.2 + + TORRENT_DEPRECATED + void set_load_function(user_load_function_t fun) + { m_user_load_torrent = fun; } + + TORRENT_DEPRECATED std::weak_ptr find_torrent(std::string const& uuid) const; #endif #ifndef TORRENT_DISABLE_MUTABLE_TORRENTS @@ -308,6 +311,7 @@ namespace libtorrent , std::string uuid) override; #ifndef TORRENT_NO_DEPRECATE //deprecated in 1.2 + TORRENT_DEPRECATED void insert_uuid_torrent(std::string uuid, std::shared_ptr const& t) override { m_uuids.insert(std::make_pair(uuid, t)); } #endif @@ -368,7 +372,9 @@ namespace libtorrent , void* userdata = nullptr); #ifndef TORRENT_NO_DEPRECATE + TORRENT_DEPRECATED entry dht_state() const; + TORRENT_DEPRECATED void start_dht_deprecated(entry const& startup_state); #endif void on_dht_announce(error_code const& e); @@ -465,23 +471,23 @@ namespace libtorrent alert* wait_for_alert(time_duration max_wait); #ifndef TORRENT_NO_DEPRECATE - void pop_alerts(); - alert const* pop_alert(); - size_t set_alert_queue_size_limit(size_t queue_size_limit_); - int upload_rate_limit_depr() const; - int download_rate_limit_depr() const; - int local_upload_rate_limit() const; - int local_download_rate_limit() const; + TORRENT_DEPRECATED void pop_alerts(); + TORRENT_DEPRECATED alert const* pop_alert(); + TORRENT_DEPRECATED size_t set_alert_queue_size_limit(size_t queue_size_limit_); + TORRENT_DEPRECATED int upload_rate_limit_depr() const; + TORRENT_DEPRECATED int download_rate_limit_depr() const; + TORRENT_DEPRECATED int local_upload_rate_limit() const; + TORRENT_DEPRECATED int local_download_rate_limit() const; - void set_local_download_rate_limit(int bytes_per_second); - void set_local_upload_rate_limit(int bytes_per_second); - void set_download_rate_limit_depr(int bytes_per_second); - void set_upload_rate_limit_depr(int bytes_per_second); - void set_max_connections(int limit); - void set_max_uploads(int limit); + TORRENT_DEPRECATED void set_local_download_rate_limit(int bytes_per_second); + TORRENT_DEPRECATED void set_local_upload_rate_limit(int bytes_per_second); + TORRENT_DEPRECATED void set_download_rate_limit_depr(int bytes_per_second); + TORRENT_DEPRECATED void set_upload_rate_limit_depr(int bytes_per_second); + TORRENT_DEPRECATED void set_max_connections(int limit); + TORRENT_DEPRECATED void set_max_uploads(int limit); - int max_connections() const; - int max_uploads() const; + TORRENT_DEPRECATED int max_connections() const; + TORRENT_DEPRECATED int max_uploads() const; #endif bandwidth_manager* get_bandwidth_manager(int channel) override; @@ -1173,9 +1179,11 @@ namespace libtorrent std::array>, 4> m_ses_extensions; #endif +#ifndef TORRENT_NO_DEPRECATE // if this function is set, it indicates that torrents are allowed // to be unloaded. If it isn't, torrents will never be unloaded user_load_function_t m_user_load_torrent; +#endif // this is true whenever we have posted a deferred-disk job // it means we don't need to post another one diff --git a/include/libtorrent/performance_counters.hpp b/include/libtorrent/performance_counters.hpp index 12dce9abd..152dd5ba9 100644 --- a/include/libtorrent/performance_counters.hpp +++ b/include/libtorrent/performance_counters.hpp @@ -131,7 +131,9 @@ namespace libtorrent on_disk_queue_counter, on_disk_counter, +#ifndef TORRENT_NO_DEPRECATE torrent_evicted_counter, +#endif // bittorrent message counters // TODO: should keepalives be in here too? diff --git a/include/libtorrent/session_handle.hpp b/include/libtorrent/session_handle.hpp index 0e5c4b0c1..1fcc6a9b6 100644 --- a/include/libtorrent/session_handle.hpp +++ b/include/libtorrent/session_handle.hpp @@ -260,6 +260,7 @@ namespace libtorrent void resume(); bool is_paused() const; +#ifndef TORRENT_NO_DEPRECATE // This function enables dynamic-loading-of-torrent-files_. When a // torrent is unloaded but needs to be available in memory, this function // is called **from within the libtorrent network thread**. From within @@ -280,9 +281,9 @@ namespace libtorrent // The signature of the function to pass in is:: // // void fun(sha1_hash const& info_hash, std::vector& buf, error_code& ec); + TORRENT_DEPRECATED void set_load_function(user_load_function_t fun); -#ifndef TORRENT_NO_DEPRECATE // deprecated in libtorrent 1.1, use performance_counters instead // returns session wide-statistics and status. For more information, see // the ``session_status`` struct. diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index ff99d453e..0aa9d5021 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -1045,7 +1045,15 @@ namespace libtorrent // about you for any reason and tries to connect, it will still be // accepted, unless the torrent is paused, which means it won't accept // any connections. - // + active_downloads, + active_seeds, + active_checking, + active_dht_limit, + active_tracker_limit, + active_lsd_limit, + active_limit, + +#ifndef TORRENT_NO_DEPRECATE // ``active_loaded_limit`` is the number of torrents that are allowed // to be *loaded* at any given time. Note that a torrent can be active // even though it's not loaded. If an unloaded torrents finds a peer @@ -1054,14 +1062,10 @@ namespace libtorrent // unloading torrents is not enabled, this setting have no effect. If // this limit is set to 0, it means unlimited. For more information, // see dynamic-loading-of-torrent-files_. - active_downloads, - active_seeds, - active_checking, - active_dht_limit, - active_tracker_limit, - active_lsd_limit, - active_limit, active_loaded_limit, +#else + deprecated20, +#endif // ``auto_manage_interval`` is the number of seconds between the // torrent queue is updated, and rotated. diff --git a/simulation/test_swarm.cpp b/simulation/test_swarm.cpp index 26769b079..a13ac9d9e 100644 --- a/simulation/test_swarm.cpp +++ b/simulation/test_swarm.cpp @@ -118,8 +118,6 @@ TORRENT_TEST(session_stats) std::vector stats = session_stats_metrics(); int const downloading_idx = find_metric_idx("ses.num_downloading_torrents"); TEST_CHECK(downloading_idx >= 0); - int const evicted_idx = find_metric_idx("ses.torrent_evicted_counter"); - TEST_CHECK(evicted_idx >= 0); int const incoming_extended_idx = find_metric_idx("ses.num_incoming_extended"); TEST_CHECK(incoming_extended_idx >= 0); @@ -136,7 +134,6 @@ TORRENT_TEST(session_stats) // there's one downloading torrent TEST_EQUAL(ss->values[downloading_idx], 1); - TEST_EQUAL(ss->values[evicted_idx], 0); TEST_EQUAL(ss->values[incoming_extended_idx], 1); } // terminate diff --git a/src/session_handle.cpp b/src/session_handle.cpp index 73c737fa1..be0aa6259 100644 --- a/src/session_handle.cpp +++ b/src/session_handle.cpp @@ -421,12 +421,12 @@ namespace libtorrent return sync_call_ret(&session_impl::is_paused); } +#ifndef TORRENT_NO_DEPRECATE void session_handle::set_load_function(user_load_function_t fun) { async_call(&session_impl::set_load_function, fun); } -#ifndef TORRENT_NO_DEPRECATE session_status session_handle::status() const { return sync_call_ret(&session_impl::status); diff --git a/src/session_stats.cpp b/src/session_stats.cpp index 88f41c437..414dcd60d 100644 --- a/src/session_stats.cpp +++ b/src/session_stats.cpp @@ -230,10 +230,12 @@ namespace libtorrent METRIC(ses, num_have_pieces) METRIC(ses, num_total_pieces_added) +#ifndef TORRENT_NO_DEPRECATE // this counts the number of times a torrent has been // evicted (only applies when `dynamic loading of torrent files`_ // is enabled). METRIC(ses, torrent_evicted_counter) +#endif // the number of allowed unchoked peers METRIC(ses, num_unchoke_slots) diff --git a/src/settings_pack.cpp b/src/settings_pack.cpp index 1b6b50fec..0ae33aa0a 100644 --- a/src/settings_pack.cpp +++ b/src/settings_pack.cpp @@ -240,7 +240,7 @@ namespace libtorrent SET(active_tracker_limit, 1600, nullptr), SET(active_lsd_limit, 60, nullptr), SET(active_limit, 15, &session_impl::trigger_auto_manage), - SET(active_loaded_limit, 100, &session_impl::trigger_auto_manage), + DEPRECATED_SET(active_loaded_limit, 100, &session_impl::trigger_auto_manage), SET(auto_manage_interval, 30, nullptr), SET(seed_time_limit, 24 * 60 * 60, nullptr), SET(auto_scrape_interval, 1800, nullptr), diff --git a/tools/parse_session_stats.py b/tools/parse_session_stats.py index 2c906e9d3..bc6902d78 100755 --- a/tools/parse_session_stats.py +++ b/tools/parse_session_stats.py @@ -490,7 +490,7 @@ reports = [ 'disk.arc_mfu_ghost_size' \ ], {'allow-negative': True}), - ('torrent churn', 'num torrents', '', '', ['ses.num_loaded_torrents', 'ses.num_pinned_torrents', 'ses.torrent_evicted_counter']), + ('torrent churn', 'num torrents', '', '', ['ses.num_loaded_torrents', 'ses.num_pinned_torrents']), ('pinned torrents', 'num torrents', '', '', ['ses.num_pinned_torrents']), ('loaded torrents', 'num torrents', '', '', ['ses.num_loaded_torrents', 'ses.num_pinned_torrents']), ('request latency', 'us', '', 'latency from receiving requests to sending response', ['disk.request_latency']),