More Related Content
Similar to Cache Management (20)
More from SysPlay eLearning Academy for You (12)
Cache Management
- 1. © 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Cache Management
- 2. 2© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What to Expect?
Cache Fundamentals
How's of Cache
Cache Organization
Cache Pitfalls
- 3. 3© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Cache Fundamentals
Mismatch between the RAM & CPU speed
Transfer rate
Latency to access the RAM
Static Vs Dynamic RAM
Systems have Dynamic RAM, which is slower
Static RAM is fast but expensive
Small static RAM between CPU & Dynamic RAM
This is known as Cache
- 4. 4© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
How's of Cache
Located inside the CPU
Copies most recently accessed data from the RAM
memory to the static memory
The goal is to make CPU access the memory
cache instead of accessing directly the RAM
memory
We call it a ‘cache miss’ if the data is not present in
the cache
The circuit called cache controller loads the data
into cache
- 5. 5© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
How's of Cache ...
The CPU asks for the memory / data stored in
address ‘A’
Since contents are not in cache, would be fetched
from RAM
The cache controller loads the line (typically 64
bytes) starting at address ‘A’
The circuit called prefetcher loads more data
located after this line
Branch prediction since program is not always
sequential
- 6. 6© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Cache Organization
Direct Mapping
Divide the memory as per the number of cache lines
Simplest configuration, requires less meta data
Higher chances of cache misses
Fully Associative
Any memory could be loaded into any cache line
Most efficient cache organization
Extremely complex control logic
- 7. 7© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Cache Organization ...
Hybrid solution called set associative
Memory cache is divided in several blocks (sets)
containing ‘n’ lines each
With this, the memory from the single block can be
put into one of the ‘n’ cache lines in the set
- 8. 8© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Direct Mapping
Line 1
Line 2
...
Line 8192
128KB
128KB
128
- 9. 9© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Set Associative Cache
Line 1– Line 4
Line 5 – Line 8
...
Line 2048
128KB
128KB
128
- 10. 10© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Cache Pitfalls
Stale data
May severely degrade the system performance if
the program is not cache local
- 11. 11© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Linux Page Cache Basics
Accelerates many accesses to files on non
volatile storage
During reads / writes to disk, Linux stores data in
unused areas of memory, which acts as cache
free -m
- 12. 12© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What all have we learnt?
Cache Fundamentals
How's of Cache
Cache Organization
Cache Pitfalls
- 13. 13© 2019 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Any Queries?