Submit your Linux news story here.

How setting the TZ environment variable avoids thousands of system calls on Linux

The timezone to use when displaying dates can be set using a shell variable called TZ. The normal format is a pathname relative to /usr/share/zoneinfo file. To avoid extra system calls on server processes where you won’t be updating the timezone (or can restart processes when you do) simply set the TZ environment variable to :/etc/localtime (or some other timezone file of your choise) for a process. This will cause glibc to avoid making extra (and unnecessary) system calls.

From the blog post:

This blog post explains how setting an environment variable can save thousands (or in some cases, tens of thousands) of unnecessary system calls that can be generated by glibc over small periods of time.

This has been tested on Ubuntu Precise (12.04) and Ubuntu Xenial (16.04). It likely applies to other flavors of Linux, as well. It is very easy to test if this applies to you and to correct it, if so. Keep reading for more details!

To understand why this is and how to test if your processes can benefit, read on!

Comments on this entry are closed.