1

I've often wanted to create a really lean and optimized installation of Windows XP to use with VMware, disabling everything that's useless for the use case.

I've used quite a few days with nLite and have a really lean installation — not too aggressive (man, there are some caveats to tweaking and removing stuff with nLite!). The ISO is really awesome.

Now, in the spirit of the moment, I'm trying to put together a post-install batch script that'll apply the last handful of tweaks that I can't do with nLite but I'd still like to automate.

One such tweak is disabling the disk cache, since there's already caching going on in my host OS, so I'd much prefer that Windows didn't use any of its precious (and scarce) memory on disk caching.

It's easy enough to do using the GUI once everything is set up, but it'd be really cool if I could do it in my batch script. Either specifically turning off disk caching on each drive (I have two drives in my setup, one of them is persistent for swap and temp files so they don't waste space in snapshots), or perhaps there's a system service or similar that could be turned off, disabling caching system-wide in one go?

Thanks in advance for any ideas :)

Daniel

EDIT: Just to avoid the "disabling write caching is bad" debate (I'd really just like answers to my question :) Thanks).

ATTO benchmarks for no write caching (left) and write caching (right):

ATTO benchmarks for no write caching (left) and write caching (right)

EDIT 2: As per inspiration by @techie007, I've tried to determine the memory benefits from turning off caching in the first place. As you can see by these screenshots, nothing is really gained by turning off caching, at least memory-wise. Any change here would be entirely within statistical uncertainty.

For the record, I didn't quite know the best way to do this, so for both runs I rebooted the machine, let it settle for a bit, then ran ATTO and monitored mem usage during and after a run.

First two are with write caching enabled (during ATTO, then after):

enter image description here

enter image description here

Next two are the same scenario, but with write caching disabled:

enter image description here

enter image description here

5
  • The ATTO benchmarks are interesting for sure. Do you have any benchmarks showing the benefits that disabling the write cache gives? Is there measurably less memory usage? Less CPU usage? Less processes running? Nov 3, 2013 at 19:14
  • @techie007 — That's a really good question. I'm just assuming the effect would be less memory consumption. I'll do some tests and report back. Nov 3, 2013 at 19:20
  • @techie007 — As you can see from my edit, there's no real benefit at all! Thanks for making me test that :) Nov 3, 2013 at 19:37
  • Come to think of it, this sort of optimization seems to be a no-brainer to implement in the VMware Tools in the first place, so that's probably what's happening already. Nov 3, 2013 at 19:43

3 Answers 3

1

It's not possible. Windows doesn't really have a disk cache, it has a page cache, and the entire memory management subsystem is built around it. Even things like tracking what memory is active and what memory is inactive is managed through page protection on the page cache.

If the guest doesn't control caching, that means the guest has to pass on all disk accesses to the host so it will know what to keep in memory. Programs would run at a microscopic speed as a soft fault all the way to the host would be caused each time code traversed a page boundary. That's just the most obvious problem, there are plenty more that would be all kinds of horrific.

It would be like building a car every day to drive to work.

8
  • Hi David :) Thanks for responding! I think I may have phrased myself badly... You might be right about read caching, but at least we have an option to disable write caching (which is disabled by default for USB sticks, for instance). This is easily disabled via GUI, but I'd like to do it from the command line. And if it's possible (which you suggest not), the same for read caching. Cheers :) Nov 3, 2013 at 17:27
  • @DanielSmedegaardBuus That won't provide any benefits. Why do you think you'll get some benefit from disabling write caching? Nov 3, 2013 at 17:28
  • Well, because I already have write caching on my host. So any write operation would already return pretty much immediately, even when synchronized, as the host OS eventually gets the write request, throws it in the cache, and returns. Also, I'm on a 2013 Air with 700+ MB/s reads and writes. Plus, most of what I'd be writing would be to shared folders on the host via vmhgfs. Nov 3, 2013 at 18:20
  • @DanielSmedegaardBuus Having to pass the request through from the guest to the host would be anything but immediate. I think you're missing that the main point of the write cache is to aggregate lots of small writes into a few big ones. Nov 4, 2013 at 0:37
  • Pass the request through? What do you mean? The write request? How would that not get passed through either way? The only difference I can see is whether the writes are queued in guest RAM and then flushed intermittently to the host (cache), or the writes are queued in the host cache and flushed intermittently to disk. As my ATTO benchmarks display, I/O performance is the same. What do you mean about me missing the point of the write cache? My point is there's already a write cache on the host, so another one in the guest isn't gonna help much with performance. Nov 4, 2013 at 20:01
1

Well, doing this benchmarking actually turned out to be a rubber-ducking experience :)

This isn't a really good answer unless you know you're in a really particular use case, such as mine with VMware. Because you can do this via registry keys, but only if you know the path to the keys.

Here are the commands in my case:

reg add "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\IDE\DiskVMware_Virtual_IDE_Hard_Drive___________00000001\3030303030303030303030303030303030303130\Device Parameters\Disk" /v UserWriteCacheSetting /t REG_DWORD /d 00000000 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\IDE\DiskVMware_Virtual_IDE_Hard_Drive___________00000001\3130303030303030303030303030303030303130\Device Parameters\Disk" /v UserWriteCacheSetting /t REG_DWORD /d 00000000 /f

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\IDE\DiskVMware_Virtual_IDE_Hard_Drive___________00000001\3030303030303030303030303030303030303130\Device Parameters\Disk" /v UserWriteCacheSetting /t REG_DWORD /d 00000000 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\IDE\DiskVMware_Virtual_IDE_Hard_Drive___________00000001\3130303030303030303030303030303030303130\Device Parameters\Disk" /v UserWriteCacheSetting /t REG_DWORD /d 00000000 /f

That's for the two drives on the ide0 virtual adapter — the primary and the slave. At least in Fusion 6.

I'd much prefer to do a search for UserWriteCacheSetting and then disable each one, but ATM I don't know how I'd do that from the command line. If I find out, I'll update :)

1

And the final answer will be that yes, you can do it the (ugly) way I described before, but there's no benefit to doing it (at least with XP).

Memory usage is practially the same, as is performance.

So all in all, this is good news, as implementing it in my script was proving to be really difficult!

Thanks all for prodding at me ;)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .