Original Post
I'm wondering how files are handled in complex systems, like games with big detailed worlds. How does the system determine what to load and when to load it? For instance let's say there is a 60% probability we will need world1.pack in 25 seconds and the loading time is estimated as 15 seconds. At the same time we have a 50% probability that world2.pack will be needed in 20 seconds and the load time is estimated to 15 seconds. How does the system figure out what to do? It doesn't have time to load both, so if it tries we will definitely get a loading screen, but it will be done very quickly. If we choose to start loading one and then load the other then there is a certain probability that we will need a loading screen, but there is also a chance that we won't need a loading screen. Of course it could get much more complex. For example we may have known that world1.pack and world2.pack will never have to be loaded at the same time and that the user doesn't care as much for a little delay when reaching world2.pack because they will need to read some text there anyway. I know there are no definite answers to what to do based on certain constraints (at least not if we want a decent algorithmic complexity), but I'd guess that there are some algorithms which will provide a decent order of loading which based on the information it gets is able to almost optimally load the resources. When resources finally are in memory they will take up more space and at some point we will need to free them to make room for new resources or other applications, but how is this determined? Least recently used or least frequently used may be decent strategies in the general case, but in a game we are likely to know much more. We may have loaded both ogre.m3d and goblin.m3d 5 minutes ago and have used both the same amount of times, however we have reached the next level and we have a 10% higher probability of meeting ogre.m3d than goblin.m3d, in addition we are now near the ogre encampment and therefore this increases the probability of finding ogres by another 10%. Standard Least Recently Used and Least Frequently Used doesn't take things such as this into consideration, but have any games experimented with alternative caching algorithms depending on stuff like this? Also instead of freeing goblin.m3d or ogre.m3d we may choose to compress them instead so that they only take half the memory, but will be much faster to load then through file IO. No cache algorithms I'm familiar with takes grey areas like these into account, it's either stay in memory or get freed. So, I guess what I want to know is what approaches have been tried by others and if they proved to be useful. It doesn't necessarily have to be limited to games, I just thought I would use games as an example since we are on a game development site.