Add "File pool size" option

This commit is contained in:
Chocobo1 2019-07-03 17:44:16 +08:00
parent 6286bc716c
commit ed2199b91c
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
4 changed files with 32 additions and 1 deletions

View File

@ -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());

View File

@ -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<bool> m_announceToAllTrackers;
CachedSettingValue<bool> m_announceToAllTiers;
CachedSettingValue<int> m_asyncIOThreads;
CachedSettingValue<int> m_filePoolSize;
CachedSettingValue<int> m_checkingMemUsage;
CachedSettingValue<int> m_diskCacheSize;
CachedSettingValue<int> m_diskCacheTTL;

View File

@ -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<int>::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.

View File

@ -59,7 +59,8 @@ private:
template <typename T> 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,