当前位置:网站首页>Briefly describe the hierarchical strategy of memory
Briefly describe the hierarchical strategy of memory
2022-04-23 08:08:00 【Playful wood】
Why does storage have a hierarchical strategy ?
For memory , We all want it to be faster 、 A smaller 、 More capacity 、 It's cheaper , But these requirements are often contradictory , So we need to grade the requirements , The more frequently used data , The faster you read and write, the better , So use the most expensive materials , Put it away CPU Nearest location ; The less frequently used data , Use cheaper materials , Put it away CPU The farther away .
Hierarchical strategy of memory
Memory can usually be divided into the following four levels : register 、 Cache 、 Memory 、SSD/ Hard disk / disk
register Register
The register is next to CPU Control unit and logic calculation unit . Register access is very fast ( Using and CPU Made of the same material , So and CPU As fast as ), Generally, it is required to be within half an hour CPU Complete reading and writing within the clock cycle . For example, one should be in 4 Instructions completed in one cycle , In addition to reading and writing registers , You also need to decode instructions 、 Control instruction execution and calculation . If the speed of the register is too slow , that 4 You may not be able to complete this instruction in one cycle .
Each register can be used to store a certain byte (byte) The data of . such as :
- 32 position CPU Most registers in can store 4 Bytes
- 64 position CPU Most registers in can store 8 Bytes
Cache Cache
Cache It is a high-speed and small capacity memory in the computer , What's in it is CPU Instructions and recent data , Its access speed can be the same as CPU Speed matching for , Generally, static RAM act as Cache.CPU The speed of is controlled by the memory access speed , In order to solve CPU And memory speed mismatch , stay CPU And memory Cache.
Cache It's also divided into L1-Cache、L2-Cache、L3-Cache etc. , They are in turn far away from each other CPU The farther , Lower cost 、 More storage capacity 、 Slower reading and writing .
Memory
The main material of memory is semiconductor silicon , It works on the motherboard . Because of its position and distance CPU There's a distance , So we need to use bus and CPU Connect . Because memory has independent space , So it's bigger , The cost is also much lower than the memory mentioned above . Now the memory on some personal computers is 16G, But some servers can have up to a few memory T. The memory speed is about 200~300 individual CPU Between cycles .
All memory access requests that cannot be satisfied in the cache are transferred to main memory .
SSD And the hard disk
SSD(Solid-State Driver/Disk) Also called solid state drive , Structure is similar to memory , But its advantage is that the data is still after power failure . Memory 、 register 、 After the cache is powered off, the data disappears . The reading and writing speed of memory is faster than SSD Probably fast 10~1000 times . There used to be a kind of physical read-write disk , Also called hard disk or mechanical hard disk , It's slower than memory 100W About times . Because it's too slow , Now it has been gradually SSD replace .
The relationship between different levels of memory
SSD/ Hard disks are used to store data , And the data still exists after power failure . We install applications on computers and store local files , After shutdown or power failure , It won't go away .
Memory 、 Cache 、 Registers are not used to store data , The data will disappear after power failure ( Not exactly , Like... In memory ROM And flash memory, etc ), They are mainly used to speed up CPU Fast .CPU The speed of can be roughly divided into two categories , Processing data + Read and write data , The speed of reading and writing data will be limited by the speed of memory , So as mentioned at the beginning , We need to classify memory into registers 、 Cache 、 Memory , In turn, it has faster speed 、 leave CPU A more recent , But it also has smaller storage space 、 Higher prices .
When CPU When you need some data in memory , Will be sent to the register in turn 、 Cache 、 Memory request data . If there is this data in the register , Can be used directly ; Otherwise, you have to query the cache in turn L1、L2、L3 cache ; If there is no data , Then go to the memory to get .
版权声明
本文为[Playful wood]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230642171563.html
边栏推荐
猜你喜欢
随机推荐
GUI,CLI与Unix哲学
国基北盛-openstack-容器云-环境搭建
Talking about distributed storage from ES, mongodb, redis and rocketmq
Implementation of new
Anti shake and throttling
RAID0和RAID5的创建和模拟RAID5工作原理
KVM安装部署
1216_ MISRA_ C standard learning notes_ Rule requirements for control flow
1+x云计算中级--脚本搭建读写分离
Depth of binary tree
Mobile web (Font Icon, plane conversion, color gradient)
随笔(不定时更新)
Go语学习笔记 - 异常处理 | 从零开始Go语言
Feign source code analysis
SAP self created table log function is enabled
Chapter VII asset impairment
Chapter V investment real estate
Flutter之Provider共享数据的两种方式
Redis事务实现乐观锁原理
Link to some good tutorials or notes about network security and record them