Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

With a custom binary file format for archives that is structured similiar to Valve's VPK files I have a Game.index.gcf which holds information about all files and where exactly they are stored. I can split up and say, that the /Assets/Maps and /Assets/Scripts folders should be stored in Game.000.gcf while the bigger /Assets/Music folder could be split up into Game.001.gcf and Game.002.gcf. This should boost performance but only if done right. Moreover with updates I could say, just update this particular split archive and not the entire archive (when storing everything in one really huge a file).

As of yet, I don't know how to write such an adaptive algorithm which automatically decides the best way to split all archives and files. What aspects should I keep in mind and what should I be aware of when creating these? Do you have any suggestions?

share|improve this question
    
Why do you think this would boost performance? If you mean that there is no need to read the whole file, then proper use of seeks within a large file would have the same effect. –  Liosan Mar 28 '13 at 8:15
    
Besides, an "adaptive algorithm" means that archive layout would change often whenever you add new content, which doesn't sound fun even for the dev version. –  Liosan Mar 28 '13 at 8:16
    
@Liosan: I was thinking that seeking to and reading a small file in a 5MB archive is much more efficient than doing this in one of 1GB size which hold everything. (the sizes are chosen arbitrary) Am I wrong? –  Christian Ivicevic Mar 28 '13 at 11:47

1 Answer 1

up vote 0 down vote accepted

I wouldn't expect a performance difference between reading a 4KB chunk from a small file or from a big file, assuming both are properly implemented.

For your 1GB "huge" file, you could hold an in-memory index containing available filepaths stored in the VFS (or hashes of them, to store space). Each index entry would just contain the offset in the file - a read is a easy seek, just read the part of the file that you need. If you have compression applied, make sure each file is compressed separately or in series of smaller files, so that you can decompress your chosen file with little effort.

From the operating system point of view, it doesn't really make any difference if the files are 5 or 500 MB. Small files, that is below 10KB or so, actually have a negative impact (because finding the file and opening it also takes time).

I don't see any immediate advantage of using small archives instead of one big one, performance wise. In fact, many AAA games use this method of huge monolithic files.

The "easy patching" argument still applies, but then I guess you don't need any fancy "packer" algorithm.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.