Click to See Complete Forum and Search --> : Default buffer size and buffer handling using Filebuf


Naouin
April 14th, 2008, 04:33 AM
Hi there,

Was just wondering if someone could help me out about two little questions I didn't find an answer so far.

Actually I'm asked to write some application reading/writing files from disk. This application is driven by a third party which requests reads and writes of defined bytes size. In other words, my application somehow serves files to a third party client !

As the third party client file service should be as fast as possible (at least in reading), my application needs to handle a buffer bigger than the read requests and allowing contiguous seeking in the files. Looking through standard library, I found filebuf which seems doing the job (never used it before).

My two questions are :

- Does anyone know about the default buffer size allocated to filebuf (I've already know there were fucntion allowing this buffer size to be changed)

- How does filebuf deal with the seeking? In other words, is there so to say a self managed working zone in the middle of the buffer with some data before and after it to allow seeking operation ?

Thanks in advance if someone is able to give me some info, or any relevant link to it

Cheers

olivthill
April 14th, 2008, 07:01 AM
Have a look at stdio.h.
In the one I have, the size of the buffer depends on an external variable, which is probably filled in the startup code or in a function of a library that I cannot see.

I remember, in the old days, it was worthwhile to program a buffer for IO. But nowadays, caches are already managed by the device driver of the hard disc, and by the operating system. So I'm not sure you can improve the speed. Anyway, good luck to you!

Naouin
April 17th, 2008, 10:41 AM
Thanks for the tip..

Had a look at stdio.h and muked a bit around, seems that the default size is optimum, so I'm gonna try it out ;-P

Lets hope it will fit to my needs so that I don't have to work something similar out on my own !