[GRASS-dev] vector libs: file based spatial index
Markus GRASS
markus.metz.giswork at googlemail.com
Thu Jun 25 04:06:37 EDT 2009
Paul Kelly wrote:
> Markus:
>
>> What are memory-mapped files? Excuse my ignorance, I'm just a
>> self-trained coder (learning by doing).
>
> http://en.wikipedia.org/wiki/Memory-mapped_file
> A chunk of a disk file is directly mapped into memory so you can
> access it using normal pointers as if it was permanently in memory,
> and the OS transparently handles paging the relevant chunks of the
> file in and out of memory as required.
> It can be a useful and elegant way of managing access to large files a
> section at a time. For files small enough to be completely cached in
> memory the performance penalty over keeping the same data in memory
> (without a file) should be relatively small, and will be faster than
> accessing a file using conventional fopen()/fread() etc. functions.
> But how much of a performance gain it would give for very large files
> strongly depends on the nature of access to the file, which I know
> very little about in this case. E.g. for completely random access
> there might not be a lot of gain.
It is completely random, the next chunk to be read/written can be
anywhere in the file.
> But if there was random access only within a certain section of a
> file, that section could be mapped into memory and access would then
> be quite fast.
Does it make sense to always map a different section of the file? This
mapping would then need to replace each call to fread/fwrite because of
completely random access. I'm currently using the same method like for
the coor file which seems to work fine so far.
Markus M
More information about the grass-dev
mailing list