Write Back vs Write Through Cache: 12 Differences

3
63
Write Back vs Write Through Cache

The data cache in a computer typically works in two modes namely, write through and write back. Right from the process of writing and modification of data there are some significant differences between these two methods.

If you want to compare these two methods used in data cache, here is an article that you should read first to know the differences between write through and write back.

KEY TAKEAWAYS

  • When writes update main memory and the cache block both it is called write through and when it only updates the cache block first and the main memory is updated later on during the block replacement it is called write back.
  • The write through method is synchronous but write back or write behind is not synchronous and the modified cache block is later written back to the store.
  • The write through is slow in data writing since it has to be written in both the storage and the cache but write back is a faster process having to write the data in one place only.
  • The write through mode offers much more consistency to the main memory always with an up to date copy of data in it than the write back process in cache.
  • More memory bandwidth is used by the write through process in cache but write back mode uses much less bandwidth.

Write Back vs Write Through Cache – The 12 Differences

Write Back vs Write Through Cache

1. Immediacy

In the write through mode in cache, data is written in the main memory via the cache immediately but, on the other hand, in the write back method the same data is written at a later point of time or just before it is replaced.

Read Also:  L1 Cache vs L2 Cache vs L3 Cache: 8 Differences

2. Ease in Operation

The write through mode in cache is easier to operate than the write back process but write back process in cache is quite complicated.

3. Speed

The write through process is slow because data needs to be written both on the cache and the backend store at the same time.

On the other hand, since the data is written only in one place first, the write back process in cache is much faster in comparison.

4. Consistency Guarantee

There is no guarantee in the write back process that the block in the memory will be similar to that in the related cache line since it is written later on and before the line is replaced.

On the other hand, the write through process being simply the opposite you are guaranteed to have an up to date data and consistent always.

5. Ease in Implementation

The write through process in cache is easy to implement but the write back process, on the other hand, is harder to implement

6. Bandwidth Usage

The write back process in cache uses less memory bandwidth but, in comparison, the write through process uses more memory bandwidth.

7. Handling Write Misses

The write back mode in cache uses write allocate approach while writing data to one cache several times but, in comparison, the write through mode uses no-write allocate method for the same.

8. Number of Memory Write Operations

In the write through method the number of write operations in cache is more in a typical program.

On the other hand, in the write back mode the number of such operations is much less.

9. I/O Device Communication

In the write through method in cache the I/O devices would receive the up to date data when communicated through DMA.

On the other hand, in the write back method the I/O devices will not receive recent data when communicated through DMA.

Read Also:  What is Southbridge? Functions & More

10. Cache Coherence Protocol Requirement

The write back mode in cache needs to follow a more complex Cache Coherence Protocol (MOESI) which in turn makes the system more efficient and fast.

On the other hand, the write through mode in cache makes things simpler with no Cache Coherence Protocol required.

11. Advantages

The advantages of the write through process in cache include zero chance of a read miss in writes in the main memory which always contains the current copy of data which ensures higher consistency.

On the other hand, the advantages offered by the write back mode in cache include writes occurring at the same speed as that of the cache memory and it only needs a single write to the main memory for numerous writes within a block.

12. Disadvantages

The most significant disadvantage of write through in cache is that for every write need an access to the memory is required which slows down the write process.

On the other hand, the disadvantages of write back mode in cache are an inconsistent main memory due to dirty blocks caused by reads in it during replacement.

Which is More Useful – Write Back or Write Through Cache?

Write Back vs Write Through Cache

In terms of performance, simply put, write back in cache seems to be much better in comparison to write through mode in cache.

This is because the writing to main memory is slower than writing the same to the CPU cache.

This may result in data mismatch if, with all its high possibilities, the data is short by the time it is written to the backend store.

The data may change very soon and there is no need to write the older version then in the main memory and create more confusion.

This makes the entire process much more complex, inconsistent, and less reliable.

However, the write through process in cache is much more sophisticated and is used in the memory of most modern CPUs.

Read Also:  What is Mask ROM (MROM)? Function, Pros, Cons & More

The primary benefit offered by it is that it makes the designing of the computer system much simpler overall.

And, since the copy in the main memory in the write through is always up to date, the memory can always reply to a data request while read is done.

However, in the write back method in cache, such up to date data can be sometimes in the main memory and sometimes in the CPU cache.

In that case, the CPU may prevent the main memory from replying to a specific read request since there may be a stale copy of it in the main memory.

This makes the write back process in cache even more complicated and confusing than the write through mode in cache which can make the Cache Coherence Protocol requirement much simpler.

This is because the Modify State is not required in the write through mode in cache which requires it to write back the cache line before it evicts or invalidates the line.

Typically, a cache line in the write through mode can always be annulled without any need for writing it back because the main memory already contains an updated copy of the cache line.

However, in the write back cache architecture the software used may need to take additional steps to write to the memory-mapped I/O registers.

This is required to ensure that the writes are sent out immediately out of the cache.

If this is not done then the writes will not be visible outside the core till the time that line is evicted completely or is read by another processor.

Conclusion

Therefore, after reading this article it is clear to you that both write back and write through cache is necessary but both are significantly different.

This enhanced knowledge will surely help you to make an accurate comparison between the two.

About Taylor

AvatarTaylor S. Irwin is a freelance technology writer with in-depth knowledge about computers. She has an understanding of hardware and technology gained through over 10 years of experience.

3 Comments
Oldest
Newest
Inline Feedbacks
View all comments