Is DLIST_STATIC_INIT() a net loss?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Is DLIST_STATIC_INIT() a net loss?
Дата
Msg-id 30244.1544722515@sss.pgh.pa.us
обсуждение исходный текст
Ответы Re: Is DLIST_STATIC_INIT() a net loss?  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
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}}

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;

leaving the compiler to drop such variables into a BSS area instead
of an initialized-data area.  I'm not very sure how much that saves,
but I bet it saves something.

            regards, tom lane


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

Предыдущее
От: Andrey Borodin
Дата:
Сообщение: Re: Connections hang indefinitely while taking a gin index's LWLockbuffer_content lock
Следующее
От: David Steele
Дата:
Сообщение: Re: Add timeline to partial WAL segments