Contrast directory-based coherence with snooping. Why is snooping non-scalable for large systems? Explain the directory bit-vector structure and how it invalidates specific cores without broadcasting.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Bus Bandwidth Saturation: Every transaction must go on the shared bus. As processor count increases, bus traffic grows, eventually saturating the bus.
Broadcast Traffic: All coherence traffic is broadcast to all processors, even if only a few have copies. This wastes bandwidth.
Cache Miss Latency: With more processors, more snooping operations occur, increasing latency.
Physical Limitations: You can't build arbitrarily large buses. The bus becomes a bottleneck.
Power Consumption: Unnecessary snooping operations waste power.
Scalability Limit: Typically limited to ~64 processors on a bus
Directory Bit-Vector Structure
A directory typically maintains:
Per memory block entry containing:
State field (e.g., unowned, shared, exclusive)
Bit-vector: one bit per processor
Presence bits indicating which caches have valid copies
For example, with 8 processors, a memory block might have state EXCLUSIVE with bit-vector [0,0,1,0,0,0,1,0], meaning only processors 2 and 6 hold copies of that block.
How Directed Invalidation Works
When a processor writes to a block, the directory consults its bit-vector to identify exactly which caches need invalidation messages, then sends targeted requests only to those processors rather than broadcasting to all.
For instance, if P2 wants to write to block X, it sends a coherence request to the directory. The directory examines the bit-vector for block X, identifies that P2 and P6 have copies, and sends an invalidation message exclusively to P6. Once P6 invalidates its copy and responds, P2 proceeds with the write. This targeted approach generates far less traffic than snooping, which would broadcast the write request to all processors regardless of whether they hold the block.
Cache Coherence: Directory-Based vs. Snooping
1. Core Comparison
Snooping Protocol (Bus-Based)
code
Transaction Flow:
P0 requests write to Block X
↓
BROADCAST to bus (seen by all processors)
↓
P1, P2, P3, ..., Pn all snoop and check state
↓
All holders respond with invalidation acknowledgments
Key Characteristics:
All coherence traffic on shared bus
Every processor monitors every transaction
Symmetric responsibility (no distinguished node)
Simple but high broadcast overhead
Directory-Based Protocol (Scalable)
code
Transaction Flow:
P0 requests write to Block X
↓
Query directory (point-to-point)
↓
Directory identifies exact holders from metadata
↓
TARGETED messages only to actual cache holders
↓
Only relevant processors respond
2. Why Snooping Fails to Scale
Bandwidth Saturation Problem
code
Bus traffic = Function of (# processors) × (miss rate) × (broadcast overhead)
Small system (8 processors):
- Manageable bus bandwidth
- Average latency: ~50 cycles
Large system (256 processors):
- Bus bandwidth exhausted
- Average latency: >500 cycles
- Cache invalidation queues overflow
Specific Scalability Issues
Issue
Impact
Broadcast storm
Every write broadcasts to all cores, even if only 1-2 have copies
Bus arbitration delay
Contention increases linearly with processor count
Coherence traffic growth
O(n) - grows with # of processors
Cache interconnect limit
Physical bus limited to ~64 cores
Power waste
Unnecessary snoop traffic dissipates heat
Example: Write Saturation
code
Snooping - Writing to Block X (256-processor system):
┌─────────────────────────────────────────┐
│ Processor 0: Initiates write │
├─────────────────────────────────────────┤
│ BUS: INVALIDATE Block X broadcast │
├─────────────────────────────────────────┤
│ Processors 1-255: ALL snoop and respond │
│ Even though only P23, P87, P156 have it │
└─────────────────────────────────────────┘
Wasted snoops: ~253 unnecessary operations
3. Directory Bit-Vector Structure
Directory Entry Format
c
struct DirectoryEntry {
State state; // [UNOWNED, SHARED, EXCLUSIVE]
bit_vector holders; // One bit per processor
address tag; // Which memory block
timestamp accessed; // For replacement policies
};
Example for 32-processor system:
┌──────────────────────────────────────────────┐
│ Block Address: 0x10000 │
├──────────────────────────────────────────────┤
│ State: SHARED │
│ Holders: 00000000 00001010 01010101 10101010│
│ (bits set for P10, P12, P14, P16...)│
│ │
│ Directory identifies exactly 8 holders out │
│ of 32 possible processors │
└──────────────────────────────────────────────┘
Space Complexity
code
Centralized Directory:
- Memory blocks M
- Processors N
- Space per entry: 1 bit × N + state bits
- Total: M × (N bits + O(log N) state bits)
Scalability:
- For 1M blocks and 256 processors:
1M × (256 + 8) bits = 33 MB directory metadata
- Compare to snooping: No directory needed (but bus is bottleneck)
SNOOPING approach for same scenario:
1. P5 → BUS: "Invalidate Block X BROADCAST"
All 256 processors see this
2. Snooping by P0-P256:
P0: "Do I have Block X?" → NO (wasted snoop)
P1: "Do I have Block X?" → NO (wasted snoop)
...
P5: (already requesting)
...
P7: "Do I have Block X?" → YES (invalidate)
...
P12: "Do I have Block X?" → YES (invalidate)
...
P256: "Do I have Block X?" → NO (wasted snoop)
Messages: 256 snoops vs. 3 directed invalidations
Efficiency: Directory is 85x better (in this case)
5. Detailed Directory Protocol Example
MESI-Directory Protocol
python
# Directory maintains state for each memory block
class DirectoryEntry:
def __init__(self, num_processors):
self.state = State.UNOWNED # [UNOWNED, SHARED, EXCLUSIVE]
self.owner = None # For EXCLUSIVE state
self.sharers = BitVector(num_processors) # For SHARED state
# Write Miss Handler
def handle_write_miss(processor_id, block_address):
dir_entry = directory[block_address]
# Non-scalable snooping approach:
# if snooping:
# broadcast_invalidate(block_address) # To ALL processors!
# Scalable directory approach:
if dir_entry.state == SHARED:
# Only invalidate actual sharers
invalidate_targets = dir_entry.sharers.get_set_bits()
for target in invalidate_targets:
send_directed_message(
target=target,
type=MessageType.INVALIDATE,
block=block_address
)
wait_for_acks(invalidate_targets)
elif dir_entry.state == EXCLUSIVE:
# Only invalidate the single owner
send_directed_message(
target=dir_entry.owner,
type=MessageType.INVALIDATE,
block=block_address
)
wait_for_ack(dir_entry.owner)
# Grant write access
dir_entry.state = EXCLUSIVE
dir_entry.owner = processor_id
dir_entry.sharers.clear()
6. Scalability Comparison
Traffic Growth Analysis
code
Metric Snooping Directory
─────────────────────────────────────────────────
Broadcast traffic O(n) per miss O(log n) per miss
Bus bandwidth Saturates @64 Scales to 1000+
Avg. coherence msg All processors ~2-5 actual holders
Miss latency (256P) > 1000 cycles ~100-200 cycles
Power per miss High (wasteful) Low (targeted)
Directory-based coherence remains essential for modern large-scale systems because it avoids the fundamental broadcast bottleneck that makes snooping non-scalable.