optimise your swapfile

7
H O T W I R E D! GET MORE FROM YOU RIG ¤ DIY WATER COOLING ¤ MAKE A CASE SENSOR ¤ CORE i 7 OVERCLOCKING ¤ MAKE A CASE SENSOR Issue 230 Sep 2009 £5.99 Outside UK & ROI £6.49 ISSUE 230 IT CAN’T RAIN ALL THE TIME EVEN MORE… NOVATECH X90 GTX PRO MESH SLAYER PC COOLIT DOMINO ASUS XONAR DS ZOTAC ION MOBO TRINE, ANNO 1404 Men of War PROTOTYPE: UNLOCK GENETIC SHACKLES ARMA 2: WAR HAS NEVER FELT SO REAL PERFORMANCE GEAR & GAMING GIVE WINDOWS A HUGE BOOST! P54 56 GAMES 12 gaming mice in the labs Pixel-perfect shooters FREE DVD “A BRUTAL CROSS BETWEEN DIABLO AND ROGER RABBIT Dave loots and shoots in Borderlands IT CAN’T RAIN ALL THE TIME WWW.PCFORMAT.CO.UK ISSUE 230 SEP 2009 THERE’S MORE… Gigabyte: behind the scenes Core i5 specs revealed Real Time Strategy classics! AMD: still best for budget gaming?

Upload: jeremy-ford

Post on 08-Feb-2016

246 views

Category:

Documents


0 download

DESCRIPTION

We were asked about it, therefore we thought we’d get some answers and when we say ‘some’, in fact we mean all the answers. It’s 0ne of those questions that raises it’s ugly head a couple of times a year, everyone makes some type of grunting noise, no real conclusion is reached and it’s forgotten about until the next bemused victim asks all over again. That question was about the Windows’ swap file, aka the page file, aka virtual memory. Over the years we’ve heard all the so-called best methods; no swap file, fixed swap file, system managed file, on the main partition, on its own partition, twice the system memory, three times the system memory, fragmented, defragmented, it’s worse than knowing how to kiss a girl for the first time.

TRANSCRIPT

Page 1: Optimise your Swapfile

HOTWIRED! GET MORE FROM YOU RIG ¤ DIY WATER COOLING ¤ MAKE A CASE SENSOR ¤ CORE i7 OVERCLOCKING

¤ MAKE A CASE SENSOR

Issue 230 Sep 2009 £5.99 Outside UK & ROI £6.49

ISSUE 230 IT CAN’T RAIN ALL THE TIME

EVEN MORE… NOVATECH X90 GTX PRO MESH SLAYER PCCOOLIT DOMINOASUS XONAR DSZOTAC ION MOBOTRINE, ANNO 1404

Men of War

PROTOTYPE: UNLOCK GENETIC SHACKLES

ARMA 2: WAR HAS NEVER FELT SO REAL

PERFORMANCE GEAR & GAMING

GIVE WINDOWS A HUGE BOOST! P54 56 GAMES

12 gaming mice in the labs12 gaming mice in the labsPixel-perfect shooters

FREE DVD

“A BRUTAL CROSS BETWEEN DIABLO AND ROGER RABBIT”

Dave loots and shoots in Borderlands

IT CAN

’T RA

IN A

LL THE TIM

E W

WW

.PCFOR

MAT.CO

.UK

ISSUE 230

SEP 2009

THERE’S MORE…Gigabyte: behind the scenesCore i5 specs revealedReal Time Strategy classics!

AMD: still best for budget gaming?AMD: still best for budget gaming?AMD: still best for budget gaming?

PCF230.cover 1 15/7/09 10:10:25 am

Page 2: Optimise your Swapfile

54 September 2009

Illus

trat

ion:

Pau

l Bla

chfo

rd

PCF230.feature1 54 16/7/09 8:20:22 am

Page 3: Optimise your Swapfile

Optimise Your Swapfi le

September 2009 55

Take page fi le optimising to the extreme, as

Neil Mohr benchmarks all the options

W e were asked

about it, therefore we

thought we’d get

some answers

and when we say

‘some’, in fact we

mean all the

answers. It’s one of those questions that

raises it’s ugly head a couple of times a

year, everyone makes some type of

grunting noise, no real conclusion is

reached and it’s forgotten about until the

next bemused victim asks all over again.

