(trunk libT) #3959 "by default, disable prefetch for lightweight builds" -- fixed.

User jusid reports prefetch causes load on his NMT to jump from <1 to 3-4. He requests a way to disable prefetch, and suggests that prefetch be disabled by default on lightweight builds.  This commit adds a new settings.json key, "prefetch-enabled", which defaults to "true" on standard builds and "false" when compiled with --enable-lightweight.
This commit is contained in:
Jordan Lee 2011-01-31 23:35:10 +00:00
parent b084493bfe
commit 2f5fc4ade7
4 changed files with 14 additions and 4 deletions

View File

@ -1196,6 +1196,9 @@ prefetchPieces( tr_peermsgs *msgs )
{
int i;
if( !getSession(msgs)->isPrefetchEnabled )
return;
/* Maintain 12 prefetched blocks per unchoked peer */
for( i=msgs->prefetchCount; i<msgs->peer->pendingReqsToClient && i<12; ++i )
{

View File

@ -53,13 +53,14 @@
enum
{
SAVE_INTERVAL_SECS = 360,
#ifdef TR_LIGHTWEIGHT
DEFAULT_CACHE_SIZE_MB = 2
DEFAULT_CACHE_SIZE_MB = 2,
DEFAULT_PREFETCH_ENABLED = FALSE,
#else
DEFAULT_CACHE_SIZE_MB = 4
DEFAULT_CACHE_SIZE_MB = 4,
DEFAULT_PREFETCH_ENABLED = TRUE,
#endif
SAVE_INTERVAL_SECS = 360
};
@ -334,6 +335,7 @@ tr_sessionGetDefaultSettings( const char * configDir UNUSED, tr_benc * d )
tr_bencDictAddBool( d, TR_PREFS_KEY_PEX_ENABLED, TRUE );
tr_bencDictAddBool( d, TR_PREFS_KEY_PORT_FORWARDING, TRUE );
tr_bencDictAddInt ( d, TR_PREFS_KEY_PREALLOCATION, TR_PREALLOCATE_SPARSE );
tr_bencDictAddBool( d, TR_PREFS_KEY_PREFETCH_ENABLED, DEFAULT_PREFETCH_ENABLED );
tr_bencDictAddReal( d, TR_PREFS_KEY_RATIO, 2.0 );
tr_bencDictAddBool( d, TR_PREFS_KEY_RATIO_ENABLED, FALSE );
tr_bencDictAddBool( d, TR_PREFS_KEY_RENAME_PARTIAL_FILES, TRUE );
@ -398,6 +400,7 @@ tr_sessionGetSettings( tr_session * s, struct tr_benc * d )
tr_bencDictAddBool( d, TR_PREFS_KEY_PEX_ENABLED, s->isPexEnabled );
tr_bencDictAddBool( d, TR_PREFS_KEY_PORT_FORWARDING, tr_sessionIsPortForwardingEnabled( s ) );
tr_bencDictAddInt ( d, TR_PREFS_KEY_PREALLOCATION, s->preallocationMode );
tr_bencDictAddInt ( d, TR_PREFS_KEY_PREFETCH_ENABLED, s->isPrefetchEnabled );
tr_bencDictAddReal( d, TR_PREFS_KEY_RATIO, s->desiredRatio );
tr_bencDictAddBool( d, TR_PREFS_KEY_RATIO_ENABLED, s->isRatioLimited );
tr_bencDictAddBool( d, TR_PREFS_KEY_RENAME_PARTIAL_FILES, tr_sessionIsIncompleteFileNamingEnabled( s ) );
@ -779,6 +782,8 @@ sessionSetImpl( void * vdata )
tr_sessionSetDeleteSource( session, boolVal );
/* files and directories */
if( tr_bencDictFindBool( settings, TR_PREFS_KEY_PREFETCH_ENABLED, &boolVal ) )
session->isPrefetchEnabled = boolVal;
if( tr_bencDictFindInt( settings, TR_PREFS_KEY_PREALLOCATION, &i ) )
session->preallocationMode = i;
if( tr_bencDictFindStr( settings, TR_PREFS_KEY_DOWNLOAD_DIR, &str ) )

View File

@ -91,6 +91,7 @@ struct tr_session
tr_bool isDHTEnabled;
tr_bool isLPDEnabled;
tr_bool isBlocklistEnabled;
tr_bool isPrefetchEnabled;
tr_bool isTorrentDoneScriptEnabled;
tr_bool isClosed;
tr_bool useLazyBitfield;

View File

@ -162,6 +162,7 @@ const char* tr_getDefaultDownloadDir( void );
#define TR_PREFS_KEY_MAX_CACHE_SIZE_MB "cache-size-mb"
#define TR_PREFS_KEY_DHT_ENABLED "dht-enabled"
#define TR_PREFS_KEY_LPD_ENABLED "lpd-enabled"
#define TR_PREFS_KEY_PREFETCH_ENABLED "prefetch-enabled"
#define TR_PREFS_KEY_DOWNLOAD_DIR "download-dir"
#define TR_PREFS_KEY_ENCRYPTION "encryption"
#define TR_PREFS_KEY_IDLE_LIMIT "idle-seeding-limit"