[tz] localtime_r multiple times slower for Europe/Moscow timezone

Steffen Nurpmeso steffen at sdaoden.eu
Tue Jan 10 23:56:03 UTC 2023


Benjamin Drung wrote in
 <3f5601eaa696b06a12f3a578b3128b131ed3bbef.camel at canonical.com>:
 |Hi,
 |
 |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;
 |}
 |```
 |
 |Compile and run this code:
 |
 |```
 |gcc -o bug bug.c
 |time TZ=Etc/UTC ./bug
 |time TZ=Europe/Berlin ./bug
 |time TZ=Europe/Moscow ./bug
 |```
 |
 |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
  Tue Jan 10 23:51:57 2023


  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

Hm.

--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