That question was about the Windows’

swap fi le, aka the page fi le, aka virtual

memory. Over the years we’ve heard all the

so-called best methods; no swap fi le, fi xed

swap fi le, system managed fi le, on the main

partition, on its own partition, twice the

system memory, three times the system

memory, fragmented, defragmented, it’s

worse than knowing how to kiss a girl for

the fi rst time.A huge reason for all of this, is the historical

way Microsoft has tackled the subject and

implemented virtual memory within Windows.

The fact so many people call it the wrong thing

is testament in itself to how badly understood

the subject is, particularly when you consider

virtual memory has been implemented in

Windows since version 3.0 and has been

around far longer than that generally in the

computing world.

So we decided it was about time we took a

comprehensive look at all the different

scenarios and see which, if any, is actually

optimal. Along the way we’ll learn a lot and as

we’ll see come up with some pretty novel

solutions that are immensely helpful beyond

just the single goal of getting an optimised

page fi le. So no matter if you think you know it

all or if you’ve never even heard of a page fi le

before, we think you’re going to learn

something new along the way. From how best

to set-up your page fi le, how to avoid the usual

pitfalls, to some intriguing tricks that are

just damn handy to know about.

PCF230.feature1 55 16/7/09 8:20:29 am

Page 4: Optimise your Swapfile

Below Access to the page fi le gets pretty hectic once memory starts getting tight

Right Oops. Sorry 32-bit users you’re stuck with 4GB of memory, less in fact

56 September 2009

When someone mentions swap fi le or page fi le to you what are they talking about? Well, technically Windows 9x has a WIN386 swap fi le, while Windows NT/2000/XP/Vista/7 use a PAGEFILE fi le. You can see why the two phrases are used interchangeably. However, the confusion doesn’t stop there. All of this is connected to the Windows virtual memory system, which is what we’re really talking about here. Virtual memory enables an OS to virtualise the physical memory space to another storage medium, usually a hard drive. To do this both the kernel of an OS and the processor it’s running on need to support the function. Over 20 years ago that might have been an issue, but not today. The whole point is that when an app requests a block of memory it may see itself being given a block of real memory. In reality only part, or none at all, of this could be ‘real’ with

the rest stored temporarily virtualised on the hard drive. If an app requests memory that’s stored off in this virtual world, a ‘page fault’ is generated, the virtual memory is swapped over to real memory in chunks called ‘pages’ and everything carries on.

The primary reason why this is a helpful thing is found back in the days when the amount of real memory a processor could access was limited to mere megabytes. The virtual memory system typically works on pages of 4K, which are swapped in and out of real

memory as a whole. This enabled a processor that could be limited to just 4MB of real physical memory to address potentially gigabytes of virtual memory, albeit with that data store on a hard drive. Even today systems with 2GB of memory can easily require virtual memory and with the majority of people running 32-bit versions of Windows, 4GB is the practical physical memory accessible. So while this is a lot of memory, running demanding apps, such as an email client, productivity suite, image editing software, virus checkers and so on – this can simply go.

So with virtual memory still an issue, even for PCs with 4GB of physical memory installed, the original question still stands: What is the best confi guration for your Windows page fi le, if you need one at all? The plan here is to test a whole range of

scenarios, some of them typical and others not so ordinary to reveal the optimal confi guration for you.

Our fi rst problem is just how to test and benchmark the swap fi le. We want to test a whole range of situations from 1GB installs to 6GB installs. That means a 64-bit Vista installation to keep everything consistent. As we need a low-memory situation we’ll base it on a 1GB Windows Vista installation.

To benchmark this we’ll need something that’ll require a large block of memory and manipulate that data.

To do that we run a benchmark that creates a large image fi le in memory and does various manipulations with it, from simply scrolling it, to rotation. We time how long it takes to complete each stage and get results from completing the image write and read, and rotation speed timed in seconds and MB/s depending on the operation.

You might have spotted something here, isn’t this just a drive-speed test? Well, yes and no. We are testing the speed of the swap fi le here, it just so happens that’s dependant on the speed of the medium the swap fi le is stored on, but still how the swap fi le is stored is going to play a part, just as much as what it’s stored on.

