who would have thought that gmtime_r uses a mutex?

Nils Goroll nils.goroll at uplex.de
Fri Jul 11 07:42:06 UTC 2025


Just dropping this here, not sure if it's worth doing anything about it 
(probably not). But I was really surprised...

from `perf report` of a synthetic benchmark:

- 12.52% cnt_synth 

    - 5.24% Resp_Setup_Synth 

       - 3.50% http_TimeHeader 

          - 3.16% VTIM_format 

             - 1.69% __lll_lock_wait_private 

                - 1.63% entry_SYSCALL_64_after_hwframe 

                   - 1.63% do_syscall_64 

                      - 1.56% x64_sys_call 

                         - 1.56% __x64_sys_futex 

                            - 1.56% do_futex 

                               - futex_wait 

                                  - 1.55% __futex_wait 

                                     - 1.32% futex_wait_setup 

                                        - 1.29% futex_q_lock 

                                           - 1.26% _raw_spin_lock 

                                                native_queued_spin_lock_slowpath 

             - 0.64% __lll_lock_wake_private 

                - 0.64% entry_SYSCALL_64_after_hwframe 

                   - 0.63% do_syscall_64 

                      - 0.61% x64_sys_call 

                         - 0.61% __x64_sys_futex 

                            - 0.61% do_futex 

                                 0.59% futex_wake 

             - 0.56% __GI___snprintf 

                  0.54% __vsnprintf_internal 

         0.86% http_PrintfHeader 



https://sourceware.org/git/?p=glibc.git;a=blob;f=time/tzset.c;h=0ddc20328717bcf695de370cb48c83b06a7e076b;hb=HEAD#l572 
called from 
https://sourceware.org/git/?p=glibc.git;a=blob;f=time/gmtime.c;h=ad6e8eb35233f6018607b938f303dc75323c8f6e;hb=HEAD#l26

maybe this is for simplicity of the code, but as `use_localtime` is zero, the 
stuff at the top of the function under the lock would not be required, _I think_ 
(am I wrong?).

Nils

-- 

Nils Goroll (he/him)

** * * UPLEX - Nils Goroll Systemoptimierung

Scheffelstraße 32
22301 Hamburg

tel +49 40 28805731
mob +49 170 2723133
fax +49 40 42949753

xmpp://slink@jabber.int.uplex.de/

http://uplex.de/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0x1DCD8F57A3868BD7.asc
Type: application/pgp-keys
Size: 3943 bytes
Desc: OpenPGP public key
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20250711/c26358ff/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20250711/c26358ff/attachment-0001.bin>


More information about the varnish-dev mailing list