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

The Netherlands just blocked a US company from buying the app Dutch citizens use for everything

The Netherlands has prevented a US company from acquiring a popular Dutch app used by citizens for various services, citing national security concerns.

Quantum computing CEOs hope “validating” government backing proves their technology is no longer speculative

CEOs of Infleqtion and D-Wave view recent government grants as validation of their quantum tech, signaling industry progress and increased support.

Erin Brockovich launches map of over 4,200 data centres in the US, appeals for local communities to report environmental impact and other costs

Environmental activist Erin Brockovich has launched a website mapping over 4,200 US data centers, urging public reports on local concerns amid AI infrastructure expansion.

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.