Browse Source

Merge pull request #13499 from bershanskiy/hashing_threads

Add option for hashing_threads setting
adaptive-webui-19844
Mike Tzou 4 years ago committed by GitHub
parent
commit
5be7b256e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      src/base/bittorrent/session.cpp
  2. 3
      src/base/bittorrent/session.h
  3. 17
      src/gui/advancedsettings.cpp
  4. 2
      src/gui/advancedsettings.h
  5. 5
      src/webui/api/appcontroller.cpp
  6. 10
      src/webui/www/private/views/preferences.html

20
src/base/bittorrent/session.cpp

@ -329,7 +329,8 @@ Session::Session(QObject *parent) @@ -329,7 +329,8 @@ 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_asyncIOThreads(BITTORRENT_SESSION_KEY("AsyncIOThreadsCount"), 10)
, m_hashingThreads(BITTORRENT_SESSION_KEY("HashingThreadsCount"), 2)
, m_filePoolSize(BITTORRENT_SESSION_KEY("FilePoolSize"), 40)
, m_checkingMemUsage(BITTORRENT_SESSION_KEY("CheckingMemUsageSize"), 32)
#if (LIBTORRENT_VERSION_NUM >= 10206)
@ -1269,6 +1270,9 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack) @@ -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::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());
const int checkingMemUsageSize = checkingMemUsage() * 64;
@ -3030,6 +3034,20 @@ void Session::setAsyncIOThreads(const int num) @@ -3030,6 +3034,20 @@ void Session::setAsyncIOThreads(const int num)
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
{
return m_filePoolSize;

3
src/base/bittorrent/session.h

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

17
src/gui/advancedsettings.cpp

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

2
src/gui/advancedsettings.h

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

5
src/webui/api/appcontroller.cpp

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

10
src/webui/www/private/views/preferences.html

@ -943,6 +943,14 @@ @@ -943,6 +943,14 @@
<input type="text" id="asyncIOThreads" style="width: 15em;" />
</td>
</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>
<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>
@ -1871,6 +1879,7 @@ @@ -1871,6 +1879,7 @@
$('resolvePeerCountries').setProperty('checked', pref.resolve_peer_countries);
// libtorrent section
$('asyncIOThreads').setProperty('value', pref.async_io_threads);
$('hashingThreads').setProperty('value', pref.hashing_threads);
$('filePoolSize').setProperty('value', pref.file_pool_size);
$('outstandMemoryWhenCheckingTorrents').setProperty('value', pref.checking_memory_use);
$('diskCache').setProperty('value', pref.disk_cache);
@ -2257,6 +2266,7 @@ @@ -2257,6 +2266,7 @@
// libtorrent section
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('checking_memory_use', $('outstandMemoryWhenCheckingTorrents').getProperty('value'));
settings.set('disk_cache', $('diskCache').getProperty('value'));

Loading…
Cancel
Save