虚拟内存(页面文件)如何影响程序的执行时间? [英] How does virtual memory (pagefile) affect a program's execution time?

查看:127
本文介绍了虚拟内存(页面文件)如何影响程序的执行时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在测量Windows上程序的运行时间。该程序需要大量内存,因此使用Windows的交换文件(pagefile.sys),但不同运行之间的运行时间差别很大,我无法理解。 

I'm measuring the running time of a program on Windows. The program requires a lot of memory so Windows' swap file (pagefile.sys) is used, but the running time differs a lot between different runs, which I cannot understand. 


以下是详细信息:

Here are the details:


  1. 我通过隐藏文件夹system32 / Task来禁用Windows的计划任务,以避免受到干扰。
  2. 我创建了一个磁盘分区并将交换文件放在那里,其初始大小为50G。 (以前的经验表明20G已经足够了)
  3. 第一次运行需要6h
  4. 第二次运行还没有结束,已经花了14h ......

该程序是一个确定性求解器,其运行时间和内存使用量取决于输入数据的硬度。在简单的数据上,RAM就足够了,每次运行的运行时间都非常稳定。在硬数据上,需要更多的内存和页面文件,
我遇到上述问题。

The program is a deterministic solver whose running time and memory usage depends on the hardness of input data. On easy data, RAM is enough and the running time is very stable on each run. On hard data, much more memory is required and pagefile is concerned, where i'm having the above problem.

如果我理解的话,页面文件可以被视为扩展名内存,它不应该以非确定的方式影响程序的运行时间。
那么为什么运行时间差异那么大呢?

If I understood well, pagefile can be considered as an extension of memory, and it should not affect the running time of programs in a non-deterministic way. So why does the running time differ so much then?

[新观察] 我重启了我的电脑第三次运行,因为我在第一次运行之前也重新启动了。这次我的执行时间为7.2小时,现在接近6小时(首次运行)。所以也许在我的程序第一次运行之后,分页环境
变为"脏",这会影响第二次运行的执行时间?无论如何,1h的差异对我来说似乎仍然不容忽视。

[New observation] I restarted my pc for the third run, since i also restarted before my first run. This time i got 7.2h as execution time which is now close to 6h (first run). So perhaps after the first run of my program, the paging environment becomes "dirty", which affects the execution time of the second run? Anyway 1h's difference still seems not negligible for me.

问候,

推荐答案

您好shanglei,

Hi shanglei,

感谢您在此发帖。

虚拟地址空间分为称为页面的单元。

这是因为硬件内存管理单元以页面的粒度将虚拟地址转换为物理地址。

The virtual address space is divided into units called pages.
That is because the hardware memory management unit translates virtual to physical addresses at the granularity of a page.

大页面的主要优点是对大页面内其他数据的引用进行地址转换的速度。

The primary advantage of large pages is speed of address translation for references to other data within the large page.

第一个引用对于大页面中的任何字节,将导致硬件的转换后备缓冲区(TLB)在其高速缓存中具有将引用转换为大页面内任何其他字节所需的信息

The first reference to any byte within a large page will cause the hardware’s translation look-aside buffer (TLB) to have in its cache the information necessary to translate references to any other byte within the large page

如果使用小页面,则相同范围的虚拟地址需要更多TLB条目,因此随着新虚拟地址需要翻译而增加条目的回收

If small pages are used, more TLB entries are needed for the same range of virtual addresses, thus increasing recycling of entries as new virtual addresses require translation

所以页面将导致运行时间。

So the pages will cause the running time.

最好的问候,

Hart

Best Regards,
Hart


这篇关于虚拟内存(页面文件)如何影响程序的执行时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