[GRASS5] segment lib speed patch

Glynn Clements glynn at gclements.plus.com
Tue Jun 28 07:41:07 EDT 2005


Markus Neteler wrote:

> to speed up the creation of segments in lib/segment/format.c,
> a colleague from ITC-irst proposes the attached patch.
> I used it locally for quite a while without having problems.
> 
> I would like to hear you opinion:
> - any objections to include it (removing the old version)?
> - should it be conditionalized for GNU/Linux only or
>   anything else (means: modifying the current condition ORIG)?

It doesn't need to be conditionalised upon anything; it will work on
any Unix. On most Unices, you can simplify the code further by using
ftruncate() (although ftruncate() exists on all POSIX-compliant
systems, some older Unices don't allow you to use it to lengthen a
file).

The only potential objection is that the new version doesn't allocate
disk storage for the file; storage will be allocated dynamically as
blocks are actually written. This could result in zero_fill()
succeeding but a subsequent call to write() failing with ENOSPC ("No
space left on device").

Whether that's an advantage or disadvantage is a matter of preference. 
If you're dealing with sparse data, the reduced storage is an
advantage. If you aren't, it's of no benefit, and it would usually be
preferable to fail during initialisation than at an intermediate
stage.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list