TL;DR

Restartable sequences (rseq) are a Linux feature allowing lockless, thread-safe data structures on multi-core systems. Currently used in some libraries, rseq offers significant performance improvements, especially on high-core-count CPUs. Its adoption could reshape system programming.

Restartable sequences (rseq), a Linux system programming feature introduced around 2018, are gaining attention for their ability to enable lockless, thread-safe data structures that scale efficiently across many CPU cores.

Rseq allows user-space programs to define small sequences of assembly instructions that the kernel can abort and retry if a thread is preempted or migrated to a different CPU. Currently, rseq is only accessible through handwritten assembly code, but it is used in libraries like tcmalloc, jemalloc, glibc, and cosmopolitan. Developers report that on high-core-count systems, rseq can improve malloc() performance by up to 43 times compared to traditional sharding techniques.

For example, on a $160 Raspberry Pi 5 with four cores, rseq speeds up malloc() by 3x. On a $4,834 System76 Thelio Astra with 128 cores, it yields a 34x speedup, and on a $17,628 AMD Threadripper with 96 cores, a 43x improvement has been observed. These enhancements are particularly relevant as microprocessors with 128 or more cores become more affordable and widespread.

Why It Matters

Rseq’s ability to facilitate lockless, scalable data structures directly addresses performance bottlenecks in high-core-count systems. As hardware continues to evolve toward many-core architectures, adopting rseq could lead to substantial efficiency gains in system and application performance, impacting fields from AI to high-performance computing.

Amazon

Linux system programming books

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Background

Introduced in Linux 4.18, rseq has been a niche feature mainly used in specialized libraries. Its potential for widespread adoption is increasing as the industry shifts toward multi-core processors with dozens or hundreds of cores. Currently, support for rseq requires manual assembly programming, but there is a strong expectation that future operating systems and languages will integrate native support, enabling broader use.

“Restartable sequences are poised to transform system programming, especially on high-core-count CPUs, by enabling lockless data structures that scale efficiently.”

— Justine, developer and researcher

“The adoption of rseq could be a game-changer for high-performance computing and AI workloads, where minimizing synchronization overhead is critical.”

— Industry analyst

Amazon

high-performance computing hardware

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

What Remains Unclear

It remains unclear when widespread support for rseq will be integrated into mainstream operating systems and programming languages. Currently, implementation requires handwritten assembly, limiting accessibility. The pace of adoption and the development of higher-level abstractions are still evolving.

Amazon

multi-core CPU optimization tools

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

What’s Next

Future developments may include official kernel support for rseq, integration into system libraries, and language-level abstractions. Developers and system programmers should monitor updates in Linux kernel versions and language compilers for potential support, and experiment with rseq in high-performance applications.

Amazon

lockless data structure libraries

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Key Questions

What are restartable sequences (rseq)?

Rseq is a Linux feature that allows user-space programs to define small sequences of assembly instructions that the kernel can abort and retry if a thread is preempted or migrated, enabling lockless, scalable data structures.

Why is rseq important for high-core-count CPUs?

Rseq reduces synchronization overhead by enabling lockless data access, which is crucial for maintaining performance as the number of CPU cores increases significantly.

Is rseq supported across all operating systems?

No, currently rseq is primarily available on Linux and requires manual assembly programming. Future OS support is anticipated but not yet confirmed.

How does rseq improve malloc() performance?

Rseq allows malloc implementations to avoid locking or sharding across cores, dramatically reducing contention and increasing speed, especially on systems with many cores.

Source: Hacker News

You May Also Like

Indonesian commodity exporters flag myriad hurdles in state monopoly push

Indonesian authorities’ move to centralize coal, palm oil, and nickel exports under a state enterprise faces industry resistance and legal hurdles.

China chides US after Trump says he will talk to Taiwan’s Lai

Beijing condemns Washington following Trump’s indication of a potential call with Taiwan’s Lai, escalating tensions amid recent US-China diplomatic exchanges.

When a Content Network Starts Publishing to Itself

Discover what happens when a publishing network begins producing content for itself. Learn the risks, benefits, and how to navigate this shift effectively.

Erin Brockovich made a map to track data centers around the country

Environmental activist Erin Brockovich has created a map to track operational, under construction, and proposed data centers across the U.S., along with community reports.