[HACKERS] Constifying numeric.c's local vars

Поиск
Список
Период
Сортировка
От Andres Freund
Тема [HACKERS] Constifying numeric.c's local vars
Дата
Msg-id 20170910232154.asgml44ji2b7lv3d@alap3.anarazel.de
обсуждение исходный текст
Ответы Re: [HACKERS] Constifying numeric.c's local vars  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi,

For JIT inlining currently functions can't be inlined if they reference
non-constant static variables. That's because there's no way, at least
none I know of, to link to the correct variable, instead of duplicating,
the linker explicitly renames symbols after all (that's the whole point
of static vars).  There's a bunch of weird errors if you ignore that ;)

One large user of unnecessary non-constant static variables is
numeric.c.  More out of curiosity - numeric is slow enough in itself to
make inlining not a huge win - I converted it to use consts.

before:
andres@alap4:~/build/postgres/dev-assert/vpath$ size --format=SysV src/backend/utils/adt/numeric.o |grep -v debug|grep
-v'^.group'
 
src/backend/utils/adt/numeric.o  :
section             size   addr
.text              68099      0
.data                 64      0
.bss                   2      0
.rodata             4256      0
.data.rel.local      224      0
.comment              29      0
.note.GNU-stack        0      0
.eh_frame           5976      0
Total             395590


after:

$ size --format=SysV src/backend/utils/adt/numeric.o |grep -v debug|grep -v '^.group'
src/backend/utils/adt/numeric.o  :
section                size   addr
.text                 68108      0
.data                     0      0
.bss                      0      0
.rodata                4288      0
.data.rel.ro.local      224      0
.comment                 29      0
.note.GNU-stack           0      0
.eh_frame              5976      0
Total                395586

Nicely visible that the data is moved from a mutable segment to a
readonly one.

It's a bit ugly that some consts have to be casted away in the constant
definitions, but aside from just inlining the values, I don't quite see
a better solution?

Leaving JIT aside, I think stuff like this is worthwhile on its own...

Greetings,

Andres Freund

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Вложения

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

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: Re: [HACKERS] The case for removing replacement selection sort
Следующее
От: Michael Paquier
Дата:
Сообщение: [HACKERS] Automatic testing of patches in commit fest