Streaming transport interfaces: input

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Oct 14 18:49:05 PDT 2010


On 10/14/2010 07:57 PM, Denis Koroskin wrote:
> In my original version there was a setbuf(f, null) call. I removed it
> because it had 0 impact on performance.
> I also tried using unistd open/read functions, that had zero impact, too

Yah, I looked more into the behavior of fread. At least on a couple of 
implementations that offer source, the implementation first copies 
whatever data is (if any) in the internal buffer, and then read the rest 
of the data straight into the remaining user-supplied buffer.

This means, if you consistently fread into a buffer, the internal 
buffers are never touched.

I stand corrected regarding the extra copy.

> (btw, opening file with O_DIRECT returned valid file descriptor, but
> read operations very failing with an invalid argument error).

I recall I've read a discussion where Linus was really down on O_DIRECT. 
Found it: http://kerneltrap.org/node/7563


Andrei


More information about the Digitalmars-d mailing list