Atomic I/O letters column #90
Originally published 2008, in Atomic: Maximum Power ComputingReprinted here January 25, 2009 Last modified 16-Jan-2015.
Cluster-frack
As far as I know, the bigger the cluster, the faster your hard drive can read a file, and the less fragmentation. Correct?
I brought a whopping great 1Tb Seagate server-edition HD, which I am planning to use only for files which are from 50Mb to several gigabytes in size. I am using Vista Ultimate 64-bit SP1 at the moment. What's the best allocation unit size to increase performance?
Will
Answer:
Very few PC tasks will run any faster if you increase the
NTFS cluster size from the default four
kilobytes.
You can go all the way to 64 kilobytes if you like - some partition-management apps, like Acronis Disk Director, let you change the cluster size quickly without reformatting - but only in unusual circumstances will this make any perceptible difference.
Disks that've been converted from FAT32 to NTFS are a special case. They'll have a cluster size of only 512 bytes, which actually will at least slightly reduce performance. If a file can fit in a single cluster, then it's impossible for that file to be fragmented, which means at least one less seek operation when the computer reads that file. If your cluster size is very small, though, as it will be on a FAT-to-NTFS converted volume, then pretty much everything will be fragmentable - though the system will still write files to contiguous clusters as much as it can.
(512-byte clusters will also bloat out the NTFS Master File Table {MFT}, with eight times as many entries as 4Kb clusters would require.)
There's a bit more to this, though, which you'll discover if you start looking into the amount of "slack" space that exists on an NTFS volume. Slack space is the wasted space between the end of a file's actual data, and the end of the last disk cluster it occupies. Unless you're using a rather unusual filesystem, only one file can have data in any given cluster, so the slack space at the end of each file is wasted.
On average, the slack space on a given drive will be one-half of the cluster size times the number of files. Windows makes it easy to see these numbers, in the Properties page for any collection of files; "Size" is the actual bytesize of whatever you selected, while "Size on disk" is the amount of disk space the files take up, including the slack.
On NTFS disks, though, the slack will be smaller than you'd expect. My C drive, for instance, is an NTFS volume with the default four-kilobyte clusters, and it at the moment contains 106,123 files. The simple estimate of slack space therefore gives two kilobytes times 103,123 of slack space - a bit more than 200 megabytes.
The actual bytesize of the files is 313,990,941,886 bytes, but the "Size on disk" number is only 314,062,303,132 bytes. The difference between those two numbers is only about 68 megabytes. That's about a third of what the simple estimate suggests.
This is because NTFS will actually store the whole of a small file in the Master File Table, if the file itself is smaller than the normal MFT data for the file would be. This reduces seeking and makes things faster, and it also greatly reduces the amount of slack space.
The storage capacity of the MFT remains at around 750 bytes per file no matter how big the cluster size is, though. So as NTFS cluster size gets bigger, the actual slack space will get closer and closer to the simple estimate.
Disk space has been so cheap for so long that slack space really doesn't matter much any more. But I'd still probably be wasting nearly a gigabyte of space on my C: drive, instead of less than 70 megabytes, if I stepped it up to 64-kilobyte clusters. And all I'd get in return would be zero fragmentation of all files smaller than 64Kb.
If you've got some oddball application that makes vast numbers of files that're all smaller than the maximum possible cluster size, but bigger than the default one, then setting the cluster size big enough that every one of those files will be able to fit in a single cluster will make disk access faster. This is probably not your situation, though.
NTFS cluster sizes larger than four kilobytes also, by the way, make it impossible to use NTFS compression. NTFS compression can actually, surprisingly, increase disk performance on modern computers that have CPU power to burn, especially for often-read, seldom-written things like application data, and/or if a drive's read speed isn't very high.
Compression won't do any good with incompressible data, though, so there's no point turning it on for a drive that's full of already-compressed image, sound or video files.
Also, align your computer north-south
Apparently, "Chinese hacker has managed to crack the maximum memory limit imposed by Microsoft on 32-bit Windows Vista. The trick is to transfer or transplant the more memory support feature in 32-bit Windows Server 2008 to Windows Vista, which use similar kernel code. Replace and overwrite the Windows Vista version of pkeyconfig.xrm-ms and tokens.dat with the version copied from Windows Server 2008."
Some people even claim that only one file needs to be replaced to do the trick.
Is this for real?
Jurgen
Answer:
I don't know whether this works or not (I'd suspect not, based on
this).
But if it does, all it's doing is enabling full Physical Address Extension (PAE)
in 32-bit Vista. This is probably not something you want to do.
32-bit Vista, like 32-bit Windows XP SP2 and later, doesn't really support PAE. You can turn PAE on, but you won't then actually be able to address any more memory. The only reason to turn PAE on is if you want to activate the no-execute (NX) or execute-disable (XD) features of modern CPUs, which require larger-than-32-bit memory addresses, to accommodate the extra bit that activates those modes. That's all PAE does on these operating systems.
The reason why PAE in XP and 32-bit Vista doesn't expand the memory map is that for a computer to work with PAE, all of its kernel-mode drivers need to be PAE-aware. If any of them aren't, the computer will hang.
Microsoft gave up on ever having enough PAE-aware drivers for mainstream WinXP computers, which is why, as of SP2 back in 2004, they abandoned the larger address space and changed the PAE mode for the mainstream 32-bit versions of Windows. Now it only gives you the same 4Gb maximum memory as non-PAE mode. Non-PAE-aware drivers then work fine.
Since 32-bit Vista is not meant to have a full-address-space PAE option, I imagine that many of its kernel-mode drivers - quite possibly including standard Microsoft ones - will also not be PAE-aware. So all sorts of important stuff will fail, and you probably won't even make it to the Windows desktop.
If you can set the system up with nothing but PAE-aware kernel-mode drivers, then "full" PAE would work just fine. But I'd be surprised if you could actually do that, and I'm doubtful about whether this hack actually activates full PAE anyway.
Just get 64-bit Vista in the first place. It pretty much works, these days.
I Can't Believe It's Not A Battery!
Do you know of a device that would replace 2 AA batteries with mains power? By that I mean a sort of dummy pack that would be inserted in place of the batteries, and plugs in? I'm thinking no, especially after about an hour of looking. If you know and have a minute I would sure appreciate your insight.
Greg
Now, Igor, we need only wait for the lightning to strike!
Answer:
No, I don't know of any off-the-shelf way to do this. It shouldn't be hard to hack up
a solution, though.
"Dummy batteries" actually do exist for a few devices - I'm thinking of my old Canon EOS D60 and its "DC coupler", here - but general-purpose ones that replace commodity batteries don't seem to exist.
It wouldn't be difficult to make one, though. All you'd have to do is connect a 2.4-to-3-volt regulated plugpack to a couple of dummy batteries, with the output terminals in the right place to make contact in the battery bay of the device.
(The "regulated" part is important, by the way; unregulated plugpacks output more than their rated voltage when they're less than fully loaded. Modern lightweight switchmode mains adapters should all be regulated, and thus not give a higher output voltage when lightly loaded, but it's still a good idea to check the unloaded output with a multimeter, if you're not quite sure.)
You actually can buy dummy batteries off the shelf, though they're not very easy to find. Making them is no big deal, though - pieces of wooden dowel plus nails or thumbtacks for terminals will do the job. You could also do it without any woodwork, by hacking wires into battery size adapters that're meant to let you use AAs in something that expects C-size or D-size cells, or use AAAs as AAs.
Note that if you want to put the battery cover back on after installing a contraption like this, you're probably going to have to cut some sort of notch in the cover for the wire to pass through. My old D60 had such a notch built in; for other devices you'll have to drill, cut or melt.
It's also often possible to get a good connection with battery-bay contacts by using alligator clips or integrated-circuit test clips, thus avoiding the dummy-battery problem entirely.
Or you could just hard-solder wires to battery-bay contacts, and attach an inline barrel socket or something to the end, so you can plug a normal wall-wart straight in.
The Windows-key poltergeist
Sometimes I come back to my Windows XP computer, and the Windows key is stuck down. So if I press E I get a new Explorer window, if I press L the computer locks, and so on.
Apparently this can happen because of some Terminal Services stuff or something; I'm not running Terminal Services, but whatever. The same pages that told me that also said that you can cure it by just pressing your Windows key a couple of times.
The killer is - MY KEYBOARD DOESN'T HAVE A WINDOWS KEY! So the only way I've been able to fix the problem is by rebooting.
WTF?!
Luke
A simple solution to a stupid problem.
Answer:
Use the On-Screen Keyboard, Luke.
Start -> Run (or just R, since your computer's convinced the Windows key is down...), and type "osk" and return.
(Fortunately, Windows-O, Windows-S and Windows-K aren't normally used for anything. Once this happened to me when I was running something that did use Windows-O as a hotkey; I had to copy and paste an O from my text editor.)
Now use the mouse to click one of the OSK's Windows keys a couple of times. Windows treats this exactly like pressing the physical key, so now your phantom pressed key will be unpressed once more.