Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add piece_extent_affinity to AdvancedSettings #11781

Merged
merged 1 commit into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/base/bittorrent/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ Session::Session(QObject *parent)
#else
, m_coalesceReadWriteEnabled(BITTORRENT_SESSION_KEY("CoalesceReadWrite"), false)
#endif
, m_usePieceExtentAffinity(BITTORRENT_SESSION_KEY("PieceExtentAffinity"), false)
, m_isSuggestMode(BITTORRENT_SESSION_KEY("SuggestMode"), false)
, m_sendBufferWatermark(BITTORRENT_SESSION_KEY("SendBufferWatermark"), 500)
, m_sendBufferLowWatermark(BITTORRENT_SESSION_KEY("SendBufferLowWatermark"), 10)
Expand Down Expand Up @@ -1323,6 +1324,10 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack)
settingsPack.set_bool(lt::settings_pack::coalesce_reads, 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()
? lt::settings_pack::suggest_read_cache : lt::settings_pack::no_piece_suggestions);

Expand Down Expand Up @@ -3248,6 +3253,19 @@ bool Session::isSuggestModeEnabled() const
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)
{
if (mode == m_isSuggestMode) return;
Expand Down
3 changes: 3 additions & 0 deletions src/base/bittorrent/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ namespace BitTorrent
void setUseOSCache(bool use);
bool isCoalesceReadWriteEnabled() const;
void setCoalesceReadWriteEnabled(bool enabled);
bool usePieceExtentAffinity() const;
void setPieceExtentAffinity(bool enabled);
bool isSuggestModeEnabled() const;
void setSuggestMode(bool mode);
int sendBufferWatermark() const;
Expand Down Expand Up @@ -610,6 +612,7 @@ namespace BitTorrent
CachedSettingValue<int> m_diskCacheTTL;
CachedSettingValue<bool> m_useOSCache;
CachedSettingValue<bool> m_coalesceReadWriteEnabled;
CachedSettingValue<bool> m_usePieceExtentAffinity;
CachedSettingValue<bool> m_isSuggestMode;
CachedSettingValue<int> m_sendBufferWatermark;
CachedSettingValue<int> m_sendBufferLowWatermark;
Expand Down
12 changes: 12 additions & 0 deletions src/gui/advancedsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ enum AdvSettingsRows
DISK_CACHE_TTL,
OS_CACHE,
COALESCE_RW,
#if (LIBTORRENT_VERSION_NUM >= 10202)
PIECE_EXTENT_AFFINITY,
FranciscoPombal marked this conversation as resolved.
Show resolved Hide resolved
#endif
SUGGEST_MODE,
SEND_BUF_WATERMARK,
SEND_BUF_LOW_WATERMARK,
Expand Down Expand Up @@ -188,6 +191,10 @@ void AdvancedSettings::saveAdvancedSettings()
session->setUseOSCache(m_checkBoxOsCache.isChecked());
// Coalesce reads & writes
session->setCoalesceReadWriteEnabled(m_checkBoxCoalesceRW.isChecked());
#if (LIBTORRENT_VERSION_NUM >= 10202)
// Piece extent affinity
session->setPieceExtentAffinity(m_checkBoxPieceExtentAffinity.isChecked());
#endif
// Suggest mode
session->setSuggestMode(m_checkBoxSuggestMode.isChecked());
// Send buffer watermark
Expand Down Expand Up @@ -426,6 +433,11 @@ void AdvancedSettings::loadAdvancedSettings()
m_checkBoxCoalesceRW.setChecked(session->isCoalesceReadWriteEnabled());
addRow(COALESCE_RW, (tr("Coalesce reads & writes") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#coalesce_reads", "(?)"))
, &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
m_checkBoxSuggestMode.setChecked(session->isSuggestModeEnabled());
addRow(SUGGEST_MODE, (tr("Send upload piece suggestions") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#suggest_mode", "(?)"))
Expand Down
2 changes: 1 addition & 1 deletion src/gui/advancedsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private slots:
QCheckBox m_checkBoxOsCache, m_checkBoxRecheckCompleted, m_checkBoxResolveCountries, m_checkBoxResolveHosts, m_checkBoxSuperSeeding,
m_checkBoxProgramNotifications, m_checkBoxTorrentAddedNotifications, m_checkBoxTrackerFavicon, m_checkBoxTrackerStatus,
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;
QLineEdit m_lineEditAnnounceIP;

Expand Down
5 changes: 5 additions & 0 deletions src/webui/api/appcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ void AppController::preferencesAction()
data["enable_os_cache"] = session->useOSCache();
// Coalesce reads & writes
data["enable_coalesce_read_write"] = session->isCoalesceReadWriteEnabled();
// Piece Extent Affinity
data["enable_piece_extent_affinity"] = session->usePieceExtentAffinity();
FranciscoPombal marked this conversation as resolved.
Show resolved Hide resolved
// Suggest mode
data["enable_upload_suggestions"] = session->isSuggestModeEnabled();
// Send buffer watermark
Expand Down Expand Up @@ -686,6 +688,9 @@ void AppController::setPreferencesAction()
// Coalesce reads & writes
if (hasKey("enable_coalesce_read_write"))
session->setCoalesceReadWriteEnabled(it.value().toBool());
// Piece extent affinity
if (hasKey("enable_piece_extent_affinity"))
session->setPieceExtentAffinity(it.value().toBool());
// Suggest mode
if (hasKey("enable_upload_suggestions"))
session->setSuggestMode(it.value().toBool());
Expand Down
10 changes: 10 additions & 0 deletions src/webui/www/private/views/preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,14 @@
<input type="checkbox" id="coalesceReadsAndWrites" />
</td>
</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>
<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>
Expand Down Expand Up @@ -1741,6 +1749,7 @@
$('diskCacheExpiryInterval').setProperty('value', pref.disk_cache_ttl);
$('enableOSCache').setProperty('checked', pref.enable_os_cache);
$('coalesceReadsAndWrites').setProperty('checked', pref.enable_coalesce_read_write);
$('pieceExtentAffinity').setProperty('checked', pref.enable_piece_extent_affinity);
$('sendUploadPieceSuggestions').setProperty('checked', pref.enable_upload_suggestions);
$('sendBufferWatermark').setProperty('value', pref.send_buffer_watermark);
$('sendBufferLowWatermark').setProperty('value', pref.send_buffer_low_watermark);
Expand Down Expand Up @@ -2105,6 +2114,7 @@
settings.set('disk_cache_ttl', $('diskCacheExpiryInterval').getProperty('value'));
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'));
settings.set('enable_upload_suggestions', $('sendUploadPieceSuggestions').getProperty('checked'));
settings.set('send_buffer_watermark', $('sendBufferWatermark').getProperty('value'));
settings.set('send_buffer_low_watermark', $('sendBufferLowWatermark').getProperty('value'));
Expand Down