Command for Enabling/Disabling Win 10 "Disk Write Caching" (?) in Java

Joined
Dec 14, 2019
Messages
3
Reaction score
1
Hi Guys,
I have a strange question (not even sure that this is the right forum for that but let's see how it goes).

I am the editor of a photography review website and we test a lot of fast external hard drives (SSDs/NVMEs). Besides using synthetic benchmarks (Blackmagic Disk Speed Test / CrystalDiskMark 6) we also love to run real-world speed tests where we move several GBs of data from the computer to the drive and back.
Until now we have been manually doing this - dragging one folder to the drive and using a screen recorder to measure the time it took to complete the transfer and manually calculate the average transfer speed and do the same back to the computer.

We are now talking to a Java programmer to create a small program to automate this - it should be pretty simple I hope. We do have one problem though:
We discovered that windows 10 tends to keep in the memory recently transferred files (possibly in RAM or virtual memory - I am not sure). This means that if you transferred 1GB to a drive at 500MB/s the other way around could be seen to be much faster because windows already "knows" the files as they are already in memory.

I am not sure what is the name of the win 10 "feature" that does that - maybe Disk Write Caching? (not sure) and more importantly - is there a way to give a command in Java that will tell win 10 to temporarily disable this "feature" and re-enable it at the end of the test so that our measurements will be correct.

Many thanks in advance,
Iddo
 
Joined
Jan 27, 2016
Messages
794
Reaction score
80
not sure about java but this might help.
 

Regedit32

Moderator
Joined
Mar 4, 2016
Messages
3,609
Reaction score
1,140
I'm not sure your plan is wise.

The whole point of Windows using the Virtual Memory Manager to manage File I/O on your physical RAM is to reduce the number of writes to your Hard or SSD drive. If you have a number of smaller files ( smaller in size that your Read/Write speed ) these are collated into one single File in RAM, meaning they are Written to the Hard / SSD drive in one Write, thus reducing the wear of the drive.

As for using Java to manage file transfers, why not just use the built-in xcopy?

For example: xcopy C:\Pictures\*.* Z: /e /f /i /j where the /j flag prevents buffering
 
Joined
Dec 14, 2019
Messages
3
Reaction score
1
Hi Guys - thanks for the answer Snuffy - I'll show it to my programmer.

Regedit32 - I think you didn't read my original post - we are making a (real world) transfer speed TEST program. The whole point is to really see how fast files are copied from an internal drive to an external one and back (the same files). If win 10 saves those files into RAM or virtual memory - it will copy much faster and the whole point of the test is lost. This is not meant for day to day use - only for when we will be running the test program.

We still need confirmation from somebody who knows Windows well - is Windows " write caching" the reason behind what we have been experiencing? (i.e. faster read speed from an external drive after writing to it - with the same files)?

Iddo
 

Regedit32

Moderator
Joined
Mar 4, 2016
Messages
3,609
Reaction score
1,140
I think you didn't read my original post - we are making a (real world) transfer speed TEST program

In what real world scenario does anyone override the management of read/write?

The test you intend to do will produce meaningless results.
 

Regedit32

Moderator
Joined
Mar 4, 2016
Messages
3,609
Reaction score
1,140
is Windows " write caching" the reason behind what we have been experiencing?

In short, No it isn't.

Write-caching is how you maintain System performance on your computer, while Windows caches Write instructions to the external drive.

Depending on what setting you choose to use, you may need to use Safely remove hardware option to prevent Data loss, as this option will ensure the external drive is not released until all Writes are completed.

When completed, volatile memory is released to allow for use by another application / command.
 
Joined
Dec 14, 2019
Messages
3
Reaction score
1
ahh... you still don't seem to get it.
It is very simple - in the test we write to the external drive - testing the write speed of the drive. And then we copy the same files back to the computer (in theory we could use other files but how would they get to the external drive? you would need a different computer or copy and reset that computer to clear the memory each time - both not things that we would like to do for each test).

The idea of turning off the cache (or whatever is causing this phenomenon in win 10) is to make sure that when we do copy back the files we truly get the read speed of the drive and not the computer memory read speed.

I am still looking for a way to turn off this "feature" - I am pretty sure MS has some sort of option to do so but I need to know what is causing this first...
 

Regedit32

Moderator
Joined
Mar 4, 2016
Messages
3,609
Reaction score
1,140
The simplest way then would be to disabled Write Caching on both the internal hard drive and also, the external drive.

Assuming the external drive is connected to your computer do the following:
  • Right-click on Start and select Disk Management
  • Right-click the OS (drive letter) assigned to your internal hard drive and select Properties
  • Select the Hardware tab
  • Select the Internal Hard / SSD drive from list of drives, then click the Properties button
  • Select the Policies tab
  • Remove the check in the box next to Enable write caching on the device
  • Click OK

    Now to the external drive ( just to verify Windows 10 default to disable write caching on external drives is applied ):

  • Left-click the External drive in the list of drives, then click the Properties button
  • Select the Policies tab
  • If not already checked, check the radio button next to Quick removal (default)
  • Click OK
  • Click OK
  • Close Disk Management and any other open applications
  • Restart computer for policy changes to take affect

    Note: The default in Windows 10 is to enable Write caching on any internal drive, and to disable write caching on any external drive.
    Theoretically, you should not need to check each external drive's policies, however, some manufacturers choose to enable write caching by default on external drives, so alas you will need to check the policy for the external drive to make sure your testing is robust.

    You must restart computer for these changes to take affect, as you are activating a new policy.

    Having done this once, you will only need to check the External drive policies tab for you ongoing tests as the Policy on your internal drive will remain in place until you change it again.

On a side note, years ago Microsoft released an executable for management of Disk Caching called dskcache.exe

Whether this is still available I have no idea, however, your Programmer may be aware of this, or your IT staff member, especially if they are running a Server on your end. I'm assuming it is now deprecated, given the path they have taken with Windows 10.

Regards,

Regedit32
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top