what happens on a write

reads are more frequent than writes.

instruction fetches are reads

most instructions do not write to memory (writeback, writethrough)

make common case fastest: optimize caches for read

easy to make cache fast for read:

writes are much harder to optimize:

there are 2 basic designs for writing to cache:

comparision of writeback and writethrough

writeback happens at speed of cache.

with writeback, writes to same block need only have one write to main memory (useful in multi CPU computers).

writethrough: cache miss never results in writes to next level down.
writethrough much easier to implement in hardware.
writethrough ensures next lower level of memory always has most recent copy of data. this is important for i/o and multiprocessors.

difficulties of multiprocessors and i/o

multiprocessors and i/o are difficult to use with caches because they want characteristics of writeback to reduce requirement of memory bandwidth, but also they want characteristics of writethrough to keep data in all of the CPUs consistent.

when CPU must wait for a write to complete, it is known as a write stall.

this problem can be alleviated by a write buffer, allowing overlap of operations.

data is not needed on a write, so we have 2 options on a write miss:

writeback generally uses write allocate (hopeing subsequent writes are captured by cache).

writethrough generally uses nowrite allocate (since subsequent writes to that block still have to go to lwoer level of memory).


improving performance of caches