Advanced Caches Flashcards

1
Q

Ways to improve cache performance

A
  1. reduce hit time
  2. reduce miss rate
  3. reduce miss penalty
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Ways to reduce hit time

A
  1. pipelined caches
  2. Improve TLB time
  3. Way prediction
  4. Improve replacement policy time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are pipelined caches?

A

Cache accesses are queued, so cannot access the cache while another instruction is accessing it (this can be multiple cycles) ==> instead pipeline the steps to look up an entry in the cache

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a PIPT cache?

A

Physically-indexed, physically tagged cache. This cache stores the actual physical address. Processor must look up physical address in TLB and then use that address to get the data in the cache

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are some potential problems with virtually accessed caches?

A
  • Must flush on context switch because VA are specific to a process
  • Need other information from TLB on cache hits (such as does this process have permission to access this page)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a VIPT cache?

A

Virtually Indexed - Physically Tagged Cache.
Cache uses virtual index to get physical tag.
At the same time. TLB uses virtual index to get physical tag.
If the tags match, then it is a hit
Do not need to flush on context switch

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is cache aliasing?

A

In a VIPT cache, multiple virtual addresses might map to the same physical address, but will get store in the cache in different locations (because they are stored based on virtual address)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why is cache aliasing bad?

A

On a write, only one location will be updated

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How can we ensure that we do not have aliasing?

A

All of the index bits must come from the page offset. AKA (cache offset) + index <= page offset

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is way prediction?

A

We try to guess which line in the set has the correct tag. If we miss, we do a normal check of the rest of the lines in the set.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the relationship between associativity and hit time?

A

As associativity goes up, hit rate goes up, but hit time goes up ==> need to balance associativity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is wrong with LRU and random for replacement polcies?

A
  • Random - nothing to update on cache hit, but has higher miss rate
  • LRU - need to update lots of counters on cache hit, but lower miss rate
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are some alternatives for LRU?

A

NMRU and PLRU

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is PLRU?

A

Every time a line is accessed, set bit to 1. If we need to remove something, remove a 0. Once all the bits have been set, zero out all bits except the last one. Better than NMRU, not as good as LRU

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the three types of misses?

A

Compulsory, capacity (because of limited cache size), and conflict (because of low associativity)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How to reduce the miss rate?

A
  • larger cache blocks
  • prefetching
  • hardware prefetching
  • loop interchange
17
Q

What is the relationship between cache block size and the miss rate?

A

Larger cache blocks reduce the miss rate, but only when spatial locality is good.
Graph of block size vs miss rate is smiley face because eventually the program will not have good enough locality

18
Q

What is prefetching?

A

Trying to guess which blocks will be needed next and loading them into the cache ahead of time

19
Q

What is cache pollution?

A

When the cache is polluted with junk blocks that we don’t need. Can be caused by bad prefetching. Can also cause a second cache miss because we evicted a block we needed to fetch some junk

20
Q

What are prefetch instructions and what are the downsides to using them?

A

A hardware instruction that tells the cache to prefetch data before it is used. They are hard to program correctly because it is hard to guess how long it will take to fetch data.

21
Q

What are the types of hardware prefetching?

A

Stream buffer, stride prefetcher, correlating prefetcher

22
Q

What is a stream buffer?

A

hardware prefetching that tries to fetch the next physical block after the one we just accessed

23
Q

What is stride prefetching?

A

Guesses next block based on address difference (stride) between previous blocks (Aka just looks for a pattern of adding 3)

24
Q

What is correlating prefetching and what is it good for?

A

remembers different patterns than stride and stream. (if we fetch A then B, then next time we fetch A, fetch B). good for linked lists.

25
Q

What is loop interchange?

A
  • Compiler optimization to increase locality
  • In a nested loop, swap the inner and outer loop so that we are iterating over a contiguous block of memory
  • Not always possible => swapped code must be the same (prove by ensuring there are no dependencies between loops)
26
Q

How to reduce the miss penalty?

A

Overlap miss and cache hierarchy

27
Q

How to overlap misses?

A

Have a non-blocking cache that supports:
hit under miss: allow other hits to happen while we are fetching a miss
miss under miss: while we are fetching a miss, allow misses for other blocks to be fetched

28
Q

How to implement miss under miss?

A

Requires hardware support - Miss Status Handling Registers (MSHR) - keeps track of which fetches are currently in progress

29
Q

What is a miss vs half miss?

A

A miss would occur in a blocking cache, a half miss can only occur in a non-blocking cache and occurs when we miss on a block that we are already fetching

30
Q

What is the cache hierarchy?

A

L1, L2…LLC

31
Q

What is the local hit rate?

A

hit rate that the cache observes (i.e. only looking at requests that come to this level cache, what is the hit rate?)

32
Q

What is the global hit rate?

A

the overall hit rate of the entire cache

33
Q

What is MPKI?

A

Misses per 1000 instructions. another metric to use to describe overall hit rate of the entire cache

34
Q

What is inclusion?

A

If there is a block in L1, then it must be in L2

35
Q

What is exclusion?

A

If there is a block in L1, then is must NOT be in L2

36
Q

Do we prefer inclusion or exclusion?

A

Inclusion, better for write-backs