gpt4 book ai didi

performance - 虚拟内存相对于直接映射内存的性能影响是什么?

转载 作者:行者123 更新时间:2023-12-03 14:28:04 25 4
gpt4 key购买 nike

Virtual memory是一种在进程之间隔离内存并为每个进程提供自己的地址空间的便捷方法。它的工作原理是将虚拟地址转换为物理地址。

我已经非常熟悉虚拟内存的工作原理和实现方式。我不知道的是虚拟内存相对于直接映射内存的性能影响,它不需要翻译开销。

请不要说没有开销。这显然是错误的,因为遍历页表需要多次内存访问。 TLB 未命中的频率可能足够低,以至于对性能的影响可以忽略不计,但是,如果是这种情况,则应该有证据证明这一点。

我也意识到虚拟内存对于现代操作系统提供的许多功能的重要性,所以这个问题不是关于虚拟内存是好是坏(对于大多数用例来说这显然是一件好事),我纯粹是在问关于虚拟内存的性能影响。

我正在寻找的答案在理想情况下是这样的:虚拟内存对直接映射施加了 x% 的开销,这里有一篇论文表明了这一点。我试图寻找具有此类结果的论文,但找不到任何论文。

最佳答案

这个问题很难明确回答,因为虚拟内存是现代系统的一个组成部分,旨在支持虚拟内存,并且大多数软件都是使用具有虚拟内存的系统编写和优化的。

然而,在 2000 年代初期,微软研究院开发了一个名为 Signularity 的研究操作系统。除其他外,它不依赖虚拟内存进行进程隔离。作为该项目的一部分,他们发表了一篇论文,分析了用于进程隔离的硬件支持的开销。论文题目Deconstructing Process Isolation (非付费专区链接 here)。在论文中,研究人员写道:

Most operating systems use a CPU’s memory management hardware to provide process isolation, using two mechanisms. First, processes are only allowed access to certain pages of physical memory. Second, privilege levels prevent untrusted code from manipulating the system resources that implement processes, for example, the memory management unit (MMU) or interrupt controllers. These mechanisms’ non-trivial performance costs are largely hidden, since there is no widely used alternative approach to compare them to. Mapping from virtual to physical addresses can incur overheads up to 10–30% due to exception handling, inline TLB lookup, TLB reloads, and maintenance of kernel data structures such as page tables [29]. In addition, virtual memory and privilege levels increase the cost of inter-process communication.



他们后来在论文中写道:

Virtual memory systems (with the exception of software-only systems such as SPUR [46]) rely on a hardware cache of address translations to avoid accessing page tables at every processor cache miss. Managing TLB entries has a cost, which Jacob and Mudge estimated at 5–10% on a simulated MIPS-like processor [29]. The virtual memory system also brings its data, and in some systems, code as well, into a processor’s caches, which evicts user code and data. Jacob and Mudge estimate that, with small caches, these induced misses can increase the overhead to 10–20%. Furthermore, they found that virtual memory induced interrupts can increase the overhead to 10–30%. Other studies found similar or even higher overheads, though the actual costs are very dependent on system details and benchmarks [3, 6, 10, 26, 36, 40, 41]. In addition, TLB access is on the critical path of many processor designs [2, 30] and so might affect processor clock speed.



总的来说,我会对这些结果持保留态度,因为这项研究正在推广一种替代系统。但很明显,实现虚拟内存会产生一些开销,本文尝试量化其中一些开销(在评估可能的替代方案的背景下)。我建议阅读论文以获取更多详细信息。

关于performance - 虚拟内存相对于直接映射内存的性能影响是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36992702/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com