To the test chamber!To begin we need a control, which is going to be a standard Windows Vista 64-bit installation with a managed page fi le all running from the same partition on a Hitachi 250GB Deskstar drive. We’ll just install the OS, update the drivers and let Windows manage the page fi le in whatever manner it sees fi t. With just 1GB of memory the system creates a 1.3GB page fi le and at rest is using around 660MB of that with little actually running. Checking up on that fi le it’s already split into two fragments. Under benchmark conditions the page fi le increases to 3.2GB and has now fragmented into fi ve sections, remember this is on a clean 250GB installation so there are hundreds of gigabytes of empty space to use. You can imagine how on a real-life drive this fragmentation could become far worse over time as the available free space becomes limited.

This is the fi rst of what are the conventional ‘spinning disk’ tests and on the whole are what we’d expect the vast majority of people to be running. The next four tests are all based on different variations around single drive and twin drive confi gurations. The

Optimise your swap fi le

“The virtual memory system works on pages of 4K, which are swapped in and out of real memory as a whole”

PCF230.feature1 56 16/7/09 8:20:42 am

Page 5: Optimise your Swapfile

September 2009 57

Optimise your swap fi le

Enlarge TIME IN SECONDS: QUICKER IS BETTER

6GB MEMORY - SMALL PAGE 3

6GB MEMORY - NO PAGE 3.24

RAM DRIVE 7

DEDICATED SSD 49.08

SSD COMPLETE INSTALL 60.65

SPLIT OVER 2 DRIVES 116.16

USER DEFINED 169.28

DEDICATED SATA DRIVE 119.94

DEDICATED PARTITION 183

WINDOWS MANAGED 185.61

100 200 30020 40 60 80 120 140 160 180 220 240 260 280

Save TIME IN SECONDS: QUICKER IS BETTER

6GB MEMORY - SMALL PAGE 10.36

6GB MEMORY - NO PAGE 11.18

RAM DRIVE 17.24

DEDICATED SSD 27.73

SSD COMPLETE INSTALL 32.36

SPLIT OVER 2 DRIVES 72.52

USER DEFINED 110.19

DEDICATED SATA DRIVE 58.97

DEDICATED PARTITION 118

WINDOWS MANAGED 105.3

100 200 30020 40 60 80 120 140 160 180 220 240 260 280

Load TIME IN SECONDS: QUICKER IS BETTER

6GB MEMORY - SMALL PAGE 10.91

6GB MEMORY - NO PAGE 11.51

RAM DRIVE 11.81

DEDICATED SSD 71.04

SSD COMPLETE INSTALL 46.07

SPLIT OVER 2 DRIVES 69.49

USER DEFINED 95.97

DEDICATED SATA DRIVE 124.77

DEDICATED PARTITION 118.36

WINDOWS MANAGED 122.04

100 200 30020 40 60 80 120 140 160 180 220 240 260 280

Rotate TIME IN SECONDS: QUICKER IS BETTER

6GB MEMORY - SMALL PAGE 8.56

6GB MEMORY - NO PAGE 10.63

RAM DRIVE 16.21

DEDICATED SSD 102.37

SSD COMPLETE INSTALL 110.69

SPLIT OVER 2 DRIVES 218.39

USER DEFINED 239.39

DEDICATED SATA DRIVE 241.02

DEDICATED PARTITION 255.6

WINDOWS MANAGED 258.29

100 200 30020 40 60 80 120 140 160 180 220 240 260 280

Technical analysis –benchmark results:what they are andwhat they mean

As we’ve described we’re creating a large image in memory and manipulating it various ways, such as loading, saving, rotating and scrolling it. Running on a 1GB system this far exceeds the available free memory and forces Windows to rely on the page fi le for up to 3GB of extra memory. We time how long each operation takes as we can see how fast the system is at performing each one, plus the available bandwidth the page fi le has. For every scenario we performed multiple runs to help eliminate general system noise from the equation.

PCF230.feature1 57 16/7/09 8:20:51 am

Page 6: Optimise your Swapfile

A fi xed resultWhen it came to our ‘spinning disk’ results we were somewhat surprised and also vindicated. It’s obvious that a Windows managed page fi le is by far the slowest option to choose. The benchmark in itself may not be wholly real-world centric, we are testing the Windows managed scenario in the best possible conditions, as far as its concerned at any rate. So with it running up to 70 seconds slower than the fastest ‘spinning disk’ scenarios that’s a potential real drag, even more so under potentially more fragmented conditions. It’s also clear the fi xed same-drive partition solution isn’t a good choice either; any advantage gained by the guaranteed defragmentation is then lost by the physical partition separation and increase in drive head seek times, at

