Browse Source

Merge pull request #11781 from FranciscoPombal/piece_extent_affinity

Add piece_extent_affinity to AdvancedSettings
adaptive-webui-19844
Mike Tzou 5 years ago committed by GitHub
parent
commit
146e8213a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      src/base/bittorrent/session.cpp
  2. 3
      src/base/bittorrent/session.h
  3. 12
      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

18
src/base/bittorrent/session.cpp

@ -383,6 +383,7 @@ Session::Session(QObject *parent)
#else #else
, m_coalesceReadWriteEnabled(BITTORRENT_SESSION_KEY("CoalesceReadWrite"), false) , m_coalesceReadWriteEnabled(BITTORRENT_SESSION_KEY("CoalesceReadWrite"), false)
#endif #endif
, m_usePieceExtentAffinity(BITTORRENT_SESSION_KEY("PieceExtentAffinity"), false)
, m_isSuggestMode(BITTORRENT_SESSION_KEY("SuggestMode"), false) , m_isSuggestMode(BITTORRENT_SESSION_KEY("SuggestMode"), false)
, m_sendBufferWatermark(BITTORRENT_SESSION_KEY("SendBufferWatermark"), 500) , m_sendBufferWatermark(BITTORRENT_SESSION_KEY("SendBufferWatermark"), 500)
, m_sendBufferLowWatermark(BITTORRENT_SESSION_KEY("SendBufferLowWatermark"), 10) , m_sendBufferLowWatermark(BITTORRENT_SESSION_KEY("SendBufferLowWatermark"), 10)
@ -1322,6 +1323,10 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack)
settingsPack.set_bool(lt::settings_pack::coalesce_reads, isCoalesceReadWriteEnabled()); settingsPack.set_bool(lt::settings_pack::coalesce_reads, isCoalesceReadWriteEnabled());
settingsPack.set_bool(lt::settings_pack::coalesce_writes, isCoalesceReadWriteEnabled()); settingsPack.set_bool(lt::settings_pack::coalesce_writes, isCoalesceReadWriteEnabled());
#if (LIBTORRENT_VERSION_NUM >= 10202)
settingsPack.set_bool(lt::settings_pack::piece_extent_affinity, usePieceExtentAffinity());
#endif
settingsPack.set_int(lt::settings_pack::suggest_mode, isSuggestModeEnabled() settingsPack.set_int(lt::settings_pack::suggest_mode, isSuggestModeEnabled()
? lt::settings_pack::suggest_read_cache : lt::settings_pack::no_piece_suggestions); ? lt::settings_pack::suggest_read_cache : lt::settings_pack::no_piece_suggestions);
@ -3249,6 +3254,19 @@ bool Session::isSuggestModeEnabled() const
return m_isSuggestMode; return m_isSuggestMode;
} }
bool Session::usePieceExtentAffinity() const
{
return m_usePieceExtentAffinity;
}
void Session::setPieceExtentAffinity(const bool enabled)
{
if (enabled == m_usePieceExtentAffinity) return;
m_usePieceExtentAffinity = enabled;
configureDeferred();
}
void Session::setSuggestMode(const bool mode) void Session::setSuggestMode(const bool mode)
{ {
if (mode == m_isSuggestMode) return; if (mode == m_isSuggestMode) return;

3
src/base/bittorrent/session.h

@ -337,6 +337,8 @@ namespace BitTorrent
void setUseOSCache(bool use); void setUseOSCache(bool use);
bool isCoalesceReadWriteEnabled() const; bool isCoalesceReadWriteEnabled() const;
void setCoalesceReadWriteEnabled(bool enabled); void setCoalesceReadWriteEnabled(bool enabled);
bool usePieceExtentAffinity() const;
void setPieceExtentAffinity(bool enabled);
bool isSuggestModeEnabled() const; bool isSuggestModeEnabled() const;
void setSuggestMode(bool mode); void setSuggestMode(bool mode);
int sendBufferWatermark() const; int sendBufferWatermark() const;
@ -612,6 +614,7 @@ namespace BitTorrent
CachedSettingValue<int> m_diskCacheTTL; CachedSettingValue<int> m_diskCacheTTL;
CachedSettingValue<bool> m_useOSCache; CachedSettingValue<bool> m_useOSCache;
CachedSettingValue<bool> m_coalesceReadWriteEnabled; CachedSettingValue<bool> m_coalesceReadWriteEnabled;
CachedSettingValue<bool> m_usePieceExtentAffinity;
CachedSettingValue<bool> m_isSuggestMode; CachedSettingValue<bool> m_isSuggestMode;
CachedSettingValue<int> m_sendBufferWatermark; CachedSettingValue<int> m_sendBufferWatermark;
CachedSettingValue<int> m_sendBufferLowWatermark; CachedSettingValue<int> m_sendBufferLowWatermark;

12
src/gui/advancedsettings.cpp

@ -96,6 +96,9 @@ enum AdvSettingsRows
DISK_CACHE_TTL, DISK_CACHE_TTL,
OS_CACHE, OS_CACHE,
COALESCE_RW, COALESCE_RW,
#if (LIBTORRENT_VERSION_NUM >= 10202)
PIECE_EXTENT_AFFINITY,
#endif
SUGGEST_MODE, SUGGEST_MODE,
SEND_BUF_WATERMARK, SEND_BUF_WATERMARK,
SEND_BUF_LOW_WATERMARK, SEND_BUF_LOW_WATERMARK,
@ -189,6 +192,10 @@ void AdvancedSettings::saveAdvancedSettings()
session->setUseOSCache(m_checkBoxOsCache.isChecked()); session->setUseOSCache(m_checkBoxOsCache.isChecked());
// Coalesce reads & writes // Coalesce reads & writes
session->setCoalesceReadWriteEnabled(m_checkBoxCoalesceRW.isChecked()); session->setCoalesceReadWriteEnabled(m_checkBoxCoalesceRW.isChecked());
#if (LIBTORRENT_VERSION_NUM >= 10202)
// Piece extent affinity
session->setPieceExtentAffinity(m_checkBoxPieceExtentAffinity.isChecked());
#endif
// Suggest mode // Suggest mode
session->setSuggestMode(m_checkBoxSuggestMode.isChecked()); session->setSuggestMode(m_checkBoxSuggestMode.isChecked());
// Send buffer watermark // Send buffer watermark
@ -427,6 +434,11 @@ void AdvancedSettings::loadAdvancedSettings()
m_checkBoxCoalesceRW.setChecked(session->isCoalesceReadWriteEnabled()); m_checkBoxCoalesceRW.setChecked(session->isCoalesceReadWriteEnabled());
addRow(COALESCE_RW, (tr("Coalesce reads & writes") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#coalesce_reads", "(?)")) addRow(COALESCE_RW, (tr("Coalesce reads & writes") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#coalesce_reads", "(?)"))
, &m_checkBoxCoalesceRW); , &m_checkBoxCoalesceRW);
#if (LIBTORRENT_VERSION_NUM >= 10202)
// Piece extent affinity
m_checkBoxPieceExtentAffinity.setChecked(session->usePieceExtentAffinity());
addRow(PIECE_EXTENT_AFFINITY, (tr("Use piece extent affinity") + ' ' + makeLink("https://libtorrent.org/single-page-ref.html#piece_extent_affinity", "(?)")), &m_checkBoxPieceExtentAffinity);
#endif
// Suggest mode // Suggest mode
m_checkBoxSuggestMode.setChecked(session->isSuggestModeEnabled()); m_checkBoxSuggestMode.setChecked(session->isSuggestModeEnabled());
addRow(SUGGEST_MODE, (tr("Send upload piece suggestions") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#suggest_mode", "(?)")) addRow(SUGGEST_MODE, (tr("Send upload piece suggestions") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#suggest_mode", "(?)"))

2
src/gui/advancedsettings.h

@ -64,7 +64,7 @@ private:
QCheckBox m_checkBoxOsCache, m_checkBoxRecheckCompleted, m_checkBoxResolveCountries, m_checkBoxResolveHosts, m_checkBoxSuperSeeding, QCheckBox m_checkBoxOsCache, m_checkBoxRecheckCompleted, m_checkBoxResolveCountries, m_checkBoxResolveHosts, m_checkBoxSuperSeeding,
m_checkBoxProgramNotifications, m_checkBoxTorrentAddedNotifications, m_checkBoxTrackerFavicon, m_checkBoxTrackerStatus, m_checkBoxProgramNotifications, m_checkBoxTorrentAddedNotifications, m_checkBoxTrackerFavicon, m_checkBoxTrackerStatus,
m_checkBoxConfirmTorrentRecheck, m_checkBoxConfirmRemoveAllTags, m_checkBoxAnnounceAllTrackers, m_checkBoxAnnounceAllTiers, m_checkBoxConfirmTorrentRecheck, m_checkBoxConfirmRemoveAllTags, m_checkBoxAnnounceAllTrackers, m_checkBoxAnnounceAllTiers,
m_checkBoxMultiConnectionsPerIp, m_checkBoxSuggestMode, m_checkBoxCoalesceRW, m_checkBoxSpeedWidgetEnabled; m_checkBoxMultiConnectionsPerIp, m_checkBoxPieceExtentAffinity, m_checkBoxSuggestMode, m_checkBoxCoalesceRW, m_checkBoxSpeedWidgetEnabled;
QComboBox m_comboBoxInterface, m_comboBoxInterfaceAddress, m_comboBoxUtpMixedMode, m_comboBoxChokingAlgorithm, m_comboBoxSeedChokingAlgorithm; QComboBox m_comboBoxInterface, m_comboBoxInterfaceAddress, m_comboBoxUtpMixedMode, m_comboBoxChokingAlgorithm, m_comboBoxSeedChokingAlgorithm;
QLineEdit m_lineEditAnnounceIP; QLineEdit m_lineEditAnnounceIP;

5
src/webui/api/appcontroller.cpp

@ -281,6 +281,8 @@ void AppController::preferencesAction()
data["enable_os_cache"] = session->useOSCache(); data["enable_os_cache"] = session->useOSCache();
// Coalesce reads & writes // Coalesce reads & writes
data["enable_coalesce_read_write"] = session->isCoalesceReadWriteEnabled(); data["enable_coalesce_read_write"] = session->isCoalesceReadWriteEnabled();
// Piece Extent Affinity
data["enable_piece_extent_affinity"] = session->usePieceExtentAffinity();
// Suggest mode // Suggest mode
data["enable_upload_suggestions"] = session->isSuggestModeEnabled(); data["enable_upload_suggestions"] = session->isSuggestModeEnabled();
// Send buffer watermark // Send buffer watermark
@ -688,6 +690,9 @@ void AppController::setPreferencesAction()
// Coalesce reads & writes // Coalesce reads & writes
if (hasKey("enable_coalesce_read_write")) if (hasKey("enable_coalesce_read_write"))
session->setCoalesceReadWriteEnabled(it.value().toBool()); session->setCoalesceReadWriteEnabled(it.value().toBool());
// Piece extent affinity
if (hasKey("enable_piece_extent_affinity"))
session->setPieceExtentAffinity(it.value().toBool());
// Suggest mode // Suggest mode
if (hasKey("enable_upload_suggestions")) if (hasKey("enable_upload_suggestions"))
session->setSuggestMode(it.value().toBool()); session->setSuggestMode(it.value().toBool());

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

@ -926,6 +926,14 @@
<input type="checkbox" id="coalesceReadsAndWrites" /> <input type="checkbox" id="coalesceReadsAndWrites" />
</td> </td>
</tr> </tr>
<tr>
<td>
<label for="pieceExtentAffinity">QBT_TR(Use piece extent affinity (requires libtorrent >= 1.2.2):)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://libtorrent.org/single-page-ref.html#piece_extent_affinity" target="_blank">(?)</a></label>
</td>
<td>
<input type="checkbox" id="pieceExtentAffinity" />
</td>
</tr>
<tr> <tr>
<td> <td>
<label for="sendUploadPieceSuggestions">QBT_TR(Send upload piece suggestions:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#suggest_mode" target="_blank">(?)</a></label> <label for="sendUploadPieceSuggestions">QBT_TR(Send upload piece suggestions:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#suggest_mode" target="_blank">(?)</a></label>
@ -1748,6 +1756,7 @@
$('diskCacheExpiryInterval').setProperty('value', pref.disk_cache_ttl); $('diskCacheExpiryInterval').setProperty('value', pref.disk_cache_ttl);
$('enableOSCache').setProperty('checked', pref.enable_os_cache); $('enableOSCache').setProperty('checked', pref.enable_os_cache);
$('coalesceReadsAndWrites').setProperty('checked', pref.enable_coalesce_read_write); $('coalesceReadsAndWrites').setProperty('checked', pref.enable_coalesce_read_write);
$('pieceExtentAffinity').setProperty('checked', pref.enable_piece_extent_affinity);
$('sendUploadPieceSuggestions').setProperty('checked', pref.enable_upload_suggestions); $('sendUploadPieceSuggestions').setProperty('checked', pref.enable_upload_suggestions);
$('sendBufferWatermark').setProperty('value', pref.send_buffer_watermark); $('sendBufferWatermark').setProperty('value', pref.send_buffer_watermark);
$('sendBufferLowWatermark').setProperty('value', pref.send_buffer_low_watermark); $('sendBufferLowWatermark').setProperty('value', pref.send_buffer_low_watermark);
@ -2113,6 +2122,7 @@
settings.set('disk_cache_ttl', $('diskCacheExpiryInterval').getProperty('value')); settings.set('disk_cache_ttl', $('diskCacheExpiryInterval').getProperty('value'));
settings.set('enable_os_cache', $('enableOSCache').getProperty('checked')); settings.set('enable_os_cache', $('enableOSCache').getProperty('checked'));
settings.set('enable_coalesce_read_write', $('coalesceReadsAndWrites').getProperty('checked')); settings.set('enable_coalesce_read_write', $('coalesceReadsAndWrites').getProperty('checked'));
settings.set('enable_piece_extent_affinity', $('pieceExtentAffinity').getProperty('checked'));
settings.set('enable_upload_suggestions', $('sendUploadPieceSuggestions').getProperty('checked')); settings.set('enable_upload_suggestions', $('sendUploadPieceSuggestions').getProperty('checked'));
settings.set('send_buffer_watermark', $('sendBufferWatermark').getProperty('value')); settings.set('send_buffer_watermark', $('sendBufferWatermark').getProperty('value'));
settings.set('send_buffer_low_watermark', $('sendBufferLowWatermark').getProperty('value')); settings.set('send_buffer_low_watermark', $('sendBufferLowWatermark').getProperty('value'));

Loading…
Cancel
Save