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

Benjamin Drung benjamin.drung at canonical.com
Tue Jan 10 23:15:53 UTC 2023


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.

Is that a bug? If yes, is that a bug in glibc?

-- 
Benjamin Drung
Debian & Ubuntu Developer


More information about the tz mailing list