Understanding Linux System Call Performance Overhead on x86-64 Architecture
By
rbanffy
Toasted golden, schmeared with insight. Top of the rack.
Summary
This technical deep dive examines why system calls are expensive operations in Linux, particularly on x86-64 architecture. The article explains that system calls require context switching between user and kernel space, which involves saving/restoring CPU state, changing memory protection, and flushing CPU caches. It covers how modern processors handle system calls through mechanisms like syscall/sysret instructions, the role of the vsyscall page for optimization, and why even with hardware optimizations, system calls remain performance bottlenecks that engineers work to minimize through techniques like io_uring for I/O batching and eBPF for running code in kernel space.
Key quotes
· 4 pulledSystem calls are how user programs talk to the operating system. They include opening files, reading the current time, creating processes, and more. They're unavoidable, but they're also not cheap.
If you've ever looked at a flame graph, you'll notice system calls often show up as hot spots. Engineers spend a lot of effort cutting them down.
Whole features such as io_uring for batching I/O or eBPF for running code inside the kernel exist just to reduce how often programs have to cross into kernel mode.
Why are they so expensive? The answer lies in what happens when a program makes a system call and the CPU has to switch from user mode to kernel mode.
You might also wanna read
A Practical Guide to Scaling Web Systems from Zero to 10+ Million Users
This article provides a practical guide to scaling web systems from zero to over 10 million users, based on the author's experience at big t
Error Handling in Large Systems: The Debate Around Rust's .unwrap() Method
The article discusses the debate around error handling in large systems, sparked by Cloudflare's November 18 outage postmortem that mentione

Why Traditional Latency Measurement Tools Provide Misleading Results
The article critiques traditional latency measurement tools and methodologies, arguing they provide misleading results. Based on a workshop
Understanding Program Execution: What Happens Between execve() and main() in Linux
This technical blog post explores the complex process that occurs between when the Linux kernel is asked to execute a program via the execve
The Legacy Problems with Environment Variables in Modern Software Development
This article critiques environment variables as an outdated and problematic mechanism in modern software development. It argues that while p
Performance Benchmark: Testing HTTP Request Capacity of a Single Machine Architecture
This article presents a performance benchmark test examining how many HTTP requests per second a single machine can handle using a simple mo
