diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 0a4a06bd3..7a78a6acc 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -274,6 +274,7 @@ Session::Session(QObject *parent) , m_IPFilterFile(BITTORRENT_SESSION_KEY("IPFilter")) , m_announceToAllTrackers(BITTORRENT_SESSION_KEY("AnnounceToAllTrackers"), false) , m_announceToAllTiers(BITTORRENT_SESSION_KEY("AnnounceToAllTiers"), true) + , m_asyncIOThreads(BITTORRENT_SESSION_KEY("AsyncIOThreadsCount"), 4) , m_diskCacheSize(BITTORRENT_SESSION_KEY("DiskCacheSize"), 64) , m_diskCacheTTL(BITTORRENT_SESSION_KEY("DiskCacheTTL"), 60) , m_useOSCache(BITTORRENT_SESSION_KEY("UseOSCache"), true) @@ -1310,6 +1311,8 @@ void Session::configure(libtorrent::settings_pack &settingsPack) settingsPack.set_bool(libt::settings_pack::announce_to_all_trackers, announceToAllTrackers()); settingsPack.set_bool(libt::settings_pack::announce_to_all_tiers, announceToAllTiers()); + settingsPack.set_int(libt::settings_pack::aio_threads, asyncIOThreads()); + const int cacheSize = (diskCacheSize() > -1) ? (diskCacheSize() * 64) : -1; settingsPack.set_int(libt::settings_pack::cache_size, cacheSize); settingsPack.set_int(libt::settings_pack::cache_expiry, diskCacheTTL()); @@ -3028,6 +3031,20 @@ void Session::setAnnounceToAllTiers(bool val) } } +int Session::asyncIOThreads() const +{ + return qBound(1, m_asyncIOThreads.value(), 1024); +} + +void Session::setAsyncIOThreads(const int num) +{ + if (num == m_asyncIOThreads) + return; + + m_asyncIOThreads = num; + configureDeferred(); +} + int Session::diskCacheSize() const { int size = m_diskCacheSize; diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index 60c34e46a..ec563766e 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -375,6 +375,8 @@ namespace BitTorrent void setAnnounceToAllTrackers(bool val); bool announceToAllTiers() const; void setAnnounceToAllTiers(bool val); + int asyncIOThreads() const; + void setAsyncIOThreads(int num); int diskCacheSize() const; void setDiskCacheSize(int size); int diskCacheTTL() const; @@ -651,6 +653,7 @@ namespace BitTorrent CachedSettingValue m_IPFilterFile; CachedSettingValue m_announceToAllTrackers; CachedSettingValue m_announceToAllTiers; + CachedSettingValue m_asyncIOThreads; CachedSettingValue m_diskCacheSize; CachedSettingValue m_diskCacheTTL; CachedSettingValue m_useOSCache; diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index 69f559913..e9622440a 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -79,6 +79,9 @@ enum AdvSettingsRows // libtorrent section LIBTORRENT_HEADER, +#if LIBTORRENT_VERSION_NUM >= 10100 + ASYNC_IO_THREADS, +#endif // cache DISK_CACHE, DISK_CACHE_TTL, @@ -144,6 +147,10 @@ void AdvancedSettings::saveAdvancedSettings() Preferences *const pref = Preferences::instance(); BitTorrent::Session *const session = BitTorrent::Session::instance(); +#if LIBTORRENT_VERSION_NUM >= 10100 + // Async IO threads + session->setAsyncIOThreads(spinBoxAsyncIOThreads.value()); +#endif // Disk write cache session->setDiskCacheSize(spinBoxCache.value()); session->setDiskCacheTTL(spinBoxCacheTTL.value()); @@ -308,6 +315,14 @@ void AdvancedSettings::loadAdvancedSettings() item(LIBTORRENT_HEADER, PROPERTY)->setFont(boldFont); labelLibtorrentLink.setText(QString("%2").arg("https://www.libtorrent.org/reference.html", tr("Open documentation"))); labelLibtorrentLink.setOpenExternalLinks(true); + +#if LIBTORRENT_VERSION_NUM >= 10100 + // Async IO threads + spinBoxAsyncIOThreads.setMinimum(1); + spinBoxAsyncIOThreads.setMaximum(1024); + spinBoxAsyncIOThreads.setValue(session->asyncIOThreads()); + addRow(ASYNC_IO_THREADS, tr("Asynchronous I/O threads"), &spinBoxAsyncIOThreads); +#endif // Disk write cache spinBoxCache.setMinimum(-1); // When build as 32bit binary, set the maximum at less than 2GB to prevent crashes. diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index 61588a32b..be3feffaf 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -59,7 +59,7 @@ private: template void addRow(int row, const QString &rowText, T *widget); QLabel labelQbtLink, labelLibtorrentLink; - QSpinBox spinBoxCache, spinBoxSaveResumeDataInterval, spinBoxOutgoingPortsMin, spinBoxOutgoingPortsMax, spinBoxListRefresh, spinBoxMaxHalfOpen, + QSpinBox spinBoxAsyncIOThreads, spinBoxCache, spinBoxSaveResumeDataInterval, spinBoxOutgoingPortsMin, spinBoxOutgoingPortsMax, spinBoxListRefresh, spinBoxMaxHalfOpen, spinBoxTrackerPort, spinBoxCacheTTL, spinBoxSendBufferWatermark, spinBoxSendBufferLowWatermark, spinBoxSendBufferWatermarkFactor, spinBoxSavePathHistoryLength; QCheckBox checkBoxOsCache, checkBoxRecheckCompleted, checkBoxResolveCountries, checkBoxResolveHosts, checkBoxSuperSeeding,