Browse Source

Add tuning options related to performance warnings

Related: #16462.
PR #16538.
adaptive-webui-19844
Chocobo1 3 years ago committed by GitHub
parent
commit
ac97ed685f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 34
      src/base/bittorrent/session.cpp
  2. 12
      src/base/bittorrent/session.h
  3. 19
      src/gui/advancedsettings.cpp
  4. 4
      src/gui/advancedsettings.h
  5. 10
      src/webui/api/appcontroller.cpp
  6. 2
      src/webui/webapplication.h
  7. 20
      src/webui/www/private/views/preferences.html

34
src/base/bittorrent/session.cpp

@ -379,6 +379,7 @@ Session::Session(QObject *parent) @@ -379,6 +379,7 @@ Session::Session(QObject *parent)
, m_checkingMemUsage(BITTORRENT_SESSION_KEY("CheckingMemUsageSize"), 32)
, m_diskCacheSize(BITTORRENT_SESSION_KEY("DiskCacheSize"), -1)
, m_diskCacheTTL(BITTORRENT_SESSION_KEY("DiskCacheTTL"), 60)
, m_diskQueueSize(BITTORRENT_SESSION_KEY("DiskQueueSize"), (1024 * 1024))
, m_useOSCache(BITTORRENT_SESSION_KEY("UseOSCache"), true)
#ifdef Q_OS_WIN
, m_coalesceReadWriteEnabled(BITTORRENT_SESSION_KEY("CoalesceReadWrite"), true)
@ -468,6 +469,7 @@ Session::Session(QObject *parent) @@ -468,6 +469,7 @@ Session::Session(QObject *parent)
, m_peerTurnover(BITTORRENT_SESSION_KEY("PeerTurnover"), 4)
, m_peerTurnoverCutoff(BITTORRENT_SESSION_KEY("PeerTurnoverCutOff"), 90)
, m_peerTurnoverInterval(BITTORRENT_SESSION_KEY("PeerTurnoverInterval"), 300)
, m_requestQueueSize(BITTORRENT_SESSION_KEY("RequestQueueSize"), 500)
, m_bannedIPs("State/BannedIPs"
, QStringList()
, [](const QStringList &value)
@ -1330,6 +1332,8 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack) @@ -1330,6 +1332,8 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack)
settingsPack.set_int(lt::settings_pack::peer_turnover_cutoff, peerTurnoverCutoff());
settingsPack.set_int(lt::settings_pack::peer_turnover_interval, peerTurnoverInterval());
settingsPack.set_int(lt::settings_pack::max_out_request_queue, requestQueueSize());
settingsPack.set_int(lt::settings_pack::aio_threads, asyncIOThreads());
#ifdef QBT_USES_LIBTORRENT2
settingsPack.set_int(lt::settings_pack::hashing_threads, hashingThreads());
@ -1345,6 +1349,8 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack) @@ -1345,6 +1349,8 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack)
settingsPack.set_int(lt::settings_pack::cache_expiry, diskCacheTTL());
#endif
settingsPack.set_int(lt::settings_pack::max_queued_disk_bytes, diskQueueSize());
lt::settings_pack::io_buffer_mode_t mode = useOSCache() ? lt::settings_pack::enable_os_cache
: lt::settings_pack::disable_os_cache;
settingsPack.set_int(lt::settings_pack::disk_io_read_mode, mode);
@ -3259,6 +3265,20 @@ void Session::setPeerTurnoverInterval(const int val) @@ -3259,6 +3265,20 @@ void Session::setPeerTurnoverInterval(const int val)
configureDeferred();
}
int Session::requestQueueSize() const
{
return m_requestQueueSize;
}
void Session::setRequestQueueSize(const int val)
{
if (val == m_requestQueueSize)
return;
m_requestQueueSize = val;
configureDeferred();
}
int Session::asyncIOThreads() const
{
return std::clamp(m_asyncIOThreads.get(), 1, 1024);
@ -3357,6 +3377,20 @@ void Session::setDiskCacheTTL(const int ttl) @@ -3357,6 +3377,20 @@ void Session::setDiskCacheTTL(const int ttl)
}
}
qint64 Session::diskQueueSize() const
{
return m_diskQueueSize;
}
void Session::setDiskQueueSize(const qint64 size)
{
if (size == m_diskQueueSize)
return;
m_diskQueueSize = size;
configureDeferred();
}
bool Session::useOSCache() const
{
return m_useOSCache;

12
src/base/bittorrent/session.h

@ -343,11 +343,13 @@ namespace BitTorrent @@ -343,11 +343,13 @@ namespace BitTorrent
bool announceToAllTiers() const;
void setAnnounceToAllTiers(bool val);
int peerTurnover() const;
void setPeerTurnover(int num);
void setPeerTurnover(int val);
int peerTurnoverCutoff() const;
void setPeerTurnoverCutoff(int num);
void setPeerTurnoverCutoff(int val);
int peerTurnoverInterval() const;
void setPeerTurnoverInterval(int num);
void setPeerTurnoverInterval(int val);
int requestQueueSize() const;
void setRequestQueueSize(int val);
int asyncIOThreads() const;
void setAsyncIOThreads(int num);
int hashingThreads() const;
@ -360,6 +362,8 @@ namespace BitTorrent @@ -360,6 +362,8 @@ namespace BitTorrent
void setDiskCacheSize(int size);
int diskCacheTTL() const;
void setDiskCacheTTL(int ttl);
qint64 diskQueueSize() const;
void setDiskQueueSize(qint64 size);
bool useOSCache() const;
void setUseOSCache(bool use);
bool isCoalesceReadWriteEnabled() const;
@ -679,6 +683,7 @@ namespace BitTorrent @@ -679,6 +683,7 @@ namespace BitTorrent
CachedSettingValue<int> m_checkingMemUsage;
CachedSettingValue<int> m_diskCacheSize;
CachedSettingValue<int> m_diskCacheTTL;
CachedSettingValue<qint64> m_diskQueueSize;
CachedSettingValue<bool> m_useOSCache;
CachedSettingValue<bool> m_coalesceReadWriteEnabled;
CachedSettingValue<bool> m_usePieceExtentAffinity;
@ -760,6 +765,7 @@ namespace BitTorrent @@ -760,6 +765,7 @@ namespace BitTorrent
CachedSettingValue<int> m_peerTurnover;
CachedSettingValue<int> m_peerTurnoverCutoff;
CachedSettingValue<int> m_peerTurnoverInterval;
CachedSettingValue<int> m_requestQueueSize;
CachedSettingValue<QStringList> m_bannedIPs;
CachedSettingValue<ResumeDataStorageType> m_resumeDataStorageType;
#if defined(Q_OS_WIN)

19
src/gui/advancedsettings.cpp

@ -106,6 +106,7 @@ namespace @@ -106,6 +106,7 @@ namespace
DISK_CACHE,
DISK_CACHE_TTL,
#endif
DISK_QUEUE_SIZE,
OS_CACHE,
#ifndef QBT_USES_LIBTORRENT2
COALESCE_RW,
@ -140,6 +141,7 @@ namespace @@ -140,6 +141,7 @@ namespace
PEER_TURNOVER,
PEER_TURNOVER_CUTOFF,
PEER_TURNOVER_INTERVAL,
REQUEST_QUEUE_SIZE,
ROW_COUNT
};
@ -212,6 +214,8 @@ void AdvancedSettings::saveAdvancedSettings() @@ -212,6 +214,8 @@ void AdvancedSettings::saveAdvancedSettings()
session->setDiskCacheSize(m_spinBoxCache.value());
session->setDiskCacheTTL(m_spinBoxCacheTTL.value());
#endif
// Disk queue size
session->setDiskQueueSize(m_spinBoxDiskQueueSize.value() * 1024);
// Enable OS cache
session->setUseOSCache(m_checkBoxOsCache.isChecked());
#ifndef QBT_USES_LIBTORRENT2
@ -319,6 +323,8 @@ void AdvancedSettings::saveAdvancedSettings() @@ -319,6 +323,8 @@ void AdvancedSettings::saveAdvancedSettings()
session->setPeerTurnover(m_spinBoxPeerTurnover.value());
session->setPeerTurnoverCutoff(m_spinBoxPeerTurnoverCutoff.value());
session->setPeerTurnoverInterval(m_spinBoxPeerTurnoverInterval.value());
// Maximum outstanding requests to a single peer
session->setRequestQueueSize(m_spinBoxRequestQueueSize.value());
}
#ifndef QBT_USES_LIBTORRENT2
@ -498,6 +504,13 @@ void AdvancedSettings::loadAdvancedSettings() @@ -498,6 +504,13 @@ void AdvancedSettings::loadAdvancedSettings()
addRow(DISK_CACHE_TTL, (tr("Disk cache expiry interval") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#cache_expiry", "(?)"))
, &m_spinBoxCacheTTL);
#endif
// Disk queue size
m_spinBoxDiskQueueSize.setMinimum(1);
m_spinBoxDiskQueueSize.setMaximum(std::numeric_limits<int>::max());
m_spinBoxDiskQueueSize.setValue(session->diskQueueSize() / 1024);
m_spinBoxDiskQueueSize.setSuffix(tr(" KiB"));
addRow(DISK_QUEUE_SIZE, (tr("Disk queue size") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#max_queued_disk_bytes", "(?)"))
, &m_spinBoxDiskQueueSize);
// Enable OS cache
m_checkBoxOsCache.setChecked(session->useOSCache());
addRow(OS_CACHE, (tr("Enable OS cache") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#disk_io_write_mode", "(?)"))
@ -759,6 +772,12 @@ void AdvancedSettings::loadAdvancedSettings() @@ -759,6 +772,12 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxPeerTurnoverInterval.setValue(session->peerTurnoverInterval());
addRow(PEER_TURNOVER_INTERVAL, (tr("Peer turnover disconnect interval") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#peer_turnover", "(?)"))
, &m_spinBoxPeerTurnoverInterval);
// Maximum outstanding requests to a single peer
m_spinBoxRequestQueueSize.setMinimum(1);
m_spinBoxRequestQueueSize.setMaximum(std::numeric_limits<int>::max());
m_spinBoxRequestQueueSize.setValue(session->requestQueueSize());
addRow(REQUEST_QUEUE_SIZE, (tr("Maximum outstanding requests to a single peer") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#max_out_request_queue", "(?)"))
, &m_spinBoxRequestQueueSize);
}
template <typename T>

4
src/gui/advancedsettings.h

@ -58,11 +58,11 @@ private: @@ -58,11 +58,11 @@ private:
void loadAdvancedSettings();
template <typename T> void addRow(int row, const QString &text, T *widget);
QSpinBox m_spinBoxAsyncIOThreads, m_spinBoxFilePoolSize, m_spinBoxCheckingMemUsage,
QSpinBox m_spinBoxAsyncIOThreads, m_spinBoxFilePoolSize, m_spinBoxCheckingMemUsage, m_spinBoxDiskQueueSize,
m_spinBoxSaveResumeDataInterval, m_spinBoxOutgoingPortsMin, m_spinBoxOutgoingPortsMax, m_spinBoxUPnPLeaseDuration, m_spinBoxPeerToS,
m_spinBoxListRefresh, m_spinBoxTrackerPort, m_spinBoxSendBufferWatermark, m_spinBoxSendBufferLowWatermark,
m_spinBoxSendBufferWatermarkFactor, m_spinBoxConnectionSpeed, m_spinBoxSocketBacklogSize, m_spinBoxMaxConcurrentHTTPAnnounces, m_spinBoxStopTrackerTimeout,
m_spinBoxSavePathHistoryLength, m_spinBoxPeerTurnover, m_spinBoxPeerTurnoverCutoff, m_spinBoxPeerTurnoverInterval;
m_spinBoxSavePathHistoryLength, m_spinBoxPeerTurnover, m_spinBoxPeerTurnoverCutoff, m_spinBoxPeerTurnoverInterval, m_spinBoxRequestQueueSize;
QCheckBox m_checkBoxOsCache, m_checkBoxRecheckCompleted, m_checkBoxResolveCountries, m_checkBoxResolveHosts,
m_checkBoxProgramNotifications, m_checkBoxTorrentAddedNotifications, m_checkBoxReannounceWhenAddressChanged, m_checkBoxTrackerFavicon, m_checkBoxTrackerStatus,
m_checkBoxConfirmTorrentRecheck, m_checkBoxConfirmRemoveAllTags, m_checkBoxAnnounceAllTrackers, m_checkBoxAnnounceAllTiers,

10
src/webui/api/appcontroller.cpp

@ -306,6 +306,8 @@ void AppController::preferencesAction() @@ -306,6 +306,8 @@ void AppController::preferencesAction()
// Disk write cache
data["disk_cache"] = session->diskCacheSize();
data["disk_cache_ttl"] = session->diskCacheTTL();
// Disk queue size
data["disk_queue_size"] = session->diskQueueSize();
// Enable OS cache
data["enable_os_cache"] = session->useOSCache();
// Coalesce reads & writes
@ -358,6 +360,8 @@ void AppController::preferencesAction() @@ -358,6 +360,8 @@ void AppController::preferencesAction()
data["peer_turnover"] = session->peerTurnover();
data["peer_turnover_cutoff"] = session->peerTurnoverCutoff();
data["peer_turnover_interval"] = session->peerTurnoverInterval();
// Maximum outstanding requests to a single peer
data["request_queue_size"] = session->requestQueueSize();
setResult(data);
}
@ -777,6 +781,9 @@ void AppController::setPreferencesAction() @@ -777,6 +781,9 @@ void AppController::setPreferencesAction()
session->setDiskCacheSize(it.value().toInt());
if (hasKey("disk_cache_ttl"))
session->setDiskCacheTTL(it.value().toInt());
// Disk queue size
if (hasKey("disk_queue_size"))
session->setDiskQueueSize(it.value().toLongLong());
// Enable OS cache
if (hasKey("enable_os_cache"))
session->setUseOSCache(it.value().toBool());
@ -863,6 +870,9 @@ void AppController::setPreferencesAction() @@ -863,6 +870,9 @@ void AppController::setPreferencesAction()
session->setPeerTurnoverCutoff(it.value().toInt());
if (hasKey("peer_turnover_interval"))
session->setPeerTurnoverInterval(it.value().toInt());
// Maximum outstanding requests to a single peer
if (hasKey("request_queue_size"))
session->setRequestQueueSize(it.value().toInt());
// Save preferences
pref->apply();

2
src/webui/webapplication.h

@ -44,7 +44,7 @@ @@ -44,7 +44,7 @@
#include "base/utils/net.h"
#include "base/utils/version.h"
inline const Utils::Version<int, 3, 2> API_VERSION {2, 8, 6};
inline const Utils::Version<int, 3, 2> API_VERSION {2, 8, 7};
class APIController;
class WebApplication;

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

@ -1012,6 +1012,14 @@ @@ -1012,6 +1012,14 @@
<input type="text" id="diskCacheExpiryInterval" style="width: 15em;">&nbsp;&nbsp;QBT_TR(s)QBT_TR[CONTEXT=OptionsDialog]
</td>
</tr>
<tr>
<td>
<label for="diskQueueSize">QBT_TR(Disk queue size:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#max_queued_disk_bytes" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="diskQueueSize" style="width: 15em;">&nbsp;&nbsp;QBT_TR(KiB)QBT_TR[CONTEXT=OptionsDialog]
</td>
</tr>
<tr>
<td>
<label for="enableOSCache">QBT_TR(Enable OS cache:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#disk_io_write_mode" target="_blank">(?)</a></label>
@ -1254,6 +1262,14 @@ @@ -1254,6 +1262,14 @@
<input type="text" id="peerTurnoverInterval" style="width: 15em;" />&nbsp;&nbsp;s
</td>
</tr>
<tr>
<td>
<label for="requestQueueSize">QBT_TR(Maximum outstanding requests to a single peer:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#max_out_request_queue" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="requestQueueSize" style="width: 15em;" />
</td>
</tr>
</table>
</fieldset>
</div>
@ -1931,6 +1947,7 @@ @@ -1931,6 +1947,7 @@
$('outstandMemoryWhenCheckingTorrents').setProperty('value', pref.checking_memory_use);
$('diskCache').setProperty('value', pref.disk_cache);
$('diskCacheExpiryInterval').setProperty('value', pref.disk_cache_ttl);
$('diskQueueSize').setProperty('value', (pref.disk_queue_size / 1024));
$('enableOSCache').setProperty('checked', pref.enable_os_cache);
$('coalesceReadsAndWrites').setProperty('checked', pref.enable_coalesce_read_write);
$('pieceExtentAffinity').setProperty('checked', pref.enable_piece_extent_affinity);
@ -1962,6 +1979,7 @@ @@ -1962,6 +1979,7 @@
$('peerTurnover').setProperty('value', pref.peer_turnover);
$('peerTurnoverCutoff').setProperty('value', pref.peer_turnover_cutoff);
$('peerTurnoverInterval').setProperty('value', pref.peer_turnover_interval);
$('requestQueueSize').setProperty('value', pref.request_queue_size);
}
}
}).send();
@ -2326,6 +2344,7 @@ @@ -2326,6 +2344,7 @@
settings.set('checking_memory_use', $('outstandMemoryWhenCheckingTorrents').getProperty('value'));
settings.set('disk_cache', $('diskCache').getProperty('value'));
settings.set('disk_cache_ttl', $('diskCacheExpiryInterval').getProperty('value'));
settings.set('disk_queue_size', ($('diskQueueSize').getProperty('value') * 1024));
settings.set('enable_os_cache', $('enableOSCache').getProperty('checked'));
settings.set('enable_coalesce_read_write', $('coalesceReadsAndWrites').getProperty('checked'));
settings.set('enable_piece_extent_affinity', $('pieceExtentAffinity').getProperty('checked'));
@ -2357,6 +2376,7 @@ @@ -2357,6 +2376,7 @@
settings.set('peer_turnover', $('peerTurnover').getProperty('value'));
settings.set('peer_turnover_cutoff', $('peerTurnoverCutoff').getProperty('value'));
settings.set('peer_turnover_interval', $('peerTurnoverInterval').getProperty('value'));
settings.set('request_queue_size', $('requestQueueSize').getProperty('value'));
// Send it to qBT
const json_str = JSON.encode(settings);

Loading…
Cancel
Save