Create a cached window file API.
To efficiently read pack files from disk we need to access different
sections of the file repeatedly, and we need random access while we
do that. Using a small buffer on top of a seekable file (like we have
been doing) is very slow, as we have to keep rereading relevant parts
of the file and we never get to ammortize the operating system IO costs
over the total bytes being accessed.
So instead we want to use a strategy like what core-git will likely
move to: maintain a cache of large chunks of the file, where those
large chunks are either read directly into byte[]s or were mapped
using the operating system's virtual memory manager.
This is probably something that should just be shipped with Java,
but doesn't. I explicitly stayed away from using java.util collections
such as LinkedHashMap as I really don't want to pay an object allocation
penalty (on the search key) on every lookup in the cache, as that part
will be a critical part of our pack data access loop.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>