11 CACHES Flashcards

1
Q

What is the primary purpose of caches?

A

To alleviate high data access costs by storing data closer to the computation.

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

What do we mean when we say data is local?

A

Data is stored closer to the processor and thus quickly available for processing.

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

What is a cache hit?

A

When the requested data is found in the cache.

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

What is a cache miss?

A

When the requested data is not found in the cache.

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

What is the least recently used (LRU) cache strategy?

A

A caching strategy that stores recently used information and evicts the least recently used items when full.

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

What are the two main operations required for an LRU cache?

A
  • Looking up an arbitrary element
  • Finding the least recently used element for eviction
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How does an LRU cache determine which data to evict?

A

By tracking which items have not been used recently and removing the oldest item when full.

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

What two data structures are used to implement an LRU cache?

A
  • Hash table
  • Queue
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does the cache structure typically contain in an LRU cache?

A
  • Key
  • Value
  • Pointer to the corresponding node in the queue
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What happens when the cache is full and a new item needs to be added?

A

The oldest item is evicted from the cache.

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

Fill in the blank: A cache is a step before accessing _______ data.

A

expensive

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

True or False: Caches can store all data without limitations.

A

False

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

What is the tradeoff involved in using a cache?

A

Memory used versus the speedup provided.

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

What does the term ‘eviction’ refer to in the context of caches?

A

The process of removing data from the cache to make space for new data.

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

What is a common caching strategy used in web browsers?

A

Caching commonly accessed data such as images or logos.

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

What type of data storage is the fastest but has limited capacity?

A

Memory on the CPU (registers or local caches).

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

What is the effect of using slower storage for larger cache sizes?

A

It can reduce the overall speed of data access.

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

How does the barista analogy relate to caching?

A

It illustrates the importance of storing popular items nearby to reduce retrieval time.

19
Q

What happens to the cache when a cache hit occurs?

A

The data is accessed directly and its location is updated in the queue.

20
Q

What is the role of the hash table in an LRU cache?

A

To perform fast lookups and store composite data structures.

21
Q

What is the QueueListNode in the cache entry structure?

A

A pointer to the corresponding node in the queue.

22
Q

What is an example of a caching strategy discussed in the chapter?

A

Least Recently Used (LRU) cache.

23
Q

What is the primary purpose of a cache?

A

To alleviate access costs when dealing with expensive storage mediums.

24
Q

What is the eviction strategy used in the cache discussed?

A

Least Recently Used (LRU) eviction strategy.

25
What does a cache hit mean?
When an element is found in the cache.
26
What happens to an element's position on a cache hit?
It is moved to the back of the queue.
27
What data structure is modified to support updating an element’s position in the queue?
Doubly linked list.
28
What does the QueueListNode structure consist of?
* Type: value * QueueListNode: next * QueueListNode: prev
29
What is the purpose of the RemoveNode function?
To remove a node from the middle of the queue.
30
What does the enqueue operation do?
Adds a new node to the back of the queue.
31
What does the dequeue operation return when the queue is empty?
null.
32
What is the role of the prev pointer in a doubly linked list?
It refers to the node preceding the current node.
33
What is the first step in the RemoveNode operation?
Adjust the next pointer of the previous node.
34
True or False: The LRU eviction strategy is optimal when the cached items' distribution changes over time.
True.
35
What is the alternative eviction strategy that discards the most recently used element?
Most Recently Used (MRU) eviction strategy.
36
What does the Least Frequently Used (LFU) eviction strategy rely on?
The count of how many times an item has been accessed.
37
What can be a downside of the LFU eviction strategy?
It can take time for new popular items to accumulate enough counts to enter the cache.
38
What is the predictive eviction strategy?
A strategy that tries to predict future cache entries based on a model.
39
What is a critical tradeoff in choosing a caching strategy?
Balancing cache size and eviction strategy for optimal performance.
40
Fill in the blank: Caches illustrate the potential tradeoffs when accessing data from different _______.
mediums.
41
What is one of the key concepts caches revisit?
Data structure tuning.
42
How do caches combine basic data structures?
By using pointers to tie hash table entries to nodes in a queue.
43
What happens when the cache is too small?
It might not store enough to provide a benefit.
44
What is the consequence of a cache that is too large?
It will take important memory resources needed for other parts of the algorithm.