svn commit: r367813 - head/lib/libutil
Jessica Clarke
jrtc27 at freebsd.org
Wed Nov 18 22:39:48 UTC 2020
On 18 Nov 2020, at 22:32, Stefan Esser <se at freebsd.org> wrote:
>
> Am 18.11.20 um 22:40 schrieb Mateusz Guzik:
>>> +{
>>> + static const int localbase_oid[2] = {CTL_USER, USER_LOCALBASE};
>> There is no use for this to be static.
>
> Why not? This makes it part of the constant initialized data of
> the library, which is more efficient under run-time and memory
> space aspects than initializing them on the stack.
>
> What do I miss?
What is more efficient is not so clear-cut, it depends on things like
the architecture, microarchitecture and ABI. Allocating a small buffer
on the stack is extremely cheap (the memory will almost certainly be in
the L1 cache), whereas globally-allocated storage is less likely to be
in the cache due to being spread out, and on some architecture/ABI
combinations will incur additional indirection through the GOT. Also, 8
bytes of additional stack use is lost in the noise.
Jess
More information about the svn-src-all
mailing list