From 51fb1e3d6be21550e6fdcb3d038828ad7c7cac72 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sun, 5 Aug 2018 16:11:40 +0200 Subject: [PATCH] tweak the auto-cache-size logic to have slightly smaller cache --- examples/client_test.cpp | 2 +- include/libtorrent/settings_pack.hpp | 8 ++++---- src/disk_buffer_pool.cpp | 10 +++++----- src/settings_pack.cpp | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/client_test.cpp b/examples/client_test.cpp index aebc26d00..1d9fdb253 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -484,7 +484,7 @@ int poll_interval = 5; int max_connections_per_torrent = 50; bool seed_mode = false; bool stats_enabled = false; -int cache_size = 1024; +int cache_size = -1; bool share_mode = false; bool disable_storage = false; diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index e5e3036e0..e762f941b 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -979,9 +979,9 @@ namespace libtorrent { // or receive buffer also count against this limit. Send and receive // buffers will never be denied to be allocated, but they will cause // the actual cached blocks to be flushed or evicted. If this is set - // to -1, the cache size is automatically set to the amount of - // physical RAM available in the machine divided by 8. If the amount - // of physical RAM cannot be determined, it's set to 1024 (= 16 MiB). + // to -1, the cache size is automatically set based on the amount of + // physical RAM on the machine. If the amount of physical RAM cannot + // be determined, it's set to 1024 (= 16 MiB). // // ``cache_expiry`` is the number of seconds from the last cached write // to a piece in the write cache, to when it's forcefully flushed to @@ -1593,7 +1593,7 @@ namespace libtorrent { out_enc_policy, in_enc_policy, - // determines the encryption level of the connections. This setting + // determines the encryption level of the connections. This setting // will adjust which encryption scheme is offered to the other peer, // as well as which encryption scheme is selected by the client. See // enc_level enum for options. diff --git a/src/disk_buffer_pool.cpp b/src/disk_buffer_pool.cpp index 75f7a64b0..0915d1fb3 100644 --- a/src/disk_buffer_pool.cpp +++ b/src/disk_buffer_pool.cpp @@ -303,8 +303,8 @@ namespace libtorrent { // The more physical RAM, the smaller portion of it is allocated // for the cache. - // we take a 30th of everything exceeding 4 GiB - // a 20th of everything exceeding 1 GiB + // we take a 40th of everything exceeding 4 GiB + // a 30th of everything exceeding 1 GiB // and a 10th of everything below a GiB constexpr std::int64_t gb = 1024 * 1024 * 1024; @@ -312,15 +312,15 @@ namespace libtorrent { std::int64_t result = 0; if (phys_ram > 4 * gb) { - result += (phys_ram - 4 * gb) / 30; + result += (phys_ram - 4 * gb) / 40; phys_ram = 4 * gb; } if (phys_ram > 1 * gb) { - result += (phys_ram - 1 * gb) / 20; + result += (phys_ram - 1 * gb) / 30; phys_ram = 1 * gb; } - result += phys_ram / 10; + result += phys_ram / 20; m_max_use = int(result / default_block_size); } diff --git a/src/settings_pack.cpp b/src/settings_pack.cpp index 88b50bb1c..0df55d41a 100644 --- a/src/settings_pack.cpp +++ b/src/settings_pack.cpp @@ -248,7 +248,7 @@ constexpr int CLOSE_FILE_INTERVAL = 0; SET(send_buffer_watermark_factor, 50, nullptr), SET(choking_algorithm, settings_pack::fixed_slots_choker, nullptr), SET(seed_choking_algorithm, settings_pack::round_robin, nullptr), - SET(cache_size, 1024, nullptr), + SET(cache_size, 2048, nullptr), DEPRECATED_SET(cache_buffer_chunk_size, 0, nullptr), SET(cache_expiry, 300, nullptr), SET(disk_io_write_mode, settings_pack::enable_os_cache, nullptr),