From: | Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> |
---|---|
To: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Cc: | Andres Freund <andres(at)anarazel(dot)de>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Peter Eisentraut <peter(at)eisentraut(dot)org>, "Andrey M(dot) Borodin" <x4mmm(at)yandex-team(dot)ru> |
Subject: | Re: plenty code is confused about function level static |
Date: | 2024-04-18 12:07:43 |
Message-ID: | CAEudQAoB_2_ejJUFz=LFX7_nK6SgHFei_+cmoa4X43UfPp4gsA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
Attachment | Content-Type | Size |
---|---|---|
0004-static-const-convert-plpython.patch | application/octet-stream | 1.8 KB |
0005-const-convert-static-const.patch | application/octet-stream | 2.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Aleksander Alekseev | 2024-04-18 12:24:39 | Re: Trigger violates foreign key constraint |
Previous Message | shveta malik | 2024-04-18 12:06:05 | Re: promotion related handling in pg_sync_replication_slots() |