diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index c047f232a..77b9175cc 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -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) @@ -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); @@ -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; diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index 4591f4477..ee1837183 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -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; @@ -610,6 +612,7 @@ namespace BitTorrent CachedSettingValue m_diskCacheTTL; CachedSettingValue m_useOSCache; CachedSettingValue m_coalesceReadWriteEnabled; + CachedSettingValue m_usePieceExtentAffinity; CachedSettingValue m_isSuggestMode; CachedSettingValue m_sendBufferWatermark; CachedSettingValue m_sendBufferLowWatermark; diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index 80899a154..f211766b2 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -96,6 +96,9 @@ enum AdvSettingsRows DISK_CACHE_TTL, OS_CACHE, COALESCE_RW, +#if (LIBTORRENT_VERSION_NUM >= 10202) + PIECE_EXTENT_AFFINITY, +#endif SUGGEST_MODE, SEND_BUF_WATERMARK, SEND_BUF_LOW_WATERMARK, @@ -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 @@ -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", "(?)")) diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index 1122b58b9..ab19ba062 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -64,7 +64,7 @@ private: 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; diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index a8352a17b..7cafe6e28 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -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(); // Suggest mode data["enable_upload_suggestions"] = session->isSuggestModeEnabled(); // Send buffer watermark @@ -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()); diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index 3e8270b89..17f9a6c79 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -926,6 +926,14 @@ + + + + + + + + @@ -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); @@ -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'));