Results (
Thai) 2:
[Copy]Copied!
In addition to determining which victim to select for replacement, designers must
also decide what to do with so-called dirty blocks of cache, or blocks that have
been modified. When the processor writes to main memory, the data may be written
to the cache instead under the assumption that the processor will probably
read it again soon. If a cache block is modified, the cache write policy determines
when the actual main memory block is updated to match the cache block. There
are two basic write policies:
• Write-through—A write-through policy updates both the cache and the main
memory simultaneously on every write. This is slower than write-back, but
ensures that the cache is consistent with the main system memory. The obvious
disadvantage here is that every write now requires a main memory access.
Using a write-through policy means every write to the cache necessitates a
main memory write, thus slowing the system (if all accesses are write, this
essentially slows the system down to main memory speed). However, in real
applications, the majority of accesses are reads so this slow-down is negligible.
• Write-back—A write-back policy (also called copyback) only updates blocks in
main memory when the cache block is selected as a victim and must be removed
from cache. This is normally faster than write-through because time is not
wasted writing information to memory on each write to cache. Memory traffic is
also reduced. The disadvantage is that main memory and cache may not contain
the same value at a given instant of time, and if a process terminates (crashes)
before the write to main memory is done, the data in cache may be lost.
To improve the performance of cache, one must increase the hit ratio by using a
better mapping algorithm (up to roughly a 20% increase), better strategies for
write operations (potentially a 15% increase), better replacement algorithms (up
to a 10% increase), and better coding practices, as we saw in the earlier example
of row versus column-major access (up to a 30% increase in hit ratio). Simply
increasing the size of cache may improve the hit ratio by roughly 1–4%, but is not
guaranteed to do so.
Being translated, please wait..