From ed2199b91c2cc1b342bdd275d06035b6d6036756 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 3 Jul 2019 17:44:16 +0800 Subject: [PATCH] Add "File pool size" option --- src/base/bittorrent/session.cpp | 17 +++++++++++++++++ src/base/bittorrent/session.h | 3 +++ src/gui/advancedsettings.cpp | 10 ++++++++++ src/gui/advancedsettings.h | 3 ++- 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 4b1c89356..b68a94eb4 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -268,6 +268,7 @@ Session::Session(QObject *parent) , m_announceToAllTrackers(BITTORRENT_SESSION_KEY("AnnounceToAllTrackers"), false) , m_announceToAllTiers(BITTORRENT_SESSION_KEY("AnnounceToAllTiers"), true) , m_asyncIOThreads(BITTORRENT_SESSION_KEY("AsyncIOThreadsCount"), 4) + , m_filePoolSize(BITTORRENT_SESSION_KEY("FilePoolSize"), 40) , m_checkingMemUsage(BITTORRENT_SESSION_KEY("CheckingMemUsageSize"), 16) , m_diskCacheSize(BITTORRENT_SESSION_KEY("DiskCacheSize"), 64) , m_diskCacheTTL(BITTORRENT_SESSION_KEY("DiskCacheTTL"), 60) @@ -1255,6 +1256,8 @@ void Session::configure(lt::settings_pack &settingsPack) settingsPack.set_int(lt::settings_pack::aio_threads, asyncIOThreads()); + settingsPack.set_int(lt::settings_pack::file_pool_size, filePoolSize()); + const int checkingMemUsageSize = checkingMemUsage() * 64; settingsPack.set_int(lt::settings_pack::checking_mem_usage, checkingMemUsageSize); @@ -2814,6 +2817,20 @@ void Session::setAsyncIOThreads(const int num) configureDeferred(); } +int Session::filePoolSize() const +{ + return m_filePoolSize; +} + +void Session::setFilePoolSize(const int size) +{ + if (size == m_filePoolSize) + return; + + m_filePoolSize = size; + configureDeferred(); +} + int Session::checkingMemUsage() const { return qMax(1, m_checkingMemUsage.value()); diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index 10b2b79f3..1474a6161 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -320,6 +320,8 @@ namespace BitTorrent void setAnnounceToAllTiers(bool val); int asyncIOThreads() const; void setAsyncIOThreads(int num); + int filePoolSize() const; + void setFilePoolSize(int size); int checkingMemUsage() const; void setCheckingMemUsage(int size); int diskCacheSize() const; @@ -587,6 +589,7 @@ namespace BitTorrent CachedSettingValue m_announceToAllTrackers; CachedSettingValue m_announceToAllTiers; CachedSettingValue m_asyncIOThreads; + CachedSettingValue m_filePoolSize; CachedSettingValue m_checkingMemUsage; CachedSettingValue m_diskCacheSize; CachedSettingValue m_diskCacheTTL; diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index d418e381e..62fbec101 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -89,6 +89,7 @@ enum AdvSettingsRows // libtorrent section LIBTORRENT_HEADER, ASYNC_IO_THREADS, + FILE_POOL_SIZE, CHECKING_MEM_USAGE, // cache DISK_CACHE, @@ -155,6 +156,8 @@ void AdvancedSettings::saveAdvancedSettings() // Async IO threads session->setAsyncIOThreads(spinBoxAsyncIOThreads.value()); + // File pool size + session->setFilePoolSize(spinBoxFilePoolSize.value()); // Checking Memory Usage session->setCheckingMemUsage(spinBoxCheckingMemUsage.value()); // Disk write cache @@ -328,6 +331,13 @@ void AdvancedSettings::loadAdvancedSettings() addRow(ASYNC_IO_THREADS, (tr("Asynchronous I/O threads") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#aio_threads", "(?)")) , &spinBoxAsyncIOThreads); + // File pool size + spinBoxFilePoolSize.setMinimum(1); + spinBoxFilePoolSize.setMaximum(std::numeric_limits::max()); + spinBoxFilePoolSize.setValue(session->filePoolSize()); + addRow(FILE_POOL_SIZE, (tr("File pool size") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#file_pool_size", "(?)")) + , &spinBoxFilePoolSize); + // Checking Memory Usage spinBoxCheckingMemUsage.setMinimum(1); // When build as 32bit binary, set the maximum value lower to prevent crashes. diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index 576a6b922..ebd057d7d 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -59,7 +59,8 @@ private: template void addRow(int row, const QString &text, T *widget); QLabel labelQbtLink, labelLibtorrentLink; - QSpinBox spinBoxAsyncIOThreads, spinBoxCheckingMemUsage, spinBoxCache, spinBoxSaveResumeDataInterval, spinBoxOutgoingPortsMin, spinBoxOutgoingPortsMax, spinBoxListRefresh, + QSpinBox spinBoxAsyncIOThreads, spinBoxFilePoolSize, spinBoxCheckingMemUsage, spinBoxCache, + spinBoxSaveResumeDataInterval, spinBoxOutgoingPortsMin, spinBoxOutgoingPortsMax, spinBoxListRefresh, spinBoxTrackerPort, spinBoxCacheTTL, spinBoxSendBufferWatermark, spinBoxSendBufferLowWatermark, spinBoxSendBufferWatermarkFactor, spinBoxSocketBacklogSize, spinBoxSavePathHistoryLength; QCheckBox checkBoxOsCache, checkBoxRecheckCompleted, checkBoxResolveCountries, checkBoxResolveHosts, checkBoxSuperSeeding,