TencentOS Swap Table Boosts Linux Memory Performance by Up to 30%
TencentOS’s recent Swap Table patch series restructures the Linux kernel’s swap subsystem, eliminating long‑standing fragmentation and lock bottlenecks, introducing lock‑free allocation, dynamic swap space, and achieving 20‑30% performance gains and up to 400% higher concurrent throughput in heavy‑load scenarios.
Recently, the Tencent Cloud Operating System (TencentOS) team submitted a series of patches called Swap Table. These patches improve handling of 4 KB pages and mTHP folios, delivering roughly 20%–30% performance gains in high‑load tasks and cleaning up long‑standing issues in the swap subsystem.
What is SWAP?
SWAP is a memory‑in‑and‑out mechanism that moves rarely used pages to a secondary storage device, freeing RAM for active processes. In Linux, the SWAP subsystem acts as a temporary repository, swapping data between RAM and a designated swap space on disk.
Traditional SWAP Bottlenecks
The classic Linux SWAP design suffers from several performance problems: severe page fragmentation, heavy global lock contention, high memory overhead for mapping structures, and poor scalability for dynamic swap space.
Swap Table Redesign
The TencentOS kernel team performed a structural overhaul of the SWAP mechanism, introducing a new SWAP Table architecture. Key changes include:
Complete rework of the SWAP allocation path , turning a linear O(n) process into O(1) by managing swap devices in clusters.
Lock‑free redesign of the global swap lock , eliminating contention and achieving lock‑free operation.
Reconstruction of the AP Table to support dynamic allocation and expansion of swap space.
Performance Results
Testing shows that the new Swap Table improves performance by 20%–30% when transitioning from basic swap operations to heavy‑load workloads. It also reduces memory consumption, increases swap‑out success rate, and raises concurrent swap device throughput by up to 400% while cutting fragmentation by about 99%.
Challenges and Significance
Integrating these changes upstream is difficult because they replace the core SWAP allocator, requiring deep understanding of the existing system and extensive validation. Tencent’s large‑scale production environment provided the necessary verification. The patches also clean up long‑standing historical bugs, enhancing stability and laying a solid foundation for future optimizations.
The Swap Table has been merged as the default allocator in the upstream kernel, and its adoption is expected to become a major innovation for Linux SWAP, improving memory compression, hardware resource utilization, and ultimately reducing operational costs.
Beyond this contribution, the TencentOS kernel team continues to collaborate with the community on memory cgroup, page hotness management, and other kernel performance enhancements.
Tencent Architect
We share insights on storage, computing, networking and explore leading industry technologies together.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
