Re: Proposal: PqSendBuffer removal

2020-03-10 Thread Craig Ringer
faifaiOn Sat, 7 Mar 2020 at 02:45, Andres Freund wrote: > > Hi, > > On March 5, 2020 1:23:21 PM PST, Aleksei Ivanov wrote: > >Thank you for your reply! > > > >Yes, you are right there will be a separate call to send the data, but > >is > >copying data each time more costly operation than just

Re: Proposal: PqSendBuffer removal

2020-03-09 Thread Tom Lane
Andres Freund writes: > On 2020-03-07 13:54:57 -0500, Tom Lane wrote: >> This seems way overcomplicated compared to what I suggested (ie, >> just let internal_putbytes bypass the buffer in cases where the >> data would get flushed next time through its loop anyway). > Well, we quite frequently

Re: Proposal: PqSendBuffer removal

2020-03-09 Thread Andres Freund
Hi, On 2020-03-07 13:54:57 -0500, Tom Lane wrote: > Andres Freund writes: > > What I'm thinking is that we'd have pg_beginmessage() (potentially a > > different named version) initialize the relevant StringInfo basically as > > > (StringInfoData){ > > .data = PqSendPointer, > > .len =

Re: Proposal: PqSendBuffer removal

2020-03-07 Thread Tom Lane
Andres Freund writes: > What I'm thinking is that we'd have pg_beginmessage() (potentially a > different named version) initialize the relevant StringInfo basically as > (StringInfoData){ > .data = PqSendPointer, > .len = 0, > .alloc_offset = PqSendBuffer - PqSendBuffer > } This

Re: Proposal: PqSendBuffer removal

2020-03-07 Thread Andres Freund
Hi, On 2020-03-06 11:09:23 -0800, Aleksei Ivanov wrote: > *>Then we could get a StringInfo pointing directly to the current insertion > point in the send buffer. To support growing it, enlargeStringInfo would > first subtract the offset to the start of the allocation, and then > reallocate

Re: Proposal: PqSendBuffer removal

2020-03-06 Thread Aleksei Ivanov
*>Then we could get a StringInfo pointing directly to the current insertion point in the send buffer. To support growing it, enlargeStringInfo would first subtract the offset to the start of the allocation, and then reallocate that*. I thought about it yesterday and one issue with this approach

Re: Proposal: PqSendBuffer removal

2020-03-06 Thread Andres Freund
Hi, On March 5, 2020 1:23:21 PM PST, Aleksei Ivanov wrote: >Thank you for your reply! > >Yes, you are right there will be a separate call to send the data, but >is >copying data each time more costly operation than just one syscall? Yes, it's very likely to be more expensive to execute a

Re: Proposal: PqSendBuffer removal

2020-03-05 Thread Craig Ringer
On Fri, 6 Mar 2020 at 07:27, Aleksei Ivanov wrote: > > > What do you mean "just one syscall"? The entire point here is that it'd > > take more syscalls to send the same amount of data. > > I mean that it messages are large enough more than 2K we will need 4 syscalls > without copy it to the

Re: Proposal: PqSendBuffer removal

2020-03-05 Thread Aleksei Ivanov
*> What do you mean "just one syscall"? The entire point here is that it'd take more syscalls to send the same amount of data.* I mean that it messages are large enough more than 2K we will need 4 syscalls without copy it to the internal buffer, but currently we will copy 8K of messages and send

Re: Proposal: PqSendBuffer removal

2020-03-05 Thread Tom Lane
Aleksei Ivanov writes: > Yes, you are right there will be a separate call to send the data, but is > copying data each time more costly operation than just one syscall? What do you mean "just one syscall"? The entire point here is that it'd take more syscalls to send the same amount of data.

Re: Proposal: PqSendBuffer removal

2020-03-05 Thread Aleksei Ivanov
Thank you for your reply! Yes, you are right there will be a separate call to send the data, but is copying data each time more costly operation than just one syscall? Besides, if we already have a ready message packet to be sent why should we wait? Waiting for your reply, Best regards! On

Re: Proposal: PqSendBuffer removal

2020-03-05 Thread Tom Lane
Aleksei Ivanov writes: > I am really curious what was the original intention of using the > PqSendBuffer and is it possible to remove it now. > Currently all messages are copied from StringInfo to this buffer and sent, > which from my point of view is redundant operation. That would mean doing

Proposal: PqSendBuffer removal

2020-03-05 Thread Aleksei Ivanov
Dear community, I am really curious what was the original intention of using the PqSendBuffer and is it possible to remove it now. Currently all messages are copied from StringInfo to this buffer and sent, which from my point of view is redundant operation. It is possible to directly send