COEN 180 Memory Hierarchy Memory Hierarchy We are

  • Slides: 18
Download presentation
COEN 180 Memory Hierarchy

COEN 180 Memory Hierarchy

Memory Hierarchy We are therefore forced to recognize the possibility of constructing a hierarchy

Memory Hierarchy We are therefore forced to recognize the possibility of constructing a hierarchy of memories, each of which has greater capacity than the preceding but which is less quickly accessible. A. W. Burks, H. H. Goldstine, J. von Neumann: Preliminary Discussion of the Logical Design of Electronic Computing Instrument, Part I, Vol. I, Report prepared for the U. S. Army Ord. Dept. 28 June 1946

Computer Components There are three basic hardware modules (Bell, Newell: Computer Structures, 1971): n

Computer Components There are three basic hardware modules (Bell, Newell: Computer Structures, 1971): n n n Processors Memory Communication

Memory / Storage Evaluation n n n Costs Capacity Speed Reliability Volatility Other criteria

Memory / Storage Evaluation n n n Costs Capacity Speed Reliability Volatility Other criteria such as transportability

Memory / Storage Evaluation

Memory / Storage Evaluation

Memory Hierarchy

Memory Hierarchy

Exploiting the Memory Hierarchy n n n Not all stored data is equally important.

Exploiting the Memory Hierarchy n n n Not all stored data is equally important. Put important data in the upper ranges of the memory / storage hierarchy. Put unimportant data in the lower ranges.

Exploiting the Memory Hierarchy n Locality n Spatial Locality: n n Data is more

Exploiting the Memory Hierarchy n Locality n Spatial Locality: n n Data is more likely to be accessed if neighboring data is accessed. Temporal Locality: n Data is more likely to be accessed if it has been recently accessed.

Exploiting the Memory Hierarchy n Executables n n n Program executions tend to spend

Exploiting the Memory Hierarchy n Executables n n n Program executions tend to spend a great portion of time in loops. Spatial locality: if a statement in the loop is executed, then so are the statements surrounding it. Temporal locality: if a statement is executed, it is likely to be executed again.

Exploiting the Memory Hierarchy n Relational Databases n Store data in relations n n

Exploiting the Memory Hierarchy n Relational Databases n Store data in relations n n Relation consists of fields Often with Record ID. Stored in a B+ tree or in a (linear) hash table. Spatial Locality n Accessing all records in order, records are stored in B+ tree. n n Makes sense to move records in bunches from disk / tape to main memory. Typical transaction has no spatial locality. n n Accesses a record here and there all over the place. No spatial locality.

Exploiting the Memory Hierarchy n Relational Databases n Temporal Locality n Some records are

Exploiting the Memory Hierarchy n Relational Databases n Temporal Locality n Some records are hot, most are cold. n n Records of current students vs. records of graduates. Active accounts in a bank database. Current patients versus other patients. Some transactions look at the same record several times (due to inefficiencies).

Exploiting the Memory Hierarchy n File System n Temporal Locality: n n n Few

Exploiting the Memory Hierarchy n File System n Temporal Locality: n n n Few files are frequently accessed (OS kernel, killer apps, data in current projects). Most are written and never read again. Spatial Locality: n Not only individual files, but also directories can become hot.

Exploiting the Memory Hierarchy n Caching strategy: n n n Keep popular items in

Exploiting the Memory Hierarchy n Caching strategy: n n n Keep popular items in expensive, small, and fast memory. Keep less popular items in cheap, big, and slow memory. Use spatial & temporal locality to guess what items are popular.

Exploiting the Memory Hierarchy n Use Caches throughout the Memory Hierarchy n n Registers

Exploiting the Memory Hierarchy n Use Caches throughout the Memory Hierarchy n n Registers & SRAM versus DRAM (main memory) Disk buffer versus Disk platter Disks versus Tapes Local Storage versus Remote Storage

Cache Analysis n Assume two levels of memory: n n n Cache: fast, small,

Cache Analysis n Assume two levels of memory: n n n Cache: fast, small, expensive. Main: slow, large, cheap. Data access: n n Read Write Assume read only access Given data identifier, read data.

Cache Analysis n n n Hit rate h: chances of satisfying read request from

Cache Analysis n n n Hit rate h: chances of satisfying read request from cache. Miss rate m: chances having to read from main. h+m=1

Cache Analysis n t. C Time to read from cache t. M Time to

Cache Analysis n t. C Time to read from cache t. M Time to read from main t. C < t. M n Expected access time = system access time n n t. System = h t. C + m t. M Hit rates high: system access time close to cache access time

Caching Issues n n Larger cache slower access times Selection of items into cache

Caching Issues n n Larger cache slower access times Selection of items into cache n n Good selection takes more time and uses more resources Cache architecture depends on the situation n Cache between main memory and processor Cache between disk drive(s) and main memory Cache between remote and local storage