Re: allocation limit for encoding conversion

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: allocation limit for encoding conversion
Дата
Msg-id 61177F69-B9A0-4A95-91A0-7705CA8BA661@anarazel.de
обсуждение исходный текст
Ответ на Re: allocation limit for encoding conversion  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi,

On September 24, 2019 3:09:28 PM PDT, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>Andres Freund <andres@anarazel.de> writes:
>> On 2019-09-24 16:19:41 -0400, Tom Lane wrote:
>>> Andres Freund <andres@anarazel.de> writes:
>>>> It's probably too big a hammer for this specific case, but I think
>at
>>>> some point we ought to stop using fixed size allocations for this
>kind
>>>> of work. Instead we should use something roughly like our
>StringInfo,
>>>> except that when exceeding the current size limit, the overflowing
>data
>>>> is stored in a separate allocation. And only once we actually need
>the
>>>> data in a consecutive form, we allocate memory that's large enough
>to
>>>> store the all the separate allocations in their entirety.
>
>>> That sounds pretty messy :-(.
>
>> I don't think it's too bad - except for now allowing the .data member
>of
>> such a 'chunked' StringInfo to be directly accessible, it'd be just
>> about the same interface as the current stringinfo.
>
>I dunno.  What you're describing would be a whole lotta work, and it'd
>break a user-visible API, and no amount of finagling is going to
>prevent
>it from making conversions somewhat slower, and the cases where it
>matters
>to not preallocate a surely-large-enough buffer are really few and far
>between.  I have to think that we have better ways to spend our time.

It'd not just avoid the overallocation, but also avoid the strlen and memcpy afterwards at the callsites, as well as
theseparate allocation. So I'd bet it'd be almost always a win. 

Andres

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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alexander Korotkov
Дата:
Сообщение: Re: Bug in GiST paring heap comparator
Следующее
От: Tom Lane
Дата:
Сообщение: Re: FETCH FIRST clause WITH TIES option