On 5/12/2011 07:58, Yoann M. wrote:
> Hello,
> I have data to process and to write into files progressively. The data
> files are in the end very large, but I append to them small strings. I
> suppose buffering the strings before apending to the file would be
> faster. I don't need the files to be written before the end of the whole
> process (i.e. I don't use their content).
> 
> I've searched for info about how File buffer its data but it seems we
> can not configure anything about this, did I miss something ?
> My first idea was to buffer everything myself, appending lines to a
> string, or an array of strings and write when I reach a big enough
> amount of data. But if File uses a buffer anyway, it would be a waste of
> time I suppose ?
> Do you have any advice to optimize the writing of large files ?

As mentioned, the file writes are already being buffered by lower
layers; however, if you are closing and reopening the files throughout
your processing, the buffers aren't helping you much.  Try to ensure
that you open each file only once and keep those file references around
to use until you know you're permanently done writing to each one.
Unless you have a large number of files to open, you shouldn't have to
worry about resource constraints on the number of concurrently open files.

-Jeremy