Course contentsShow
← Embedded Systems & Computer Architecture
Lesson 141 of 9362. Instruction Set Architecture and CPU MicroarchitectureFree lesson

Evaluating Write-Through Policy Performance

Analyze the impact of write-through caching on bus traffic and identify scenarios where it simplifies consistency in multi-level hierarchies.

In this lesson, you will learn how the write-through cache policy impacts bus congestion and simplifies memory consistency in multi-level hierarchies.

Understanding Write-Through

When a processor writes data to memory, a write-through policy ensures that the data is updated in both the cache and the underlying main memory simultaneously. While this guarantees that your main memory always holds the most current value, it comes at a cost to performance.

The Impact on Bus Traffic

Because every single store instruction triggers a write to the main memory, the system bus experiences high traffic. In high-performance pipelines, this can lead to a bottleneck. If the processor performs many consecutive stores, it must wait for the memory controller to acknowledge each write. Without a "write buffer" to decouple the CPU from the slow memory, the pipeline would often stall.

Consider this simple loop:

LOOP:
    sw $t0, 0($s1)  # Store word to memory
    addi $s1, $s1, 4
    bne $s1, $t2, LOOP

With write-through, every single iteration of this loop forces a transaction onto the system bus. If the bus is busy handling other tasks, the pipeline must stall, effectively increasing your Cycles Per Instruction (CPI) and negating the speed benefits of your cache.

Consistency in Multi-level Hierarchies

Despite the traffic penalty, write-through is favored in specific designs for its simplicity regarding consistency. If you have multiple levels of cache (e.g., L1 and L2), a write-through L1 cache ensures that any change is immediately propagated to the L2 cache.

This simplifies logic significantly: you never have to worry about a "dirty" line in the L1 cache becoming stale relative to the L2 or main memory. If a different core or a DMA (Direct Memory Access) controller needs to read memory, it is guaranteed to see the most recent data without needing complex "snooping" protocols to track which cache contains a modified version of the data.

Key Takeaway: While write-through policies increase bus traffic and can introduce pipeline stalls, they provide a simple, robust method for maintaining memory consistency across multi-level cache hierarchies.