least being no better than a system managed option.

We’d also contest the idea that turning the page fi le off on a high-memory system helps improve performance. Our results actually point, if anything, to the opposite, while turning off the virtual memory makes a system vulnerable to a low-memory situation that can cause apps to crash and deny Windows the ability to create memory dumps in crash situations. Something that strikes us as a lose-lose-lose situation.

Previously we’ve always recommended a fi xed page fi le as the most sensible option. Windows enables you to specify a minimum size and a maximum, so it makes sense to create a large minimum size that you’re happy with. We’d recommend at least

2GB or better yet 4GB and then choose a larger maximum in case of emergencies, either 6GB or 8GB. Plus in light of our results if you can do this over two different drives then that’s going to be even better, ensuring you get the maximum speed out of your creaking drives.

Above The best way to store your page fi le is in a single defragmented state

58 September 2009

obvious fi rst test is to run a user-defi ned, fi xed-sized page fi le, this is the option that tends to be most favoured by people and the thinking behind it makes a lot of sense; creating a fi xed page fi le when Windows is fi rst installed eliminates the chance of fragmentation so provides an optimal single continuous fi le. If you make this large enough then apart from losing a few gigabytes of drive space there’s no real downside.

Our next scenario runs along the same lines but does so with the page fi le stored on its own partition on the same drive. This has been suggested as an optimal solution, but it has been pointed out that this unnecessarily encourages excessive amounts of drive head thrashing. As it ends up with the page fi le being physically removed from the working data. This certainly rings true for us, we’d imagine in certain situations it would be fi ne for large sequential writes and reads to the page fi le, but in reality we’d imagine this is less the case particularly when multitasking. Unfortunately, this is one area our benchmark won’t test very strongly, but we can see how it performs under our heavy single memory load.

Scenario four is running the page fi le off a secondary SATA hard drive. Before you get up in arms, it’s a similar 250GB 7,200rpm Hitachi Deskstar made within six months of the other drive, so raw performance should be very similar. Otherwise we’re running a fi xed user-defi ned page fi le as per the other scenarios. We’d expect performance here to be among the best of the ‘spinning disk’ test as the

dedicated SATA line will help eliminate drive thrashing due to separating the page fi le and system access to the drive. This leads on to the fi nal scenario which was added more as an intellectual test. We were interested to see if running two page fi les over two drives enabled Windows to perform any sort of intelligent cacheing or even RAID style spanning. If it balances storage against spare access capacity that could offer some benefi ts and the Microsoft Knowledge Base article seems to allude to that sort of practice.

A solid answerAfter testing we’re glad to see that indeed our preferred user-fi xed page fi le certainly performed well. To our surprise it outperformed the dedicated drive to a small degree in some tests, but it was certainly outpaced in others by the dedicated drive; the most notable being the save test. That aside it completed a number of tests 20 to 25 seconds quicker than the managed option. The big surprise is that the split page fi le was the one that really performed best overall. As you’d expect it at least matched the dedicated drive option in most cases, but in others certainly pulls out a good lead over the user-defi ned and dedicated drives options. While we have no direct reason for why this should be the case, as we’ve mentioned Microsoft alludes to the fact Windows does intelligently spread the load across multiple page fi les, depending on which drives are used the least. No matter whether that’s done historically or on the fl y, something seems to be working and for the majority of users

we’d imagine is the optimum and most achievable solution.

As much as we love our spinning hard drive friends and their penchant for storing grotesque amounts of video in all of its many fl eshy forms, they’re still damn slow. Those mirrored spinning surfaces may look shiny and attractive but get too close and the horrifi c realisation that their access times can be measured in geological ages claws at our souls as much as our own refl ected twisted images. Which is to say they’re a bit slow. While still expensive in comparison to ‘spinning disks’ you can certainly pick up 32GB solid state drives for under £100 now and even the more recent 80GB drives are slipping into the £200 price bracket. This defi nitely puts a solid state boot-drive solution into the price range of most people. The question is what’s the impact of this technology on page fi le performance?

Optimise your swap fi le

