当前位置:网站首页>大页内存原理及使用设置
大页内存原理及使用设置
2022-07-28 23:43:00 【qq_42533216】
内存分页大小对性能的提升原理
首先,我们需要回顾一小部分计算机组成原理,这对理解大内存分页至于JVM性能的提升是有好处的。
什么是内存分页?
我们知道,CPU是通过寻址来访问内存的。32位CPU的寻址宽度是 0~0xFFFFFFFF ,计算后得到的大小是4G,也就是说可支持的物理内存最大是4G。
但在实践过程中,碰到了这样的问题,程序需要使用4G内存,而可用物理内存小于4G,导致程序不得不降低内存占用。
为了解决此类问题,现代CPU引入了 MMU(Memory Management Unit 内存管理单元)。
MMU 的核心思想是利用虚拟地址替代物理地址,即CPU寻址时使用虚址,由 MMU 负责将虚址映射为物理地址。
MMU的引入,解决了对物理内存的限制,对程序来说,就像自己在使用4G内存一样。
内存分页(Paging)是在使用MMU的基础上,提出的一种内存管理机制。它将虚拟地址和物理地址按固定大小(4K)分割成页(page)和页帧(page frame),并保证页与页帧的大小相同。
这种机制,从数据结构上,保证了访问内存的高效,并使OS能支持非连续性的内存分配。
在程序内存不够用时,还可以将不常用的物理内存页转移到其他存储设备上,比如磁盘,这就是大家耳熟能详的虚拟内存。
在上文中提到,虚拟地址与物理地址需要通过映射,才能使CPU正常工作。
而映射就需要存储映射表。在现代CPU架构中,映射关系通常被存储在物理内存上一个被称之为页表(page table)的地方。
如下图:

从这张图中,可以清晰地看到CPU与页表,物理内存之间的交互关系。
进一步优化,引入TLB(Translation lookaside buffer,页表寄存器缓冲)
由上一节可知,页表是被存储在内存中的。我们知道CPU通过总线访问内存,肯定慢于直接访问寄存器的。
为了进一步优化性能,现代CPU架构引入了TLB,用来缓存一部分经常访问的页表内容。
如下图:

对比 9.6 那张图,在中间加入了TLB。
为什么要支持大内存分页?
TLB是有限的,这点毫无疑问。当超出TLB的存储极限时,就会发生 TLB miss,之后,OS就会命令CPU去访问内存上的页表。如果频繁的出现TLB miss,程序的性能会下降地很快。
为了让TLB可以存储更多的页地址映射关系,我们的做法是调大内存分页大小。
如果一个页4M,对比一个页4K,前者可以让TLB多存储1000个页地址映射关系,性能的提升是比较可观的。
虚拟机中设置大页内存:
echo 1024 > /proc/sys/vm/nr_hugepages 2G的内存设置256,4G内存设置512.
边栏推荐
- Cloud function realizes website automatic check-in configuration details [web function /nodejs/cookie]
- Selenium wire obtains Baidu Index
- 【commons-lang3专题】005- ObjectUtils 专题
- Flash and seven cattle cloud upload pictures
- Jupyter notebook中5个有趣的魔法命令
- Several methods of multi-threaded sequential operation can be asked casually in the interview
- 【刷题笔记】链表内指定区间反转
- 【无标题】
- Hash table~
- 【unity】将unity编辑c#配置为vscode
猜你喜欢

Wechat campus bathroom reservation applet graduation design finished product (8) graduation design thesis template

小程序毕设作品之微信校园浴室预约小程序毕业设计成品(5)任务书

时间序列数据的预处理方法总结

第二轮1000个Okaleido Tiger,再次登录Binance NFT 1小时售罄

Xinchi technology released the latest flagship product of G9 series, equipped with six A55 cores with 1.8GHz dominant frequency

Outlier detection and open set identification (2)

mysql存储过程 实现创建一张表(复制原表的结构新建的表)

用CDO进行nc数据的不规则裁剪
![[AD learning] the course of PCB drawing in this marine vehicle competition](/img/37/211a0557848f6922fda7a69a114923.png)
[AD learning] the course of PCB drawing in this marine vehicle competition

Huawei releases harmonyos 3.0, taking another step towards "Internet of all things"
随机推荐
Several methods of multi-threaded sequential operation can be asked casually in the interview
Relying on cloud business to support revenue growth alone, is Microsoft still overvalued?
机器学习 | MATLAB实现RBF径向基神经网络newrbe参数设定
About 1931cie -- conversion of XYZ color coordinate graph to RGB color coordinate relationship
Data warehouse construction - DWT floor
What opportunities does the London gold real-time market bring?
芯驰科技发布G9系列最新旗舰产品,配备6个1.8Ghz主频的A55核心
Educational Codeforces Round 132 (Rated for Div. 2)【A~C】
会议OA项目之会议通知&会议反馈&反馈详情功能
Daniel guild Games: summary and future outlook of this year
Irregular clipping of NC data with CDO
Asynchronous mode worker thread
【AD学习】本次海上航行器大赛画pcb图的历程
Andriod6.0 low power mode (turn off WiFi, Bluetooth, GPS, screen brightness, etc.)
保护性拷贝&无状态
Execute immediate simple sample set (DML)
Educational Codeforces Round 132 (Rated for Div. 2)【A~C】
DRF - web development mode, API interface, API interface testing tool, restful specification, serialization and deserialization, DRF installation and use
管理区解耦架构见过吗?能帮客户搞定大难题的
B+ tree~