Re: Proposal: PqSendBuffer removal

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org,Aleksei Ivanov <iv(dot)alekseii(at)gmail(dot)com>,Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Proposal: PqSendBuffer removal
Date: 2020-03-06 00:39:42
Message-ID: F59C65BF-7286-4711-B5C9-A4614BE9C1EC@anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On March 5, 2020 1:23:21 PM PST, Aleksei Ivanov <iv(dot)alekseii(at)gmail(dot)com> 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 syscall in a lot of cases. They've gotten a lot more expensive with all the security issues.

>Besides, if we already have a ready message packet to be sent why
>should we
>wait?

In a lot of cases we'll send a number of small messages after each other. We don't want to send those out separately, that'd just increase overhead.

But in some paths/workloads the copy is quite noticable. I've mused before whether we could extend StringInfo to handle cases like this. E.g. by having StringInfo have two lengths. One that is the offset to the start of the allocated memory (0 for plain StringInfos), and one for the length of the string being built.

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 can imagine that bring useful in a number of places. And because there only would be additional overhead when actually growing the StringInfo, I don't think the cost would be measurable.

Andres
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2020-03-06 00:57:57 Re: Psql patch to show access methods info
Previous Message Tomas Vondra 2020-03-06 00:15:56 Re: Additional improvements to extended statistics