Allow disabling of OS cache. This will prevent RAM increases on Windows when seeding many files. Closes #1699.

Conflicts:
	src/preferences/advancedsettings.h
	src/preferences/preferences.cpp
	src/preferences/preferences.h
	src/qtlibtorrent/qbtsession.cpp
This commit is contained in:
sledgehammer999 2014-08-07 22:30:54 +03:00
parent dac8e20aad
commit 60d7e3ef30
3 changed files with 18 additions and 2 deletions

View file

@ -17,7 +17,7 @@ enum AdvSettingsRows {DISK_CACHE,
#if LIBTORRENT_VERSION_NUM >= 1610 #if LIBTORRENT_VERSION_NUM >= 1610
DISK_CACHE_TTL, DISK_CACHE_TTL,
#endif #endif
OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN, SUPER_SEEDING, NETWORK_IFACE, NETWORK_ADDRESS, PROGRAM_NOTIFICATIONS, TRACKER_STATUS, TRACKER_PORT, OS_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN, SUPER_SEEDING, NETWORK_IFACE, NETWORK_ADDRESS, PROGRAM_NOTIFICATIONS, TRACKER_STATUS, TRACKER_PORT,
#if defined(Q_WS_WIN) || defined(Q_WS_MAC) #if defined(Q_WS_WIN) || defined(Q_WS_MAC)
UPDATE_CHECK, UPDATE_CHECK,
#endif #endif
@ -33,7 +33,7 @@ class AdvancedSettings: public QTableWidget {
private: private:
QSpinBox spin_cache, outgoing_ports_min, outgoing_ports_max, spin_list_refresh, spin_maxhalfopen, spin_tracker_port; QSpinBox spin_cache, outgoing_ports_min, outgoing_ports_max, spin_list_refresh, spin_maxhalfopen, spin_tracker_port;
QCheckBox cb_ignore_limits_lan, cb_recheck_completed, cb_resolve_countries, cb_resolve_hosts, QCheckBox cb_os_cache, cb_ignore_limits_lan, cb_recheck_completed, cb_resolve_countries, cb_resolve_hosts,
cb_super_seeding, cb_program_notifications, cb_tracker_status, cb_confirm_torrent_deletion, cb_super_seeding, cb_program_notifications, cb_tracker_status, cb_confirm_torrent_deletion,
cb_enable_tracker_ext; cb_enable_tracker_ext;
QComboBox combo_iface; QComboBox combo_iface;
@ -79,6 +79,8 @@ public slots:
#if LIBTORRENT_VERSION_NUM >= 1610 #if LIBTORRENT_VERSION_NUM >= 1610
pref.setDiskCacheTTL(spin_cache_ttl.value()); pref.setDiskCacheTTL(spin_cache_ttl.value());
#endif #endif
// Enable OS cache
pref.setOsCache(cb_os_cache.isChecked());
// Outgoing ports // Outgoing ports
pref.setOutgoingPortsMin(outgoing_ports_min.value()); pref.setOutgoingPortsMin(outgoing_ports_min.value());
pref.setOutgoingPortsMax(outgoing_ports_max.value()); pref.setOutgoingPortsMax(outgoing_ports_max.value());
@ -198,6 +200,9 @@ private slots:
spin_cache_ttl.setSuffix(tr(" s", " seconds")); spin_cache_ttl.setSuffix(tr(" s", " seconds"));
setRow(DISK_CACHE_TTL, tr("Disk cache expiry interval"), &spin_cache_ttl); setRow(DISK_CACHE_TTL, tr("Disk cache expiry interval"), &spin_cache_ttl);
#endif #endif
// Enable OS cache
cb_os_cache.setChecked(pref.osCache());
setRow(OS_CACHE, tr("Enable OS cache"), &cb_os_cache);
// Outgoing port Min // Outgoing port Min
outgoing_ports_min.setMinimum(0); outgoing_ports_min.setMinimum(0);
outgoing_ports_min.setMaximum(65535); outgoing_ports_min.setMaximum(65535);

View file

@ -1031,6 +1031,14 @@ public:
} }
#endif #endif
bool osCache() const {
return value("Preferences/Advanced/osCache", true).toBool();
}
void setOsCache(bool enable) {
setValue("Preferences/Advanced/osCache", enable);
}
uint outgoingPortsMin() const { uint outgoingPortsMin() const {
return value(QString::fromUtf8("Preferences/Advanced/OutgoingPortsMin"), 0).toUInt(); return value(QString::fromUtf8("Preferences/Advanced/OutgoingPortsMin"), 0).toUInt();
} }

View file

@ -419,6 +419,9 @@ void QBtSession::configureSession() {
sessionSettings.cache_expiry = pref.diskCacheTTL(); sessionSettings.cache_expiry = pref.diskCacheTTL();
#endif #endif
qDebug() << "Using a disk cache size of" << cache_size << "MiB"; qDebug() << "Using a disk cache size of" << cache_size << "MiB";
session_settings::io_buffer_mode_t mode = pref.osCache() ? session_settings::enable_os_cache : session_settings::disable_os_cache;
sessionSettings.disk_io_read_mode = mode;
sessionSettings.disk_io_write_mode = mode;
#if LIBTORRENT_VERSION_NUM >= 1600 #if LIBTORRENT_VERSION_NUM >= 1600
sessionSettings.anonymous_mode = pref.isAnonymousModeEnabled(); sessionSettings.anonymous_mode = pref.isAnonymousModeEnabled();
if (sessionSettings.anonymous_mode) { if (sessionSettings.anonymous_mode) {