Restartable Sequences

TL;DR

Restartable sequences (rseq) are a Linux system programming concept that enables lockless, scalable data structures on multi-core processors. Currently usable only through handwritten assembly, rseq offers dramatic performance improvements for high-core-count systems. Its adoption could transform system programming and application performance.

Restartable sequences (rseq), a Linux kernel feature introduced around 2018, are gaining attention for their potential to dramatically improve performance of multi-core applications by enabling lockless data structures. Currently, rseq is only accessible through handwritten assembly code, but experts believe widespread OS and language support could soon follow, unlocking new levels of efficiency for high-core-count systems.

Rseq allows threads to perform restartable, lockless operations by providing a small thread-local storage (TLS) area that the kernel updates with CPU information during scheduling. Developers can specify sequences of assembly instructions that the kernel can jump to if a thread is preempted during a critical section, enabling safe retries without locks or atomic operations.

Currently, only a handful of software, including glibc, jemalloc, tcmalloc, and cosmopolitan, utilize rseq, mostly for performance improvements in memory allocators. For example, on high-core systems like the System76 Thelio Astra with 128 cores, rseq enables malloc() to run up to 34 times faster compared to traditional sharding techniques. Similarly, on AMD Threadripper systems with 96 cores, performance gains reach 43x.

Practitioners with access to high-core-count hardware see rseq as a game-changer, allowing them to optimize critical code paths significantly. The technique is particularly relevant as microprocessors with 128 or more cores become affordable, making traditional locking methods impractical at scale.

Why It Matters

The adoption of rseq could revolutionize system and application performance on modern hardware, especially as core counts increase. It offers a pathway to scalable, lockless data structures that can fully exploit the capabilities of future CPUs. For system programmers and high-performance computing, rseq represents a low-level, yet powerful, tool to reduce latency and improve throughput, potentially impacting everything from memory allocators to real-time systems.

However, widespread support in operating systems and programming languages remains absent. The current reliance on handwritten assembly limits its accessibility, and it is unclear when mainstream Linux kernels or languages will integrate rseq support broadly. This gap could delay the full realization of its benefits for most developers.

C++ Custom Memory Allocators: Arena,Pool, and Stack Allocation, Allocator-Aware Containers, and DeterministicMemory Performance in Production Systems. (High-Performance C++ Engineering)

C++ Custom Memory Allocators: Arena,Pool, and Stack Allocation, Allocator-Aware Containers, and DeterministicMemory Performance in Production Systems. (High-Performance C++ Engineering)

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Background

The concept of restartable sequences originated in Linux around 2018, as a response to the need for scalable, lockless programming techniques in increasingly multi-core environments. Prior to rseq, developers relied on locks, atomic operations, or sharding to manage concurrency, which can become bottlenecks as core counts grow. The idea is to allow user-space code to specify critical sections that can be safely retried if interrupted, without kernel-level locking overhead.

Initial implementations focused on memory allocators and low-level threading primitives. As hardware with dozens or hundreds of cores has become more accessible, the performance benefits of rseq have become more evident, prompting a resurgence of interest. Despite its potential, no major Linux release has yet integrated rseq as a formal API, and the technique remains primarily in experimental or niche use.

“What makes restartable sequences exciting is their potential to unlock performance gains in high-core environments that are simply unattainable with traditional locking or atomic techniques.”

— Justine, source author

“Support for rseq in mainstream Linux kernels is still in development, and wider adoption depends on integrating robust APIs and language bindings.”

— Linux kernel developer

Parallel Programming with OpenMP for C++ Developers: A Practical Guide to Multithreading, Synchronization, and Performance Optimization

Parallel Programming with OpenMP for C++ Developers: A Practical Guide to Multithreading, Synchronization, and Performance Optimization

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

What Remains Unclear

It is not yet clear when Linux will officially support rseq as a stable API, or how quickly programming languages and libraries will adopt it. The extent of future OS, language, and library integration remains uncertain, as does the ease of use for general developers.

Amazon

lockless data structure development kit

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

What’s Next

Development efforts are ongoing to incorporate rseq into the Linux kernel’s mainline, along with creating language bindings and libraries to make it accessible. Expect future Linux releases to include official support, and for more software projects to experiment with rseq-based optimizations.

Mastering Embedded Linux Development: Craft fast and reliable embedded solutions with Linux 6.6 and The Yocto Project 5.0 (Scarthgap)

Mastering Embedded Linux Development: Craft fast and reliable embedded solutions with Linux 6.6 and The Yocto Project 5.0 (Scarthgap)

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Key Questions

What are restartable sequences?

Restartable sequences are a Linux kernel feature that allows user-space programs to perform lockless, scalable operations by specifying critical sections that can be safely retried if interrupted during scheduling.

How do restartable sequences improve performance?

They enable threads to execute critical code without locks or atomic operations, reducing contention and latency, especially on systems with many cores.

Are restartable sequences widely supported now?

No, currently rseq is only available through handwritten assembly code and in limited software. Broader support depends on future Linux kernel updates and language integration.

Who can benefit most from rseq?

Developers working on high-performance, multi-core applications such as memory allocators, real-time systems, or scientific computing are most likely to benefit.

Source: Hacker News

You May Also Like

Android Show 2026: all the news and announcements

Google unveils Android 17, Gemini features, new laptops, and Android Auto updates at Android Show 2026 ahead of I/O.

Two EA-18 fighter jets collide at Mountain Home airshow, pilots ejected safely

Two U.S. Navy EA-18G Growler jets collided during an air show at Mountain Home AFB; all four crew members ejected safely. Investigation ongoing.

1047 Games’ spiritual successor to Titanfall will reportedly be called Empulse

1047 Games’ upcoming movement shooter, reportedly called Empulse, is a spiritual successor to Titanfall, featuring mech combat and advanced mobility.

iPhone 18 Pro Max Vs Google Pixel 11 Pro XL: Main Differences To Expect

Compare the upcoming iPhone 18 Pro Max and Pixel 11 Pro XL, focusing on design, display, performance, and camera specs to understand their main differences.