Re: plenty code is confused about function level static

Поиск
Список
Период
Сортировка
От Ranier Vilela
Тема Re: plenty code is confused about function level static
Дата
Msg-id CAEudQAoB_2_ejJUFz=LFX7_nK6SgHFei_+cmoa4X43UfPp4gsA@mail.gmail.com
обсуждение исходный текст
Ответ на plenty code is confused about function level static  (Andres Freund <andres@anarazel.de>)
Ответы Re: plenty code is confused about function level static  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
On 18/04/2024 00:39, Andres Freund wrote:

>We have a fair amount of code that uses non-constant function level static
>variables for read-only data. Which makes little sense - it prevents the
>compiler from understanding

>a) that the data is read only and can thus be put into a segment that's shared
>between all invocations of the program
>b) the data will be the same on every invocation, and thus from optimizing
>based on that.

>The most common example of this is that all our binaries use
>static struct option long_options[] = { ... };
>which prevents long_options from being put into read-only memory.

+1 static const allows the compiler to make additional optimizations.

>There are lots of places that could benefit from adding 'static
>const'.

I found a few more places.

Patch 004

The opposite would also help, adding static.
In these places, I believe it is safe to add static,
allowing the compiler to transform into read-only, definitively.

Patch 005

best regards,

Ranier Vilela

Вложения

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

Предыдущее
От: shveta malik
Дата:
Сообщение: Re: promotion related handling in pg_sync_replication_slots()
Следующее
От: Aleksander Alekseev
Дата:
Сообщение: Re: Trigger violates foreign key constraint