Re: Strange Bitmapset manipulation in DiscreteKnapsack()

Поиск
Список
Период
Сортировка
От Andy Fan
Тема Re: Strange Bitmapset manipulation in DiscreteKnapsack()
Дата
Msg-id 87v87rz9lf.fsf@163.com
обсуждение исходный текст
Ответ на Re: Strange Bitmapset manipulation in DiscreteKnapsack()  (David Rowley <dgrowleyml@gmail.com>)
Ответы Re: Strange Bitmapset manipulation in DiscreteKnapsack()
Список pgsql-hackers
Hi,

David Rowley <dgrowleyml@gmail.com> writes:

> On Tue, 16 Jan 2024 at 16:32, David Rowley <dgrowleyml@gmail.com> wrote:
>>
>>
>> Now that 00b41463c changed Bitmapset to have NULL be the only valid
>> representation of an empty set, this code no longer makes sense.  We
>> may as well just bms_free() the original set and bms_copy() in the new
>> set as the bms_del_members() call will always pfree the set anyway.

I want to know if "user just want to zero out the flags in bitmapset
but keeping the memory allocation" is a valid requirement. Commit
00b41463c makes it is hard IIUC.  The user case I have is I want to
keep the detoast datum in slot->tts_values[1]  so that any further
access doesn't need to detoast it again, I used a 'Bitmapset' in
TupleTableSlot which shows which attributes is detoast. all of the
detoast values should be pfree-d in ExecClearTuple. However if a
bms_free the bitmapset everytime in ExecClearTuple and allocate the
memory again later makes some noticable performance regression (5%
difference in my workload). That is still a open items for that patch. 

> ...

> The functions's header comment mentions "The bitmapsets are all
> pre-initialized with an unused high bit so that memory allocation is
> done only once.".
> NOTICE:  DiscreteKnapsack: frees = 110, max_weight = 60, extra = 183.33%
> NOTICE:  DiscreteKnapsack: frees = 110, max_weight = 60, extra = 183.33%
>
> and by the looks of the code, the worst case is much worse.
>

Looks like this is another user case of "user just wants to zero out the
flags in bitmapset but keeping the memory allocation".

[1] https://www.postgresql.org/message-id/flat/87il4jrk1l.fsf@163.com

-- 
Best Regards
Andy Fan




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

Предыдущее
От: Masahiko Sawada
Дата:
Сообщение: Re: [PoC] Improve dead tuple storage for lazy vacuum
Следующее
От: Masahiko Sawada
Дата:
Сообщение: Re: subscription disable_on_error not working after ALTER SUBSCRIPTION set bad conninfo