topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday April 19, 2024, 3:12 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Disk write cache (Windows XP)  (Read 8870 times)

Giampy

  • Participant
  • Joined in 2009
  • *
  • Posts: 444
    • View Profile
    • Read more about this member.
    • Donate to Member
Disk write cache (Windows XP)
« on: May 27, 2012, 07:43 AM »
Hail!
The so called "Disk write cache" speeds up the system but I disabled it as certain data get lost if a power failure occors, even if we had performed a Save command.
Is there a way to keep that useful cache and contemporaneously to be sure that every Save command is effective?
"A refrigerator without beer is like a body without soul"

vlastimil

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 308
    • View Profile
    • Donate to Member
Re: Disk write cache (Windows XP)
« Reply #1 on: May 27, 2012, 10:52 AM »
I fear the answer to your question is no. You either wait for the write operation to finish and then you are sure that the data really is on the disk or you let the system write the data a few moments later and have a better performance.

Getting a fast SSD would help  ;)

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,612
    • View Profile
    • Donate to Member
Re: Disk write cache (Windows XP)
« Reply #2 on: May 27, 2012, 04:29 PM »
And getting a battery backed power source helps even better :Thmbsup:

Giampy

  • Participant
  • Joined in 2009
  • *
  • Posts: 444
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Disk write cache (Windows XP)
« Reply #3 on: May 28, 2012, 07:08 AM »
...or you let the system write the data a few moments later

That's just the point: the system may not save data within a short time. Sometimes it takes even hours. At least two times I heard mprecations from two colleagues of mine when the power failed and they lost hours of job.
"A refrigerator without beer is like a body without soul"

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,643
    • View Profile
    • Donate to Member
Re: Disk write cache (Windows XP)
« Reply #4 on: May 28, 2012, 07:45 AM »
That's just the point: the system may not save data within a short time. Sometimes it takes even hours. At least two times I heard mprecations from two colleagues of mine when the power failed and they lost hours of job.

That doesn't sound like the Disk Write Cache, that sounds more like they don't have a program that does auto-saves every x minutes, (or that they are not saving the data every so often).

You can go into the Device Manager->Disk Drives and then right-click to open the Properties window for each drive, then go to the Policies tab and turn off Enable write caching on the disk.

SAMSUNG HD103UJ Properties_2012-05-28_22-41-23.jpg

This will at least enable you to test whether data is still lost after a few hours - if it is, then you have another problem.

You should also check the Event Log for any disk related errors or warnings, (eg. Delayed Write Fail).
« Last Edit: May 28, 2012, 07:50 AM by 4wd »

vlastimil

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 308
    • View Profile
    • Donate to Member
Re: Disk write cache (Windows XP)
« Reply #5 on: May 28, 2012, 08:38 AM »
Agree with 4wd. Even with write caching enabled, the data should be physically on the disk within few seconds. The problem you are describing is likely related to something else, maybe the application they are using.

Giampy

  • Participant
  • Joined in 2009
  • *
  • Posts: 444
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Disk write cache (Windows XP)
« Reply #6 on: May 29, 2012, 07:02 AM »
(or that they are not saving the data every so often).
The problem you are describing is likely related to something else, maybe the application they are using.

Those colleagues perfectly know that it's necessary to save every while. I can't believe that they forgot to do it.

Trouble of colleagues apart, you assert the data are written to the HD within a short time anyway, even if the cache is enabled. But are you sure? If that were true, then I don't understand why Microsoft and other people report the dangerousness of an enabled cache (i.e. loss of data).
"A refrigerator without beer is like a body without soul"

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,643
    • View Profile
    • Donate to Member
Re: Disk write cache (Windows XP)
« Reply #7 on: May 29, 2012, 08:47 AM »
Trouble of colleagues apart, you assert the data are written to the HD within a short time anyway, even if the cache is enabled. But are you sure? If that were true, then I don't understand why Microsoft and other people report the dangerousness of an enabled cache (i.e. loss of data).

The thing is you have said that the system loses data during a power failure, hours after it was supposedly written.  If it was the case that Windows only flushed the cache every few hours you would have had literally thousands, (if not millions), of customers screaming their heads off about the unreliability of Windows disk writes.

I live in an area that is subject to reasonably frequent power failures, (high winds, overhead power lines and trees don't mix), and I can say that with both XP and Win7 I have never lost data that was written hours previously, (I don't have a UPS - never needed one).  One of my machines does nothing but download 24/7 and it never loses more than 8MB of data, (size of the cache of the program), and that 8MB is written out to the drive every minute or so.

From Microsoft: File Caching

The frequency at which flushing occurs is an important consideration that balances system performance with system reliability. If the system flushes the cache too often, the number of large write operations flushing incurs will degrade system performance significantly. If the system is not flushed often enough, then the likelihood is greater that either system memory will be depleted by the cache, or a sudden system failure (such as a loss of power to the computer) will happen before the flush. In the latter instance, the cached data will be lost.

To ensure that the right amount of flushing occurs, the cache manager spawns a process every second called a lazy writer. The lazy writer process queues one-eighth of the pages that have not been flushed recently to be written to disk. It constantly reevaluates the amount of data being flushed for optimal system performance, and if more data needs to be written it queues more data. Lazy writers do not flush temporary files, because the assumption is that they will be deleted by the application or system.

So, in theory, given a finite amount of data that has been cached, it should all have been flushed to the drive after ~8 seconds.

This is for data written from the Windows RAM based cache to the drive, the drive reports that the data has been written even though it may be sitting in the drives cache and not on its physical platters.

ie. Disabling the Write Cache under the Drive Properties will not disable the drives onboard cache, AFAIK.

If data is being lost hours after it was supposedly written, then given that no one has tampered with Windows cache manager settings it seems likely there is another problem.

Have you looked at the Event Log for disk based errors/warnings and possibly any related to specific programs that lose data, (do those programs have error logs - if so, check them) ?
Is it only happening to one computer ?

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Disk write cache (Windows XP)
« Reply #8 on: May 29, 2012, 03:00 PM »
Just as an aside, I don't know if any MS servers are still configured this way, but I remember when I ran NT 4 Server I got a kick out of the fact that every little disk write I could hear the data flushed to the HD. If I wrote a 10 byte .ini file I could hear it write to the HD right away.  Made me laugh.

But like the other responses, I don't understand how you could cache disk data for hours. For one thing the file system cache would be using up most of the ram on the system. As for the UPS, only business industrial size could maintain power for a long period of time. The home use types typically can keep you going for several minutes. Long enough to save your data and shut down. If it took hours, none of those UPS would work.

I would invest in a UPS. Even with write caching disabled, it the power goes out in the middle of the disk write, it's going to scramble the data. It's worth it, even if you can only afford one of the cheapie brands.

edit: the only situation that comes to mind where losing a few seconds of disk write might "destroy hours worth of work" would be some long math calculation. Say if you were calculating an MD5 Sum for a 800 GB file. Unless you process it all, it's gone.  Seems it would have to be a pretty specialized circumstance similar to that case.

« Last Edit: May 29, 2012, 03:07 PM by MilesAhead »

Giampy

  • Participant
  • Joined in 2009
  • *
  • Posts: 444
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Disk write cache (Windows XP)
« Reply #9 on: May 31, 2012, 06:30 AM »
Inside your replies I find encouraging words. I get to thinking those warnings about the dangerousness of the cache are a little alarmist or I have given too much weight to them.
"A refrigerator without beer is like a body without soul"