Merge pull request #13499 from bershanskiy/hashing_threads

Add option for hashing_threads setting
This commit is contained in:
Mike Tzou 2020-10-14 11:40:01 +08:00 committed by GitHub
commit 5be7b256e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 56 additions and 1 deletions

View File

@ -329,7 +329,8 @@ Session::Session(QObject *parent)
, m_IPFilterFile(BITTORRENT_SESSION_KEY("IPFilter")) , m_IPFilterFile(BITTORRENT_SESSION_KEY("IPFilter"))
, m_announceToAllTrackers(BITTORRENT_SESSION_KEY("AnnounceToAllTrackers"), false) , m_announceToAllTrackers(BITTORRENT_SESSION_KEY("AnnounceToAllTrackers"), false)
, m_announceToAllTiers(BITTORRENT_SESSION_KEY("AnnounceToAllTiers"), true) , m_announceToAllTiers(BITTORRENT_SESSION_KEY("AnnounceToAllTiers"), true)
, m_asyncIOThreads(BITTORRENT_SESSION_KEY("AsyncIOThreadsCount"), 4) , m_asyncIOThreads(BITTORRENT_SESSION_KEY("AsyncIOThreadsCount"), 10)
, m_hashingThreads(BITTORRENT_SESSION_KEY("HashingThreadsCount"), 2)
, m_filePoolSize(BITTORRENT_SESSION_KEY("FilePoolSize"), 40) , m_filePoolSize(BITTORRENT_SESSION_KEY("FilePoolSize"), 40)
, m_checkingMemUsage(BITTORRENT_SESSION_KEY("CheckingMemUsageSize"), 32) , m_checkingMemUsage(BITTORRENT_SESSION_KEY("CheckingMemUsageSize"), 32)
#if (LIBTORRENT_VERSION_NUM >= 10206) #if (LIBTORRENT_VERSION_NUM >= 10206)
@ -1269,6 +1270,9 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack)
settingsPack.set_int(lt::settings_pack::peer_turnover_interval, peerTurnoverInterval()); settingsPack.set_int(lt::settings_pack::peer_turnover_interval, peerTurnoverInterval());
settingsPack.set_int(lt::settings_pack::aio_threads, asyncIOThreads()); settingsPack.set_int(lt::settings_pack::aio_threads, asyncIOThreads());
#if (LIBTORRENT_VERSION_NUM >= 20000)
settingsPack.set_int(lt::settings_pack::hashing_threads, hashingThreads());
#endif
settingsPack.set_int(lt::settings_pack::file_pool_size, filePoolSize()); settingsPack.set_int(lt::settings_pack::file_pool_size, filePoolSize());
const int checkingMemUsageSize = checkingMemUsage() * 64; const int checkingMemUsageSize = checkingMemUsage() * 64;
@ -3030,6 +3034,20 @@ void Session::setAsyncIOThreads(const int num)
configureDeferred(); configureDeferred();
} }
int Session::hashingThreads() const
{
return qBound(1, m_hashingThreads.value(), 1024);
}
void Session::setHashingThreads(const int num)
{
if (num == m_hashingThreads)
return;
m_hashingThreads = num;
configureDeferred();
}
int Session::filePoolSize() const int Session::filePoolSize() const
{ {
return m_filePoolSize; return m_filePoolSize;

View File

@ -342,6 +342,8 @@ namespace BitTorrent
void setPeerTurnoverInterval(int num); void setPeerTurnoverInterval(int num);
int asyncIOThreads() const; int asyncIOThreads() const;
void setAsyncIOThreads(int num); void setAsyncIOThreads(int num);
int hashingThreads() const;
void setHashingThreads(int num);
int filePoolSize() const; int filePoolSize() const;
void setFilePoolSize(int size); void setFilePoolSize(int size);
int checkingMemUsage() const; int checkingMemUsage() const;
@ -651,6 +653,7 @@ namespace BitTorrent
CachedSettingValue<bool> m_announceToAllTrackers; CachedSettingValue<bool> m_announceToAllTrackers;
CachedSettingValue<bool> m_announceToAllTiers; CachedSettingValue<bool> m_announceToAllTiers;
CachedSettingValue<int> m_asyncIOThreads; CachedSettingValue<int> m_asyncIOThreads;
CachedSettingValue<int> m_hashingThreads;
CachedSettingValue<int> m_filePoolSize; CachedSettingValue<int> m_filePoolSize;
CachedSettingValue<int> m_checkingMemUsage; CachedSettingValue<int> m_checkingMemUsage;
CachedSettingValue<int> m_diskCacheSize; CachedSettingValue<int> m_diskCacheSize;

View File

@ -85,6 +85,9 @@ namespace
// libtorrent section // libtorrent section
LIBTORRENT_HEADER, LIBTORRENT_HEADER,
ASYNC_IO_THREADS, ASYNC_IO_THREADS,
#if (LIBTORRENT_VERSION_NUM >= 20000)
HASHING_THREADS,
#endif
FILE_POOL_SIZE, FILE_POOL_SIZE,
CHECKING_MEM_USAGE, CHECKING_MEM_USAGE,
#if (LIBTORRENT_VERSION_NUM < 20000) #if (LIBTORRENT_VERSION_NUM < 20000)
@ -187,6 +190,10 @@ void AdvancedSettings::saveAdvancedSettings()
#endif #endif
// Async IO threads // Async IO threads
session->setAsyncIOThreads(m_spinBoxAsyncIOThreads.value()); session->setAsyncIOThreads(m_spinBoxAsyncIOThreads.value());
#if (LIBTORRENT_VERSION_NUM >= 20000)
// Hashing threads
session->setHashingThreads(m_spinBoxHashingThreads.value());
#endif
// File pool size // File pool size
session->setFilePoolSize(m_spinBoxFilePoolSize.value()); session->setFilePoolSize(m_spinBoxFilePoolSize.value());
// Checking Memory Usage // Checking Memory Usage
@ -409,6 +416,16 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxAsyncIOThreads.setValue(session->asyncIOThreads()); m_spinBoxAsyncIOThreads.setValue(session->asyncIOThreads());
addRow(ASYNC_IO_THREADS, (tr("Asynchronous I/O threads") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#aio_threads", "(?)")) addRow(ASYNC_IO_THREADS, (tr("Asynchronous I/O threads") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#aio_threads", "(?)"))
, &m_spinBoxAsyncIOThreads); , &m_spinBoxAsyncIOThreads);
#if (LIBTORRENT_VERSION_NUM >= 20000)
// Hashing threads
m_spinBoxHashingThreads.setMinimum(1);
m_spinBoxHashingThreads.setMaximum(1024);
m_spinBoxHashingThreads.setValue(session->hashingThreads());
addRow(HASHING_THREADS, (tr("Hashing threads") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#hashing_threads", "(?)"))
, &m_spinBoxHashingThreads);
#endif
// File pool size // File pool size
m_spinBoxFilePoolSize.setMinimum(1); m_spinBoxFilePoolSize.setMinimum(1);
m_spinBoxFilePoolSize.setMaximum(std::numeric_limits<int>::max()); m_spinBoxFilePoolSize.setMaximum(std::numeric_limits<int>::max());

View File

@ -77,6 +77,8 @@ private:
#if (LIBTORRENT_VERSION_NUM < 20000) #if (LIBTORRENT_VERSION_NUM < 20000)
QSpinBox m_spinBoxCache, m_spinBoxCacheTTL; QSpinBox m_spinBoxCache, m_spinBoxCacheTTL;
QCheckBox m_checkBoxCoalesceRW; QCheckBox m_checkBoxCoalesceRW;
#else
QSpinBox m_spinBoxHashingThreads;
#endif #endif
// OS dependent settings // OS dependent settings

View File

@ -277,6 +277,8 @@ void AppController::preferencesAction()
// libtorrent preferences // libtorrent preferences
// Async IO threads // Async IO threads
data["async_io_threads"] = session->asyncIOThreads(); data["async_io_threads"] = session->asyncIOThreads();
// Hashing threads
data["hashing_threads"] = session->hashingThreads();
// File pool size // File pool size
data["file_pool_size"] = session->filePoolSize(); data["file_pool_size"] = session->filePoolSize();
// Checking memory usage // Checking memory usage
@ -701,6 +703,9 @@ void AppController::setPreferencesAction()
// Async IO threads // Async IO threads
if (hasKey("async_io_threads")) if (hasKey("async_io_threads"))
session->setAsyncIOThreads(it.value().toInt()); session->setAsyncIOThreads(it.value().toInt());
// Hashing threads
if (hasKey("hashing_threads"))
session->setHashingThreads(it.value().toInt());
// File pool size // File pool size
if (hasKey("file_pool_size")) if (hasKey("file_pool_size"))
session->setFilePoolSize(it.value().toInt()); session->setFilePoolSize(it.value().toInt());

View File

@ -943,6 +943,14 @@
<input type="text" id="asyncIOThreads" style="width: 15em;" /> <input type="text" id="asyncIOThreads" style="width: 15em;" />
</td> </td>
</tr> </tr>
<tr>
<td>
<label for="hashingThreads">QBT_TR(Hashing threads (requires libtorrent >= 2.0):)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#hashing_threads" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="hashingThreads" style="width: 15em;" />
</td>
</tr>
<tr> <tr>
<td> <td>
<label for="filePoolSize">QBT_TR(File pool size:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#file_pool_size" target="_blank">(?)</a></label> <label for="filePoolSize">QBT_TR(File pool size:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#file_pool_size" target="_blank">(?)</a></label>
@ -1871,6 +1879,7 @@
$('resolvePeerCountries').setProperty('checked', pref.resolve_peer_countries); $('resolvePeerCountries').setProperty('checked', pref.resolve_peer_countries);
// libtorrent section // libtorrent section
$('asyncIOThreads').setProperty('value', pref.async_io_threads); $('asyncIOThreads').setProperty('value', pref.async_io_threads);
$('hashingThreads').setProperty('value', pref.hashing_threads);
$('filePoolSize').setProperty('value', pref.file_pool_size); $('filePoolSize').setProperty('value', pref.file_pool_size);
$('outstandMemoryWhenCheckingTorrents').setProperty('value', pref.checking_memory_use); $('outstandMemoryWhenCheckingTorrents').setProperty('value', pref.checking_memory_use);
$('diskCache').setProperty('value', pref.disk_cache); $('diskCache').setProperty('value', pref.disk_cache);
@ -2257,6 +2266,7 @@
// libtorrent section // libtorrent section
settings.set('async_io_threads', $('asyncIOThreads').getProperty('value')); settings.set('async_io_threads', $('asyncIOThreads').getProperty('value'));
settings.set('hashing_threads', $('hashingThreads').getProperty('value'));
settings.set('file_pool_size', $('filePoolSize').getProperty('value')); settings.set('file_pool_size', $('filePoolSize').getProperty('value'));
settings.set('checking_memory_use', $('outstandMemoryWhenCheckingTorrents').getProperty('value')); settings.set('checking_memory_use', $('outstandMemoryWhenCheckingTorrents').getProperty('value'));
settings.set('disk_cache', $('diskCache').getProperty('value')); settings.set('disk_cache', $('diskCache').getProperty('value'));