Is write-through better for gaming than write-back?

BoozeHobo

Member
Mar 23, 2017
30
7
21
I found this somewhere:
The benefit of write-through to main memory is that it simplifies the design of the computer system. With write-through, the main memory always has an up-to-date copy of the line. So when a read is done, main memory can always reply with the requested data.

If write-back is used, sometimes the up-to-date data is in a processor cache, and sometimes it is in main memory. If the data is in a processor cache, then that processor must stop main memory from replying to the read request, because the main memory might have a stale copy of the data. This is more complicated than write-through.

Also, write-through can simplify the cache coherency protocol because it doesn't need the Modify state. The Modify state records that the cache must write back the cache line before it invalidates or evicts the line. In write-through a cache line can always be invalidated without writing back since memory already has an up-to-date copy of the line.

One more thing - on a write-back architecture software that writes to memory-mapped I/O registers must take extra steps to make sure that writes are immediately sent out of the cache. Otherwise writes are not visible outside the core until the line is read by another processor or the line is evicted.
(I couldn't make heads or tails of the above, but it sounds experty)

In windows, if you go device manager, then disks, then pick the drive you're using, then go to the policies tab your disks always seem to be using "Better Performance", which means it's using write-back. To use write-through you'd have to instead set your disk to "Quick Removal". The only problem is windows 10 won't let me set it to Quick Removal, cause whenever I choose it Windows says it needs to restart to apply the changes but after the restart it always defaults back to Better Performance option.

I'm curious if write-through can have any benefits in many games where I get random intermittent stutters. Maybe using write-through will fix those?
 

Merad

Platinum Member
May 31, 2010
2,586
19
81
The quote is talking about RAM, not hard drives. Most modern CPUs contain a set of registers (16 on x86-64 processors) that store the values it is currently work with, and then three levels of of temporary memory (L1, L2, and L3 cache) that sit between the registers and RAM. L1 cache is very small and very fast, L2 is larger but slower, and L3 is larger but slower than L2. This is all done because accessing RAM is very, very slow compared to the speed of the CPU. The quote is referring to what happens when a value changes - the write through strategy means that the new value is immediately updated on all three levels of cache and is updated in RAM. In most cases write back is going to be the fastest approach by far, because write through requires writing main memory for every. single. write., and touching main memory is orders of magnitude slower than just writing to cache.

Anyway. Most games very rarely write to the hard drive except when you're saving your game. I would be extremely surprised if the setting you're asking about makes a measurable difference in game performance.
 
  • Like
Reactions: BoozeHobo

BoozeHobo

Member
Mar 23, 2017
30
7
21
The quote is talking about RAM, not hard drives. Most modern CPUs contain a set of registers (16 on x86-64 processors) that store the values it is currently work with, and then three levels of of temporary memory (L1, L2, and L3 cache) that sit between the registers and RAM. L1 cache is very small and very fast, L2 is larger but slower, and L3 is larger but slower than L2. This is all done because accessing RAM is very, very slow compared to the speed of the CPU. The quote is referring to what happens when a value changes - the write through strategy means that the new value is immediately updated on all three levels of cache and is updated in RAM. In most cases write back is going to be the fastest approach by far, because write through requires writing main memory for every. single. write., and touching main memory is orders of magnitude slower than just writing to cache.

Anyway. Most games very rarely write to the hard drive except when you're saving your game. I would be extremely surprised if the setting you're asking about makes a measurable difference in game performance.
Just so I can be sure, is there a way to force windows to use write-through?
 

CountZero

Golden Member
Jul 10, 2001
1,796
36
86
The quote you gave lists only design time benefits to write-through, not a single performance benefit is mentioned. It offers design simplification not performance benefit (at least not in a typical system).

There is no way I can imagine windows would you let you change the way memory/cache is used at such a fundamental level. If such an option existed at all it would be at the BIOS level and I highly doubt it exists there.

To elaborate on why there isn't a performance help. Imagine the following:
Register takes 1 cycle per write
L1 takes 2 cycles per write
L2 takes 20 cycles per write
L3 takes 200 cycles per write
Main Memory takes 20000 cycles per write

Do you want to wait for 20000 cycles every time you write to memory?
 
  • Like
Reactions: BoozeHobo

Merad

Platinum Member
May 31, 2010
2,586
19
81
Just so I can be sure, is there a way to force windows to use write-through?

No idea, I've never messed with that settings. That would probably be a better question for the operating system forum.

You're taking the wrong impression from the quote though. Write through is the simpler method, but it is slower - whether you're talking about memory or the hard drive.

There is no way I can imagine windows would you let you change the way memory/cache is used at such a fundamental level.

OP is referring to hard drive write caching settings, which are available through the drive's properties in device manager.