Googles appar
Huvudmeny

Post a Comment On: cbloom rants

"04-17-09 - Oodle File Page Cache"

9 Comments -

1 – 9 of 9
Blogger Brian said...

You are doing this for games right? Can you just build a statistical model from test runs of playing the game. Then just use that to predict what pages are least likely to be used?

April 17, 2009 at 1:05 PM

Blogger cbloom said...

You're quite mad, you know.

April 17, 2009 at 1:54 PM

Anonymous Anonymous said...

Or use that to predict what to prefetch...

April 17, 2009 at 2:36 PM

Blogger cbloom said...

(I was kinda joking with that last comment if it wasn't obvious)

So I am using game runs to generate the file access list to automatically schedule prefetches. But I really don't want to rely on that too much because game IO pattersn are not totally deterministic. Even level loads might pull slightly different stuff depending on user quality settings or whatever.

So for example if you recorded a run that went

A
B
C
D

and then you actually execute a run that goes

A
C
D
B

when you load C & D, the prefetched version of B should stick around waiting in memory because it will be used.

but if you execute a run that goes

A
C
D
E
...

and never loads B, then it needs to get dropped at some point.

April 17, 2009 at 2:51 PM

Blogger Ben Garney said...

Couldn't you implement some reasonable default behavior, then give the user a few hints to deal with the weird cases? For instance, assume that they will always lock things once, unless they hint in the unlock that they will want it again. The glory of the game scenario is you can assume intelligent hints - whereas the OS doesn't have that luxury. You could even have some dumb logic that would say "hey I noticed you're making me thrash these pages, pass this hint and it will save a lot of pain."

April 17, 2009 at 9:31 PM

Blogger Brian said...

If you test the games enough, your statistical models should be pretty decent.

Why not focus on getting good performance from the model, and then make some sort of default behavior that clears something if absolutely necessary (or it becomes obviously very old)?

April 17, 2009 at 9:53 PM

Blogger ryg said...

Hmm, the statistical model thing should work reasonably well if you do it on a per-"object" (file, asset, whatever) basis, but I'm skeptical about doing it on a page level. Page-granular statistics are brittle in the sense that they depend not only on which asset gets used when, but also on the exact version of that asset. This increases the turnaround time for what would otherwise be small content tweaks by a considerable amount since now you have to do test runs again. Changing a few pixels in a texture isn't a big deal no matter what, but e.g. changing the format for a HUD texture from DXT5 to ARGB does make a big difference in size and hence page layout, and so does changing animation compression settings for a chracter.

Blowing up a simple memory test run (which consists of loading all levels and checking whether there are any out of memory conditions, takes our QA maybe 2-3 hours) to a full representative playtest run (don't have exact numbers, but I'd assume a week at least to get reasonable values) is some serious friction for last-minute content tweaks.

April 18, 2009 at 1:35 AM

Blogger cbloom said...

Hmm.. so it seems that a lot of actual OS's just use this simple scheme :

keep pages in an LRU (or pseudo-LRU of some kind)

add prefetched pages to the top of the LRU (the MRU spot)

Then the only decision point is : if I want to do prefetch X, should I pop the LRU page or wait.

April 20, 2009 at 1:30 PM

Blogger cbloom said...

One annoying thing about doing my own page cache is the weirdness of the interaction with Windows cache.

On PS3 or Xenon or whatever this isn't a big issue, I can just do my thing.

On Windows, if I use buffered IO, then all the pages will go through Windows cache AND my cache. Kind of dumb. However, if I *don't* use buffered IO, then I lose the ability to keep pages in cache across program runs, and stdio will appear to beat me when you run the same test over and over because the pages will stay in Windows cache for it.

Pages staying in cache between program runs is of dubious use for games. However it is kind of handy for game developers, since we do run the same test over and over.

I've noticed some developers running 64 bit OS'es with 16 GB + , which gives them 10 GB of disk cache, which means that almost all of their file IO is coming from cache all the time, which sort of screws up all my assumptions. Obviously the average consumer is still nowhere near this, but they will be eventually I suppose.

April 20, 2009 at 3:03 PM

You can use some HTML tags, such as <b>, <i>, <a>

This blog does not allow anonymous comments.

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.