added read cache. Not fully configurable yet

This commit is contained in:
Arvid Norberg
2008-02-22 04:11:04 +00:00
parent bf7552a4cd
commit ef9ef674d5
5 changed files with 486 additions and 79 deletions

View File

@@ -660,7 +660,11 @@ struct cache_status
{
size_type blocks_written;
size_type writes;
int write_size;
size_type blocks_read;
size_type blocks_read_hit;
size_type reads;
int cache_size;
int read_cache_size;
};
</pre>
</blockquote>
@@ -671,7 +675,14 @@ session was started.</p>
<p>The ratio (<tt class="docutils literal"><span class="pre">blocks_written</span></tt> - <tt class="docutils literal"><span class="pre">writes</span></tt>) / <tt class="docutils literal"><span class="pre">blocks_written</span></tt> represents
the number of saved write operations per total write operations. i.e. a kind
of cache hit ratio for the write cahe.</p>
<p><tt class="docutils literal"><span class="pre">write_size</span></tt> is the number of 16 KiB blocks currently in the write cache.</p>
<p><tt class="docutils literal"><span class="pre">blocks_read</span></tt> is the number of blocks that were requested from the
bittorrent engine (from peers), that were served from disk or cache.</p>
<p><tt class="docutils literal"><span class="pre">blocks_read_hit</span></tt> is the number of blocks that were served from cache.</p>
<p>The ratio <tt class="docutils literal"><span class="pre">blocks_read_hit</span></tt> / <tt class="docutils literal"><span class="pre">blocks_read</span></tt> is the cache hit ratio
for the read cache.</p>
<p><tt class="docutils literal"><span class="pre">cache_size</span></tt> is the number of 16 KiB blocks currently in the disk cache.
This includes both read and write cache.</p>
<p><tt class="docutils literal"><span class="pre">read_cache_size</span></tt> is the number of 16KiB blocks in the read cache.</p>
</div>
<div class="section">
<h2><a id="get-cache-info" name="get-cache-info">get_cache_info()</a></h2>
@@ -690,14 +701,14 @@ struct cached_piece_info
{
int piece;
std::vector&lt;bool&gt; blocks;
ptime last_write;
ptime last_use;
};
</pre>
</blockquote>
<p><tt class="docutils literal"><span class="pre">piece</span></tt> is the piece index for this cache entry.</p>
<p><tt class="docutils literal"><span class="pre">blocks</span></tt> has one entry for each block in this piece. <tt class="docutils literal"><span class="pre">true</span></tt> represents
the data for that block being in the disk cache and <tt class="docutils literal"><span class="pre">false</span></tt> means it's not.</p>
<p><tt class="docutils literal"><span class="pre">last_write</span></tt> is the time when a block was last written to this piece. The older
<p><tt class="docutils literal"><span class="pre">last_use</span></tt> is the time when a block was last written to this piece. The older
a piece is, the more likely it is to be flushed to disk.</p>
</div>
<div class="section">