[tz] localtime_r multiple times slower for Europe/Moscow timezone
Steffen Nurpmeso
steffen at sdaoden.eu
Wed Jan 11 00:17:38 UTC 2023
Steffen Nurpmeso wrote in
<20230110235603.tclHE%steffen at sdaoden.eu>:
|Benjamin Drung wrote in
| <3f5601eaa696b06a12f3a578b3128b131ed3bbef.camel at canonical.com>:
||a Ubuntu user has been reporting in https://launchpad.net/bugs/868395
||that the Europe/Moscow timezone is multiple times slower than other
||timezones. Here is the example bug.c code:
||
||```
||#include <time.h>
||#include <stdio.h>
||
||int main() {
|| time_t t = time(0);
|| int i;
|| struct tm result;
|| for(i=0; i < 10000000; i++)
|| localtime_r(&t, &result);
|| puts(ctime(&t));
|| return 0;
||}
||```
...
||The result on my machine is that Etc/UTC, Europe/Berlin, and other
||timezones take around 250 to 400 ms, but Europe/Moscow takes 1200 ms.
||The result is the same when running in a Debian unstable, Ubuntu 22.04
||(jammy) and Ubuntu 23.04 (lunar) chroot.
|
|Wow, what performance.
|
| #?0|kent:tmp$ for f in Etc/UTC Europe/Berlin Europe/Moscow; do time \
| TZ=$f ./zt; done
| real 0m0.520s
| user 0m0.515s
| sys 0m0.004s
| Wed Jan 11 00:51:58 2023
| real 0m7.202s
| user 0m7.180s
| sys 0m0.000s
| Wed Jan 11 02:52:05 2023
| real 0m2.076s
| user 0m2.071s
| sys 0m0.000s
|
||Is that a bug? If yes, is that a bug in glibc?
|
|CRUX Linux, 2022g, 2.36-3, gcc 12.2.0.
|
| #?0|kent:tmp$ zdump -v Europe/Berlin|wc -l
| 2144
| #?0|kent:tmp$ zdump -v Europe/Moscow|wc -l
| 166
| #?0|kent:tmp$ zdump -v Etc/UTC|wc -l
| 6
..just to correct stupidity a little bit
$ for f in Etc/UTC Europe/Berlin Europe/Moscow; do
ef=$(echo $f | sed -E 's|/|\\/|')
sed -E '/^Z '"$ef"'/,/^Z /p;d' /usr/share/zoneinfo/tzdata.zi
done
comes to
Z Etc/UTC 0 - UTC
Z Etc/GMT 0 - GMT
Z Europe/Berlin 0:53:28 - LMT 1893 Ap
1 c CE%sT 1945 May 24 2
1 So CE%sT 1946
1 DE CE%sT 1980
1 E CE%sT
Z Europe/Gibraltar -0:21:24 - LMT 1880 Au 2
Z Europe/Moscow 2:30:17 - LMT 1880
2:30:17 - MMT 1916 Jul 3
2:31:19 R %s 1919 Jul 1 0u
3 R %s 1921 O
3 R MSK/MSD 1922 O
2 - EET 1930 Jun 21
3 R MSK/MSD 1991 Mar 31 2s
2 R EE%sT 1992 Ja 19 2s
3 R MSK/MSD 2011 Mar 27 2s
4 - MSK 2014 O 26 2s
3 - MSK
Z Europe/Simferopol 2:16:24 - LMT 1880
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)
More information about the tz
mailing list