2.6. gettimeofday speedup

Many application workloads (especially databases and financial service applications) perform extremely frequent gettimeofday or similar time function calls. Optimizing the efficiency of this calls can provide major benefits.
A Virtual Dynamic Shared Object (VDSO), is a shared library that allows application in user space to perform some kernel actions without as much overhead as a system call. The VDSO is often used to provide fast access to the gettimeofday system call data.
Enabling the VDSO instructs the kernel to use its definition of the symbols in the VDSO, rather than the ones found in any user-space shared libraries, particularly the glibc. The effects of enabling the VDSO are system-wide - either all processes use it or none do.
When enabled, the VDSO overrides the glibc definition of gettimeofday with it's own. This removes the overhead of a system call, as the call is made direct to the kernel memory, rather than going through the glibc.
The VDSO boot parameter has three possible values:
Provides the most accurate time intervals at μs (microsecond) resolution, but also produces the highest call overhead, as it uses a regular system call
Slightly less accurate, although still at μs resolution, with a lower call overhead
The least accurate, with time intervals at the ms (millisecond) level, but offers the lowest call overhead

Enable gettimeofday with VDSO

There is a Virtual Dynamic Shared Object (VDSO) implemented in the glibc runtime library. The VDSO maps some of the kernel code, which is necessary to read gettimeofday in the user-space. Standard Red Hat Enterprise Linux 5.5 allows the gettimeofday function to be performed entirely in user-space, removing the system call overhead.
  1. VDSO behavior is enabled by default. The value used to enable the VDSO affects the behavior of gettimeofday. It can be enabled by echoing the desired value to /proc/sys/kernel/syscall64.
    # echo 1 > /proc/sys/kernel/vsyscall64


    When using the echo command, ensure you place a space character in between the value and the > character. At the shell prompt, using 0>, 1>, and 2> (without a space character) refers to standard input, standard output and standard error. Using them by mistake could result in severe unintended consequences.
  2. In addition to the above, the MRG Realtime kernel includes a further gettimeofday performance optimization. See Section 3.2, “MRG Realtime Specific gettimeofday speedup”.


Currently the gettimeofday speed up is implemented only for 64 bit architectures (AMD64 and Intel 64) and is not available on x86 machines.
Related Manual Pages
For more information, or for further reading, the following man pages are related to the information given in this section.
  • gettimeofday(2)