diff --git a/ChangeLog b/ChangeLog index 472d9f775..0322b2e09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,7 @@ * added support for retrieval of DHT live nodes * complete UNC path support * add packets pool allocator + * remove disk buffer pool allocator * fix last_upload and last_download overflow after 9 hours in past * python binding add more add_torrent_params fields and an invalid key check * introduce introduce distinct types for peer_class_t, piece_index_t and diff --git a/include/libtorrent/disk_buffer_pool.hpp b/include/libtorrent/disk_buffer_pool.hpp index 9f98992fb..ac6925b8c 100644 --- a/include/libtorrent/disk_buffer_pool.hpp +++ b/include/libtorrent/disk_buffer_pool.hpp @@ -35,15 +35,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" -#include "libtorrent/aux_/disable_warnings_push.hpp" - -#ifndef TORRENT_DISABLE_POOL_ALLOCATOR -#include "libtorrent/allocator.hpp" // for page_aligned_allocator -#include -#endif - -#include "libtorrent/aux_/disable_warnings_pop.hpp" - #if TORRENT_USE_INVARIANT_CHECKS #include #endif @@ -87,8 +78,6 @@ namespace libtorrent { int block_size() const { return m_block_size; } - void release_memory(); - int in_use() const { std::unique_lock l(m_pool_mutex); @@ -144,28 +133,6 @@ namespace libtorrent { int m_cache_buffer_chunk_size; -#ifndef TORRENT_DISABLE_POOL_ALLOCATOR - // if this is true, all buffers are allocated - // from m_pool. If this is false, all buffers - // are allocated using page_aligned_allocator. - // if the settings change to prefer the other - // allocator, this bool will not switch over - // to match the settings until all buffers have - // been freed. That way, we never have a mixture - // of buffers allocated from different sources. - // in essence, this make the setting only take - // effect after a restart (which seems fine). - // or once the client goes idle for a while. - bool m_using_pool_allocator; - - // this is the actual user setting - bool m_want_pool_allocator; - - // memory pool for read and write operations - // and disk cache - boost::pool m_pool; -#endif - // this is specifically exempt from release_asserts // since it's a quite costly check. Only for debug // builds. diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index 4e49334fd..34daeb871 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -642,11 +642,15 @@ namespace libtorrent { // failure is preferred, set this to false. listen_system_port_fallback, +#ifndef TORRENT_NO_DEPRECATE // ``use_disk_cache_pool`` enables using a pool allocator for disk // cache blocks. Enabling it makes the cache perform better at high // throughput. It also makes the cache less likely and slower at // returning memory back to the system, once allocated. use_disk_cache_pool, +#else + deprecated24, +#endif // when this is true, and incoming encrypted connections are enabled, // &supportcrypt=1 is included in http tracker announces diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index 305774c88..6a9f144d9 100644 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -293,7 +293,6 @@ namespace libtorrent { // // int block_size() const { return m_block_size; } // - // void release_memory(); // }; virtual void delete_files(remove_flags_t options, storage_error& ec) = 0; diff --git a/src/block_cache.cpp b/src/block_cache.cpp index efd95ff1e..3aaf042dd 100644 --- a/src/block_cache.cpp +++ b/src/block_cache.cpp @@ -692,9 +692,6 @@ cached_piece_entry* block_cache::allocate_piece(disk_io_job const* j, std::uint1 cached_piece_entry* block_cache::add_dirty_block(disk_io_job* j) { -#if !defined TORRENT_DISABLE_POOL_ALLOCATOR - TORRENT_ASSERT(is_disk_buffer(boost::get(j->argument).get())); -#endif #ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS INVARIANT_CHECK; #endif @@ -1616,14 +1613,6 @@ void block_cache::check_invariant() const { if (p.blocks[k].buf) { -#if !defined TORRENT_DISABLE_POOL_ALLOCATOR && defined TORRENT_EXPENSIVE_INVARIANT_CHECKS - TORRENT_PIECE_ASSERT(is_disk_buffer(p.blocks[k].buf), &p); - - // make sure we don't have the same buffer - // in the cache twice - TORRENT_PIECE_ASSERT(buffers.count(p.blocks[k].buf) == 0, &p); - buffers.insert(p.blocks[k].buf); -#endif ++num_blocks; if (p.blocks[k].dirty) { diff --git a/src/disk_buffer_pool.cpp b/src/disk_buffer_pool.cpp index 84da3d5ee..8a4cf8b09 100644 --- a/src/disk_buffer_pool.cpp +++ b/src/disk_buffer_pool.cpp @@ -77,11 +77,6 @@ namespace libtorrent { , m_exceeded_max_size(false) , m_ios(ios) , m_cache_buffer_chunk_size(0) -#ifndef TORRENT_DISABLE_POOL_ALLOCATOR - , m_using_pool_allocator(false) - , m_want_pool_allocator(false) - , m_pool(block_size, 32) -#endif { #if TORRENT_USE_ASSERTS m_magic = 0x1337; @@ -145,13 +140,9 @@ namespace libtorrent { return m_buffers_in_use.count(buffer) == 1; #elif defined TORRENT_DEBUG_BUFFERS return page_aligned_allocator::in_use(buffer); -#elif defined TORRENT_DISABLE_POOL_ALLOCATOR - return true; #else - if (m_using_pool_allocator) - return m_pool.is_from(buffer); - else - return true; + TORRENT_UNUSED(buffer); + return true; #endif } @@ -237,28 +228,8 @@ namespace libtorrent { TORRENT_ASSERT(l.owns_lock()); TORRENT_UNUSED(l); - char* ret; -#if defined TORRENT_DISABLE_POOL_ALLOCATOR + char* ret = page_aligned_allocator::malloc(m_block_size); - ret = page_aligned_allocator::malloc(m_block_size); - -#else - if (m_using_pool_allocator) - { - int const effective_block_size - = m_in_use >= m_max_use - ? 20 // use small increments once we've exceeded the cache size - : m_cache_buffer_chunk_size - ? m_cache_buffer_chunk_size - : std::max(m_max_use / 10, 1); - m_pool.set_next_size(effective_block_size); - ret = static_cast(m_pool.malloc()); - } - else - { - ret = page_aligned_allocator::malloc(m_block_size); - } -#endif if (ret == nullptr) { m_exceeded_max_size = true; @@ -324,14 +295,6 @@ namespace libtorrent { // 0 cache_buffer_chunk_size means 'automatic' (i.e. // proportional to the total disk cache size) m_cache_buffer_chunk_size = sett.get_int(settings_pack::cache_buffer_chunk_size); -#ifndef TORRENT_DISABLE_POOL_ALLOCATOR - // if the chunk size is set to 1, there's no point in creating a pool - m_want_pool_allocator = sett.get_bool(settings_pack::use_disk_cache_pool) - && (m_cache_buffer_chunk_size != 1); - // if there are no allocated blocks, it's OK to switch allocator - if (m_in_use == 0) - m_using_pool_allocator = m_want_pool_allocator; -#endif int const cache_size = sett.get_int(settings_pack::cache_size); if (cache_size < 0) @@ -419,37 +382,9 @@ namespace libtorrent { TORRENT_ASSERT(l.owns_lock()); TORRENT_UNUSED(l); -#if defined TORRENT_DISABLE_POOL_ALLOCATOR - page_aligned_allocator::free(buf); -#else - if (m_using_pool_allocator) - m_pool.free(buf); - else - page_aligned_allocator::free(buf); -#endif // TORRENT_DISABLE_POOL_ALLOCATOR - --m_in_use; - -#ifndef TORRENT_DISABLE_POOL_ALLOCATOR - // should we switch which allocator to use? - if (m_in_use == 0 && m_want_pool_allocator != m_using_pool_allocator) - { - m_pool.release_memory(); - m_using_pool_allocator = m_want_pool_allocator; - } -#endif - } - - void disk_buffer_pool::release_memory() - { - TORRENT_ASSERT(m_magic == 0x1337); -#ifndef TORRENT_DISABLE_POOL_ALLOCATOR - std::unique_lock l(m_pool_mutex); - if (m_using_pool_allocator) - m_pool.release_memory(); -#endif } } diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index b6552ba5d..5f109406b 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -2569,8 +2569,6 @@ namespace libtorrent { , completed_jobs, l); l.unlock(); - m_disk_cache.release_memory(); - j->storage->release_files(j->error); return j->error ? status_t::fatal_disk_error : status_t::no_error; } diff --git a/src/session.cpp b/src/session.cpp index 345470b35..9569f9457 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -240,8 +240,6 @@ namespace libtorrent { // of a resumed file set.set_int(settings_pack::checking_mem_usage, 320); - // the disk cache performs better with the pool allocator - set.set_bool(settings_pack::use_disk_cache_pool, true); return set; } diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 1ea2067db..0d26dcd21 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -3547,8 +3547,6 @@ namespace { } } } - -// m_peer_pool.release_memory(); } namespace { diff --git a/src/settings_pack.cpp b/src/settings_pack.cpp index 6c23f0182..f1b8d3c9d 100644 --- a/src/settings_pack.cpp +++ b/src/settings_pack.cpp @@ -189,7 +189,7 @@ constexpr int CLOSE_FILE_INTERVAL = 0; SET(support_merkle_torrents, true, nullptr), SET(report_redundant_bytes, true, nullptr), SET(listen_system_port_fallback, true, nullptr), - SET(use_disk_cache_pool, true, nullptr), + DEPRECATED_SET(use_disk_cache_pool, false, nullptr), SET(announce_crypto_support, true, nullptr), SET(enable_upnp, true, &session_impl::update_upnp), SET(enable_natpmp, true, &session_impl::update_natpmp),