如今的计算机速度非常快,最新的操作系统非常擅长保持这种状态。大多数精通技术的Windows用户每年都会执行“格式化并重新安装”仪式的日子已经一去不复返了。(format and reinstall)这并不是说您全新安装的Windows 10将永远保持活泼。
一些用户可能会注意到,如果他们在视频游戏中使用 alt-tab 或(game or swap)在视频编辑器或 100-tab 浏览器窗口等重磅应用之间切换,事情就会停止。这表明您已经用完了安装在 PC 中的超快随机存取存储器, (Random Access Memory)Windows现在不得不依靠速度慢得多的辅助存储来溢出。
当Windows将(Windows)RAM芯片中的信息与称为“页面文件”的溢出区域交换时,就会出现您目睹的速度减慢。
在Windows 10中优化(Windows 10)页面文件(paging file)时可以提高性能。
什么是“分页文件”?(What Is a “Paging File” Anyway?)
在我们了解如何优化页面文件(paging file)之前,让我们更深入地了解一下文件是什么。如果您已将Windows 资源(Windows explorer)管理器设置为向您显示隐藏的系统文件,您会在C 驱动器(C drive)的根目录中找到它,名称为“pagefile.sys”。假设您的 PC 具有默认配置(default configuration)。
页面文件具有保留大小,并在内部分为“页面”。这是存储RAM数据的数据格式,适用于任何使用RAM 分页(RAM paging)作为内存管理方法的(memory management method)操作系统(operating system)。
“页面”是信息块,每个信息块都有一个唯一的地址和完全相同的大小。您计算机上的软件会记录哪些页面有其信息,因此当它需要该信息时,它会从Windows请求该页面。
当您的应用程序需要的RAM比您的计算机实际拥有的更多 RAM 时,它需要使用“虚拟内存”,这正是页面文件(page file)的含义。从应用程序的角度来看,它只是更多的RAM。唯一的区别是从硬盘读取信息比RAM慢得多(much)。这(Which)是拥有RAM的重点!
因此,如果页面文件(page file)如此缓慢,为什么还要拥有它呢?如果没有页面文件(page file),您的应用程序将崩溃或严重故障,因为需要存储在RAM中的任何附加信息都将丢失。稍微放慢速度来处理峰值RAM需求比让系统整体停机要好。
好的,但是为什么要优化分页文件呢?(OK, But Why Optimize The Paging File?)
RAM 分页(RAM paging)是现存最古老的内存管理(memory management)方法之一。1960 年代的大型计算机已经在使用它!当RAM(RAM)以几十 KB 为单位测量时,这很有意义。当 640KB 的内存“对任何人都足够(enough for anyone)”时,它仍然是有意义的。
如今,大多数主流计算机的RAM远远超过用户可能需要的内存,除非他们经常运行需要大量内存的应用程序。如果您因为日常用户案例(user case)而总是用完RAM,那么解决该问题的更好策略是为您的系统添加更多RAM。
与现代大多数计算机组件一样,RAM相对便宜!
鉴于您的计算机具有适当数量的RAM,可能仍然会有某天需要RAM分页。那时你会庆幸你有足够的头脑来确保分页不会超过必要的时间。
提高分页性能的一般提示(General Tips To Improve Paging Performance)
除了调整 Windows 自己的管理设置之外,您还可以做一些事情来提高RAM分页发生时的性能。最常见的建议之一是将页面文件设置为与(page file)操作系统驱动器(operating system drive)不同的驱动器。
问题是,如今大多数新计算机都将固态驱动器(state drive)( SSD ) 作为其主磁盘。虽然使用SATA 接口的(SATA interface)SSD(SSDs)仍然必须按顺序排列读取和写入请求,但它们比带有旋转盘片的机械驱动器快几个数量级。
这背后的逻辑是有道理的,因为硬盘驱动器必须对读取和写入请求进行排队。读/写磁头必须物理移动到存储数据的磁盘盘片的不同部分。(disk platter)因此,如果Windows试图从您的页面文件(page file)中交换信息,并且还试图将磁盘用于其他目的,那么它都会减慢到爬行速度。如果您将页面文件(page file)放在单独的硬盘驱动器上,那么这个问题就会消失。
因此,如果您的计算机中有两个SATA SSD ,那么将(SATA SSDs)页面文件(page file)放在辅助驱动器上仍然是有意义的。但是,如果您的主驱动器使用NVMe over PCIe 接口,则移动(PCIe interface)页面文件(page file)将一无所获,这是因为NVMe over PCIe是并行的,这意味着同时处理读取和写入请求。
在机械硬盘上,碎片也可能是一个问题。文件不是连续存储的,而是写入已删除文件留下的任何可用间隙中。这意味着随着文件的写入和删除,随着时间的推移,特定文件可能会以零碎的形式存在于整个驱动器中。
如果您的页面文件(page file)在物理上分散在整个磁盘盘片上(disk platter),则驱动器磁头需要更长的时间才能将它们放在一起。在固态驱动器上,这不是问题。如果您使用的是机械驱动器,则在首先对相关驱动器进行碎片整理后创建一个专用分区可能是解决此问题的好方法。通过将页面文件(page file)放在碎片整理的分区上,您将确保所有数据在物理上位于同一位置。
如何在 Windows 10 中优化分页文件(How To Optimize Your Paging File In Windows 10)
现在您已经很好地了解了优化页面文件的(paging file)上下文和规则(context and rules),是时候真正深入研究设置本身了。您可以根据您的具体配置决定使用哪些具体设置。
- 首先,打开开始菜单(start menu),然后在搜索栏中输入性能。(performance )
- 在设置类别下查找调整 Windows 的外观和性能,(Adjust the appearance and performance of Windows)如下面的屏幕截图所示。
- 性能选项(Performance Options)窗口现在应该打开。切换到高级( advanced )选项卡。
- 打开“高级(Advanced)”选项卡,单击“虚拟内存(Virtual memory)”部分下的“更改”。(Change )
- 虚拟内存窗口(Virtual Memory window)现在将打开。默认情况下,所有选项都是灰色的。所以首先我们必须取消选中自动管理所有驱动器的分页文件大小。(Automatically manage paging file size for all drives.)
- 每个驱动器的设置都可以独立管理。在上面的窗口中单击(Click)所需的驱动器以更改其特定设置。逻辑分区也将显示为独立驱动器。
- 选择自定义大小(custom size )以指定您自己的最小和最大页面文件大小(paging file size)。如果您根本不希望特定驱动器有分页文件,请选择“无分页文件” 。(No Paging File)
- 默认的自动行为是最小大小为实际RAM量的(RAM)1.5(size 1.5)倍。我们不建议(t recommend)您选择低于此的最小尺寸。以您喜欢的方式设置特定驱动器后,请记住单击“设置(Set )”以锁定这些选项。
如何在旧版本的 Windows 中优化分页文件(How To Optimize Your Paging File In Older Versions Of Windows)
在旧版本的Windows上调整和管理虚拟内存的方式与在(Windows)Windows 10上的工作方式几乎相同。具体来说,Windows 7,8 和 8.1 仍然具有完全相同的虚拟内存接口(memory interface)。
我们不会在本次讨论中包含任何比 Windows 7 更早的版本,因为应该没有现存的机器仍在运行这些不受支持的操作系统。
从您到达“性能选项(Performance Options)”窗口的那一点开始,该过程与上面概述的Windows 10步骤相同。(Windows 10)然而,到达那里有点不同。
- 转到开始(Start),然后转到控制面板。 (Control Panel. )
- 在那里,打开系统。(System.)然后点击高级系统设置(Advanced System Settings)。
- 在“系统属性”窗口的“(System Properties)高级(Advanced)”选项卡下,单击“设置”。(Settings.)
从这里您可以按照与上述相同的说明进行操作。如果您运行的是Windows 7,请考虑尽快升级。对Windows 7(Windows 7)的常规支持于 2015 年结束,扩展支持于 2020 年初结束。
寻呼博士表演(Paging Dr. Performance)
如果您更改其分页设置,大多数现代计算机的性能不会有任何不同,但稍作调整就可以在RAM有限的低端计算机上有所作为。即使在偶尔需要在内存方面超出其重量的高端机器上也是如此。
因此,如果您下次遇到计算机停止运行,很可能需要页面文件医生(file doctor)的访问才能重新设置。
How To Optimize The Paging File In Windows
Computers thesе days are pretty fast аnd the latest operating systems аre pretty good at keeping them that way. Gone are the days of the annual “format and reinstall” ritual most tech-savvy Windows users performed. That’s not to say your fresh new installation of Windows 10 will remain snappy forever though.
Some users may notice that if they alt-tab from a video game or swap between heavy-hitting apps such as video editors or 100-tab browser windows, things grind to a halt. This is a sign that you’ve run out of the ultra-fast Random Access Memory installed in your PC, and Windows now has to rely on your much slower secondary storage as an overflow.
The slowdown you’re witnessing occurs when Windows swaps information from your RAM chips with an overflow area known as the “page file”.
You can improve performance when you optimize the paging file in Windows 10.
What Is a “Paging File” Anyway?
Before we get to how you can optimize the paging file, let’s dig a little deeper into what the file is. If you’ve set up Windows explorer to show you hidden system files, you’ll find it at the root of your C drive with the name “pagefile.sys”. Assuming that your PC has the default configuration.
The pagefile has a reserved size and is divided into “pages” internally. This is the data format that RAM data is stored in for any operating system that uses RAM paging as a memory management method.
“Pages” are blocks of information that each have a unique address and exactly the same size. The software on your computer keeps a record of which pages have its information, so when it wants that information, it requests the page from Windows.
When your apps need more RAM than your computer physically has, it needs to use “virtual memory” which is exactly what the page file is. From the application’s point of view, it’s just more RAM. The only difference is that reading information from a hard drive is much, much slower than RAM. Which is rather the point of having RAM!
So if the page file is so slow, why even have it? Without a page file, your applications will crash or seriously malfunction, as any additional information that needs to be stored in RAM will simply be lost. Having a bit of slowdown to handle peak RAM demands is better than having the system go down as a whole.
OK, But Why Optimize The Paging File?
RAM paging is one of the oldest memory management methods in existence. Mainframe computers from the 1960s were already using it! It made a lot of sense when RAM was measured in dozens of kilobytes. It still made sense when 640KB of memory was “enough for anyone”.
These days most mainstream computers have way more RAM than the user is likely to need unless they routinely run memory-hungry applications. If you’re always running out of RAM because of your daily user case, a far better strategy to solve the issue is adding more RAM to your system.
Like most computer components in modern times, RAM is relatively cheap!
Given that your computer has the right amount of RAM, there may still come a day when something makes RAM paging necessary. At which time you’ll be thankful you had the presence of mind to make sure paging takes no longer than necessary.
General Tips To Improve Paging Performance
Apart from tweaking Windows’ own management settings, there are a few things you can do to improve the performance of RAM paging when it happens. One of the most common pieces of advice is to set your page file to a different drive than your operating system drive.
The thing is, most new computers have a solid state drive (SSD) as their primary disk these days. While SSDs using the SATA interface still have to queue read and write requests sequentially, they are orders of magnitude faster than mechanical drives with spinning platters.
The logic behind this makes sense, since hard drives have to queue requests for reads and writes. The read/write heads have to physically travel to different parts of the disk platter where data is stored. So if Windows is trying to swap information from your page file and also trying to use the disk for other purposes it will all slow down to a crawl. If you put your page file on a separate hard drive, then this problem goes away.
So if you have two SATA SSDs in your computer, then it still makes sense to put your page file on the secondary drive. If you have a main drive that uses the NVMe over PCIe interface however, you gain nothing by moving the page file That’s because NVMe over PCIe is parallel, which means read and write requests are handled simultaneously.
On mechanical hard drives, fragmentation can also be an issue. Files are not stored continuously, but written into any available gaps left by deleted files. This means that over time as files are written and deleted, a specific file might exist in bits and pieces all over the drive.
If your page file is physically scattered all over the disk platter, it takes longer for the drive heads to put it all together. On solid state drives, this is a non-issue. If you are using a mechanical drive, creating a dedicated partition after first defragmenting the drive in question can be a good way around this. By putting the page file on a defragmented partition, you’ll ensure all the data is physically in the same location.
How To Optimize Your Paging File In Windows 10
Now that you have a good understanding of the context and rules to optimize the paging file, it’s time to actually dig into the settings themselves. It’s up to you to decide what specific settings to use based on your specific configuration.
- First, open the start menu and then type performance into the search bar.
- Look for Adjust the appearance and performance of Windows under the settings category as you can see in the screenshot below.
- The Performance Options window should now open. Switch to the advanced tab.
- With the Advanced tab open, click on Change under the Virtual memory section.
- The Virtual Memory window will now open. All of the options are greyed out by default. So first we have to uncheck Automatically manage paging file size for all drives.
- Now you’ll see the following options open up for you to change.
- Each drive’s settings can be managed independently. Click on the desired drive in the window above to change its specific settings. Logical partitions will also show up as independent drives.
- Select custom size to specify your own minimum and maximum paging file size. Select No Paging File if you don’t want a particular drive to have one at all.
- The default automatic behavior is to have a minimum size 1.5 times the amount of actual RAM. We don’t recommend you choose a minimum size below this. Once you have set a particular drive the way you like it, remember to click Set to lock those choices in.
How To Optimize Your Paging File In Older Versions Of Windows
The way in which virtual memory is tweaked and managed on older versions of Windows is virtually identical to how it works on Windows 10. Specifically, Windows 7,8 and 8.1 still have exactly the same virtual memory interface.
We aren’t going to include anything older than Windows 7 in this discussion since there should be no extant machines still running these unsupported operating systems anymore.
The process is identical to the Windows 10 steps outlined above from the point where you have reached the Performance Options window. However, getting there is a little different.
- Go to Start, then the Control Panel.
- Once there, open System. Then click on Advanced System Settings.
- Under the Advanced tab of the System Properties window, click on Settings.
From here you can follow the same instructions as above. If you are running Windows 7, consider upgrading as soon as possible. Regular support for Windows 7 ended in 2015 and extended support ends early in 2020.
Paging Dr. Performance
While most modern computers aren’t going to perform any differently if you change their paging settings, a little bit of tweaking can make a difference on low-end computers with limited RAM. Even on high-end machines that occasionally need to punch above their weight in terms of memory.
So if you next encounter a computer grinding to a halt, it might very well be that it needs a visit from the paging file doctor to set things right again.