[Libguestfs] [nbdkit] [filter/nozero] large binary size with GCC 9

Eric Blake eblake at redhat.com
Fri Jul 5 15:02:31 UTC 2019


On 7/5/19 9:52 AM, Thomas Weißschuh wrote:

>> Good to know. So the fix is indeed removing 'const', rather than
>> reducing scope (although I might as well reduce scope while at it, for
>> consistency).
> 
> Does this not mean, the 64M are zeroed on every loop iteration in every call to
> these functions?

No. static variables are guaranteed by the C standard to start life
pre-initialized (where that initialization is guaranteed to be all
zeroes if there is no explicit initializer), and that pre-initialization
is NOT performed during each call to the function (the compiler may
delay the initialization to the first function call, if that is cheaper
than always initializing the storage even if the function doesn't get
called, but the effect is the same).

> (Probably also depends on compiler optimizations)

Any compiler that initializes a static variable more than once is buggy.

> 
> Maybe this will have some performance impact, or does it not matter with these
> functions?

No, there should be no performance change.  If there were, that's an
even more serious bug in gcc.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20190705/f2ade374/attachment.sig>


More information about the Libguestfs mailing list