forked from premiere/premiere-libtorrent
added session setting to control disk buffer pool allocation sizes
This commit is contained in:
parent
46c286eea3
commit
85bf463e11
|
@ -3369,6 +3369,7 @@ session_settings
|
||||||
bool auto_upload_slots_rate_based;
|
bool auto_upload_slots_rate_based;
|
||||||
bool use_parole_mode;
|
bool use_parole_mode;
|
||||||
int cache_size;
|
int cache_size;
|
||||||
|
int cache_buffer_chunk_size;
|
||||||
int cache_expiry;
|
int cache_expiry;
|
||||||
bool use_read_cache;
|
bool use_read_cache;
|
||||||
bool disk_io_no_buffer;
|
bool disk_io_no_buffer;
|
||||||
|
@ -3613,6 +3614,11 @@ send or receive buffer also count against this limit. Send and receive buffers
|
||||||
will never be denied to be allocated, but they will cause the actual cached blocks
|
will never be denied to be allocated, but they will cause the actual cached blocks
|
||||||
to be flushed or evicted.
|
to be flushed or evicted.
|
||||||
|
|
||||||
|
Disk buffers are allocated using a pool allocator, the number of blocks that
|
||||||
|
are allocated at a time when the pool needs to grow can be specified in
|
||||||
|
``cache_buffer_chunk_size``. This defaults to 16 blocks. Lower numbers
|
||||||
|
saves memory at the expense of more heap allocations. It must be at least 1.
|
||||||
|
|
||||||
``cache_expiry`` is the number of seconds from the last cached write to a piece
|
``cache_expiry`` is the number of seconds from the last cached write to a piece
|
||||||
in the write cache, to when it's forcefully flushed to disk. Default is 60 second.
|
in the write cache, to when it's forcefully flushed to disk. Default is 60 second.
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,7 @@ namespace libtorrent
|
||||||
, auto_upload_slots_rate_based(true)
|
, auto_upload_slots_rate_based(true)
|
||||||
, use_parole_mode(true)
|
, use_parole_mode(true)
|
||||||
, cache_size(1024)
|
, cache_size(1024)
|
||||||
|
, cache_buffer_chunk_size(16)
|
||||||
, cache_expiry(60)
|
, cache_expiry(60)
|
||||||
, use_read_cache(true)
|
, use_read_cache(true)
|
||||||
, disk_io_write_mode(0)
|
, disk_io_write_mode(0)
|
||||||
|
@ -383,6 +384,12 @@ namespace libtorrent
|
||||||
// default is 512 (= 8 MB)
|
// default is 512 (= 8 MB)
|
||||||
int cache_size;
|
int cache_size;
|
||||||
|
|
||||||
|
// this is the number of disk buffer blocks (16 kiB)
|
||||||
|
// that should be allocated at a time. It must be
|
||||||
|
// at least 1. Lower number saves memory at the expense
|
||||||
|
// of more heap allocations
|
||||||
|
int cache_buffer_chunk_size;
|
||||||
|
|
||||||
// the number of seconds a write cache entry sits
|
// the number of seconds a write cache entry sits
|
||||||
// idle in the cache before it's forcefully flushed
|
// idle in the cache before it's forcefully flushed
|
||||||
// to disk. Default is 60 seconds.
|
// to disk. Default is 60 seconds.
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace libtorrent
|
||||||
: m_block_size(block_size)
|
: m_block_size(block_size)
|
||||||
, m_in_use(0)
|
, m_in_use(0)
|
||||||
#ifndef TORRENT_DISABLE_POOL_ALLOCATOR
|
#ifndef TORRENT_DISABLE_POOL_ALLOCATOR
|
||||||
, m_pool(block_size, 16)
|
, m_pool(block_size, m_settings.cache_buffer_chunk_size)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
|
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
|
||||||
|
@ -95,7 +95,7 @@ namespace libtorrent
|
||||||
char* ret = page_aligned_allocator::malloc(m_block_size);
|
char* ret = page_aligned_allocator::malloc(m_block_size);
|
||||||
#else
|
#else
|
||||||
char* ret = (char*)m_pool.ordered_malloc();
|
char* ret = (char*)m_pool.ordered_malloc();
|
||||||
m_pool.set_next_size(16);
|
m_pool.set_next_size(m_settings.cache_buffer_chunk_size);
|
||||||
#endif
|
#endif
|
||||||
++m_in_use;
|
++m_in_use;
|
||||||
#if TORRENT_USE_MLOCK
|
#if TORRENT_USE_MLOCK
|
||||||
|
@ -162,7 +162,7 @@ namespace libtorrent
|
||||||
char* ret = page_aligned_allocator::malloc(m_block_size * num_blocks);
|
char* ret = page_aligned_allocator::malloc(m_block_size * num_blocks);
|
||||||
#else
|
#else
|
||||||
char* ret = (char*)m_pool.ordered_malloc(num_blocks);
|
char* ret = (char*)m_pool.ordered_malloc(num_blocks);
|
||||||
m_pool.set_next_size(16);
|
m_pool.set_next_size(m_settings.cache_buffer_chunk_size);
|
||||||
#endif
|
#endif
|
||||||
m_in_use += num_blocks;
|
m_in_use += num_blocks;
|
||||||
#if TORRENT_USE_MLOCK
|
#if TORRENT_USE_MLOCK
|
||||||
|
|
|
@ -148,6 +148,7 @@ namespace libtorrent
|
||||||
|
|
||||||
// don't use any disk cache
|
// don't use any disk cache
|
||||||
set.cache_size = 0;
|
set.cache_size = 0;
|
||||||
|
set.cache_buffer_chunk_size = 1;
|
||||||
set.use_read_cache = false;
|
set.use_read_cache = false;
|
||||||
|
|
||||||
set.close_redundant_connections = true;
|
set.close_redundant_connections = true;
|
||||||
|
@ -190,12 +191,12 @@ namespace libtorrent
|
||||||
// use 128 MB of cache
|
// use 128 MB of cache
|
||||||
set.cache_size = 8192;
|
set.cache_size = 8192;
|
||||||
set.use_read_cache = true;
|
set.use_read_cache = true;
|
||||||
|
set.cache_buffer_chunk_size = 64;
|
||||||
|
|
||||||
set.close_redundant_connections = true;
|
set.close_redundant_connections = true;
|
||||||
|
|
||||||
set.max_rejects = 10;
|
set.max_rejects = 10;
|
||||||
|
|
||||||
// use less memory when checking pieces
|
|
||||||
set.optimize_hashing_for_speed = true;
|
set.optimize_hashing_for_speed = true;
|
||||||
|
|
||||||
return set;
|
return set;
|
||||||
|
|
Loading…
Reference in New Issue