[Bug 1669055] [NEW] TZ is not set by default

Matteo Croce rootkit85 at yahoo.it
Wed Mar 1 17:16:49 UTC 2017


Public bug reported:

It seems that unsetting the environment variable TZ there is a huge
performance penalty calling some glibc functions, eg. time()

this has been documented here:

https://blog.packagecloud.io/eng/2017/02/21/set-environment-variable-
save-thousands-of-system-calls/

and I can confirm it on an amd64 system running Yakkety:

$ cat time.c
#include <time.h>

int main(int argc, char *argv[])
{
        int i = 0;
        time_t timep;

        for (i = 0; i < 10000000; i++) {
                time(&timep);
                localtime(&timep);
        }

        return 0;
}
$ gcc -Wall -O3 time.c -o time
$ time ./time

real    0m7.102s
user    0m2.060s
sys     0m5.040s
$ time TZ=:/etc/localtime ./time

real    0m0.952s
user    0m0.948s
sys     0m0.000s
$

I've set TZ in /etc/environment to have it globally defined.

** Affects: shadow (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to shadow in Ubuntu.
https://bugs.launchpad.net/bugs/1669055

Title:
  TZ is not set by default

Status in shadow package in Ubuntu:
  New

Bug description:
  It seems that unsetting the environment variable TZ there is a huge
  performance penalty calling some glibc functions, eg. time()

  this has been documented here:

  https://blog.packagecloud.io/eng/2017/02/21/set-environment-variable-
  save-thousands-of-system-calls/

  and I can confirm it on an amd64 system running Yakkety:

  $ cat time.c
  #include <time.h>

  int main(int argc, char *argv[])
  {
          int i = 0;
          time_t timep;

          for (i = 0; i < 10000000; i++) {
                  time(&timep);
                  localtime(&timep);
          }

          return 0;
  }
  $ gcc -Wall -O3 time.c -o time
  $ time ./time

  real    0m7.102s
  user    0m2.060s
  sys     0m5.040s
  $ time TZ=:/etc/localtime ./time

  real    0m0.952s
  user    0m0.948s
  sys     0m0.000s
  $

  I've set TZ in /etc/environment to have it globally defined.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/shadow/+bug/1669055/+subscriptions



More information about the foundations-bugs mailing list