Re: Simplified version of read_binary_file (src/backend/utils/adt/genfile.c) - Mailing list pgsql-hackers

From Ranier Vilela
Subject Re: Simplified version of read_binary_file (src/backend/utils/adt/genfile.c)
Date
Msg-id CAEudQAqB1-EMd7JDoxHVYnB_z8WOsEGt8WsD-VgK_63NAgJAuQ@mail.gmail.com
Whole thread Raw
In response to Re: Simplified version of read_binary_file (src/backend/utils/adt/genfile.c)  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers
Em ter., 15 de set. de 2020 às 14:54, Alvaro Herrera <alvherre@2ndquadrant.com> escreveu:
I think you meant _IONBF instead of _IOFBF -- otherwise it's at odds
with the comment you add.  But what is the justification for that
addition?  I don't see us doing that anywhere else.
No.
_IOFBFFull buffering: On output, data is written once the buffer is full (or flushed). On Input, the buffer is filled when an input operation is requested and the buffer is empty.
_IONBF No buffering: No buffer is used. Each I/O operation is written as soon as possible. In this case, the buffer and size parameters are ignored.
_IONBF ignores buffer and size.

Without setvbuf, fread uses an internal buffer, default 4096 bytes (OS dependent).
If fread uses an internal buffer, then it needs a copy to the buffer provided by the function.
setvbuf, does the same as read function low level, copies directly to the final buffer.

regards,
Ranier Vilela

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Gripes about walsender command processing
Next
From: Robert Haas
Date:
Subject: Re: recovering from "found xmin ... from before relfrozenxid ..."