Re: Is DLIST_STATIC_INIT() a net loss?

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: Is DLIST_STATIC_INIT() a net loss?
Дата
Msg-id 20181213191024.cbzj3s2kb76rszmu@alap3.anarazel.de
обсуждение исходный текст
Ответ на Is DLIST_STATIC_INIT() a net loss?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi,

On 2018-12-13 12:35:15 -0500, Tom Lane wrote:
> I happened to notice today that the initializer macro for dlist_head
> variables is
>
> #define DLIST_STATIC_INIT(name) {{&(name).head, &(name).head}}
>
> However, all the functions that work with dlists are prepared to handle
> a dlist_head that starts out as zeroes, so that this could also be
>
> #define DLIST_STATIC_INIT(name) {{NULL, NULL}}

Historically that's because my patch initially didn't handle structs
starting out as zeroes, and that that was changed over my objections. I
still think those zero checks are a waste of cycles.

> I submit that we'd be better off with the latter.  The number of cycles
> that the linker and loader expend on getting those non-constant values
> correctly set up (especially in PIE builds) probably dwarf what it
> costs for the first dlist access to initialize them.  It's especially
> obviously a loss in processes that never touch the particular dlist
> at all.
>
> Another thought is that maybe we should deprecate the use of the
> [DS]LIST_STATIC_INIT macros altogether, and just write
>
> static dlist_header myheader;

But if we're not going to change that - which I'd vote for, but not
forsee happening - we should indeed just skip over initialization,
there's really not much point.

Greetings,

Andres Freund


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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: Remove Deprecated Exclusive Backup Mode
Следующее
От: David Steele
Дата:
Сообщение: Re: Remove Deprecated Exclusive Backup Mode