Summary
- What Is It? – Program to analyze cache behavior based on memory access patterns
- Technologies Used – Java
-
My Accomplishments
- Gained understanding of physical memory and cache operation
- Studied how access patterns impact hit-rate and access time
- Applied Object Oriented Programming best practices
What It Does
The program simulates a series of memory accesses while keeping track of key performance statistics like hit rate and hard disk accesses. When a memory access is requested, the program first checks the page table to see if that address is in TLB. If there is a TLB miss, the program moves on to check the page table. If that address is still not found, that means that it must be on the hard disk. The program simulates reading the block from the hard disk and finds an open frame in the frame table to put the block. The simulation puts the entry into the page table and marks the corresponding frame as allocated.
Finally the translation is moved from the page table to the TLB to simulate caching the data. If any of these tables are full, an eviction is done before moving the data. The simulation implements a fully associative mapping, the write-back scheme, and the least recently used eviction method.
How I Used It
I used this program to study how page size and cache size can impact the performance of a computer. In my case study, I tested 1000 random memory accesses of 8 pages versus 1000 random memory accesses from 9 pages. This seems like a tiny difference, but the outcome changed dramatically. The TLB hitrate dropped from 99% to only 87% because the data could no longer completely fit in cache.
Additionally, I looked at how code localization can affect the speed at which that code runs. I simulated code jumping outside of its current block 25 times versus 400 times. This resulted in a hitrate decrease of 7.5% which would cause the code to execute more slowly.
What I Learned
Before writing this program I thought I had a good understanding of how virtual memory worked. In development I realized all the parts I overlooked. By the time I finished, I had gone over every detail and intricacy of the virtual memory hierarchy that I would consider myself an expert. Additionally, I learned the importance of understanding a project’s requirements. Many school assignments can be learned during development, but more complex projects need to be planned out and fully understood before starting. I also gain a better grasp of object-oriented best practices like abstraction and minimizing side effects.
Link to Code
Because this is a school project, I had to make the GitHub repo private. This link gives read access to the repo without making it public. Virtual Memory Simulation Code