TL;DR

Restartable sequences (rseq) is a Linux system programming feature that enables lockless, highly scalable data structures. Currently supported mainly through handwritten assembly, it offers major performance improvements on multi-core CPUs. Wider OS and language support are anticipated but not yet available.

A Linux feature called restartable sequences (rseq) is gaining attention for its potential to drastically improve performance of system programming on multi-core CPUs. Currently, rseq is only accessible through handwritten assembly code, but experts expect broader support across operating systems and programming languages in the near future. This development could enable developers to create lockless, scalable data structures that leverage the full power of modern hardware.

Restartable sequences (rseq) is a Linux system call introduced around 2018 that provides thread-local storage (TLS) which is automatically updated with the CPU number during thread rescheduling. Developers can specify small assembly routines that the kernel will execute atomically when a thread is preempted, allowing for lockless synchronization mechanisms. This capability is especially valuable for high-performance data structures such as lockless linked lists or hash tables, which traditionally rely on locks or atomic operations that become bottlenecks on many-core systems.

Currently, support for rseq is limited; it requires custom assembly code, and only a handful of libraries, including tcmalloc, jemalloc, glibc, and cosmopolitan, have integrated it. However, early benchmarks show dramatic speedups: for example, on a high-core-count CPU, rseq-enabled malloc implementations are reported to be up to 43 times faster than traditional sharding techniques. On lower-end hardware like a Raspberry Pi 5 with four cores, the improvements are more modest but still notable, with a threefold increase in malloc speed.

Why It Matters

This development matters because it could fundamentally change how system programmers optimize performance on modern hardware. As CPUs with dozens or hundreds of cores become more common and affordable, traditional locking mechanisms and atomic operations face scalability limits. Rseq offers a way to bypass these bottlenecks, enabling more efficient, lockless algorithms that can fully exploit hardware capabilities. Widespread adoption could lead to significant performance gains across operating systems, libraries, and applications, especially in high-performance computing, AI, and database systems.

C++ for Performance-Critical Systems: Build High-Performance Applications on Linux and Unix with Practical C++20/23 Examples, Concurrency, and Networking

C++ for Performance-Critical Systems: Build High-Performance Applications on Linux and Unix with Practical C++20/23 Examples, Concurrency, and Networking

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Background

The concept of restartable sequences was first introduced in Linux kernel version 4.18, but adoption has been limited due to the complexity of implementation and the need for handwritten assembly. The technique involves creating small, atomic assembly routines that the kernel can execute when a thread is preempted, allowing for lockless updates to thread-local data. Early use cases include memory allocators like tcmalloc and jemalloc, which have reported substantial performance improvements on multi-core systems. As hardware continues to evolve toward many-core architectures, interest in rseq is growing among system programmers seeking scalable solutions.

“Restartable sequences are the best-kept secret in system programming right now. They enable lockless data structures that scale to hundreds of cores, which is vital for modern hardware.”

— Justine, developer and advocate for rseq

“On a 128-core CPU, rseq can make malloc 34 times faster compared to traditional sharding, which is a game-changer for scalable memory management.”

— A hardware enthusiast

Lockly Secure Link Wi-Fi Hub - Control Your Lockly Smart Lock from Anywhere with Real-time Notifications and Voice Control
  • Wi-Fi Compatibility: Connects lock to Wi-Fi for remote access
  • Remote Lock/Unlock: Control lock remotely via mobile app
  • Real-time Notifications: Instant alerts for lock status changes

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

What Remains Unclear

Widespread support for rseq across operating systems and programming languages remains uncertain. Currently, implementation is limited, and integration into mainstream libraries and compilers is still in early stages. It is also unclear how quickly OS updates will incorporate native support for rseq, or how developers will adapt their codebases to leverage this feature broadly.

Linux Basics for Hackers: Getting Started with Networking, Scripting, and Security in Kali

Linux Basics for Hackers: Getting Started with Networking, Scripting, and Security in Kali

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

What’s Next

Developers and system architects will likely focus on creating portable abstractions over rseq, advocating for kernel and language support, and integrating it into core libraries. Future milestones include official OS support, compiler integration, and widespread adoption in performance-critical applications. Monitoring the development of high-level language bindings and OS updates will be key to understanding how quickly rseq becomes mainstream.

Practical Binary Analysis: Build Your Own Linux Tools for Binary Instrumentation, Analysis, and Disassembly

Practical Binary Analysis: Build Your Own Linux Tools for Binary Instrumentation, Analysis, and Disassembly

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Key Questions

What is restartable sequences (rseq)?

Rseq is a Linux feature that allows small, atomic assembly routines to be executed when a thread is preempted, enabling lockless, scalable data structures for multi-core systems.

Why is rseq important for modern hardware?

It provides a way to bypass traditional locking and atomic operations that become bottlenecks on many-core CPUs, enabling higher performance and scalability.

Is rseq supported on all operating systems?

No, support is currently limited to Linux with handwritten assembly routines. Broader OS and language support are expected but are still in development.

How can developers start using rseq now?

Currently, it requires writing custom assembly code and integrating it into existing projects. Some libraries like jemalloc have begun experimenting with it, but widespread adoption will depend on future OS and compiler support.

Source: Hacker News

You May Also Like

Operational Security for LLMs: Aligning Models for Sensitive Use

Understanding how to secure large language models for sensitive applications is crucial—discover strategies to protect your systems and stay ahead.

Singapore Military Taps Oracle for Advanced Cloud Computing and AI Support.

Harnessing Oracle’s cutting-edge cloud and AI technologies, Singapore’s military embarks on a transformative journey—discover the implications for regional security and defense innovation.

Running local models on an M4 with 24GB memory

Experimental setup enables running smaller AI models locally on a MacBook Pro with 24GB memory, offering a practical alternative to cloud-based models.

OpenAI Buys AI Voice Startup Weights

OpenAI has announced its acquisition of Weights, an AI voice startup, marking a strategic move into voice technology development.