This post introduces the evolution of timekeeping in Go programs on Linux, detailing the transition from traditional system calls like gettimeofday to the more efficient vDSO (Virtual Dynamically linked Shared Objects) mechanism for clock_gettime. It highlights the performance improvements achieved by leveraging vDSO for time.Now and runtime.nanotime, and discusses the underlying Linux kernel system calls (time, gettimeofday, clock_gettime) and their respective precisions and behaviors. Benchmarks demonstrate significant speedups, especially for time.Now, compared to older Go versions and traditional system calls. The post also touches upon the importance of accurate timekeeping in various systems, including NTP and the Year 2038 problem.
All Cloudflare trails