Switching off the page fi le quickly made our benchmark throw up this error

PCF230.feature1 58 16/7/09 8:21:8 am

Page 7: Optimise your Swapfile

Fixing the fi leTo get the most from your page fi le you’ll need to know how to control it. From Windows 95 to Windows 7, the page fi le has always been controlled through the Advanced settings section of the System Properties Control Panel, press [Windows] + [Break] to open this. Vista and 7 users will also need to click the Advanced system settings link. For all versions of Windows XP/Vista/7 in the Performance section click the ‘Settings’ button, choose the Advanced tab and in the Virtual memory section click the ‘Change’ button.

Here you’ll see a list of all eligible connected drives, what, if any, page fi le they currently have and Windows’ own recommendations. Windows Vista and 7 systems have an additional tick box at the top of the dialogue box that forces a system managed page fi le and will need to be cleared. Selecting each drive enables you to create a custom-defi ned page fi le, enable Windows to

manage its own fi le or to force no page fi le at all. The important thing is to make sure you click the Set button after each selection, otherwise any changes won’t be permanent.

Windows has a couple of foibles that are worth pointing out. By default it’ll create its system managed page fi le on the boot drive and it’ll opt for 1.5 times the physical memory, moving up to three times this depending on the memory loads. It won’t take advantage of other partitions or drives with more space. This is particularly odd when you consider that even Microsoft admits this isn’t an optimal confi guration over at this Knowledge Base article support.microsoft.com/kb/314482. It advises that running the page fi le on a separate hard drive is a better option, but it does go on to state that a page fi le on the boot drive is also required for error logging. While alongside of this Windows has its own

algorithms for determining which drives are used least and will priorities those for page fi le usage over other partitions or drives.

Right Here we see PCMark giving up when the page fi le is turned off

We decided to run two scenarios, as we’ve already established that a user-defi ned fi xed page fi le is the way to go, the two options we want to test are with a full Windows installation and as a plain drive with a fi xed page fi le on it. As you’d hope the up-to-date solid state architecture effi ciently smothers

the randomness of the mechanical drives, in most cases yielding double the performance, with a halving in most times and a three-fold increase in throughput on the scroll test. As you’d also expect the dedicated driver option also offered a little improvement in performance, though the sheer effi ciency of the solid state access system meant the Windows managed fi le was almost as effi cient.

Stacks of memoryWe fi nally come to that scenario we’ve seen a lot of people with a sizeable compliment of RAM touting: turning off virtual memory and doing away with a page fi le. What we would like to know is just how good a thing it is! To answer these fi nal questions we took a high-memory system that involved installing 6GB of memory into our 64-bit test system.

Clearly the fastest scenario will be running without any page fi le at all, right? It appears not. By accident we actually left the page fi le on and ran the benchmark cycle. Spotting our mistake we reran the test with the page fi le off, to discover it was slower. Only slightly slower, but still slower.

Either way the results are still staggering in terms of the speed increase over any dependency on using the page fi le, it’s a ten-fold reduction in wait times and a 40-fold increase in throughput over even the solid state drives, never mind the 100-fold plus increase in throughput over the spinning disks. Again, more from interest than any practical solution we created a 5GB RAM drive and created a fi xed page fi le within this to see what type of overhead that would impose. It pretty much halved the throughput speed showing there is something of an overhead involved with simply running the page fi le, but in context of the slow drives it’s normally stored on that’s not usually an issue.

So what have we learnt? Clearly having lots of memory is a great thing, if you can eliminate the need for Windows to use the page fi le your life

is going to be much improved. Having no page fi le, while it might seem clever on the face of it could slow things down ever so slightly and if you do ever hit a low-memory situation it’s going to cause problems. The page fi le is also used as a dump area if a crash occurs, turning it off eliminates that feature. We can see anyone with a solid state drive is going to be fi ne either with a managed or fi xed page fi le. For the rest of us the best solution is to opt for a user-fi xed page fi le and as many people more than likely have a second drive, choose to store two user-fi xed page fi les on both drives. If swapping does occur at least this should keep times to a minimum. ¤

September 2009 59

Optimise your swap fi le

“Clearly the fastest scenario will be running without any page file at all, right? It appears not”

This simple system setting has served us proud for many a year

PCF230.feature1 59 16/7/09 8:21:22 am