# underrust

Published articles for underrust.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Underrust: What is the cost of Mutex, RwLock and AtomicPtr?

DevFeed: [Underrust: What is the cost of Mutex, RwLock and AtomicPtr?](<https://devfeed.tech/articles/underrust-what-is-the-cost-of-mutex-rwlock-and-atomicptr-35479.md>)

Original publisher: [Read original article](<https://darkcoding.net/software/underrust-mutual-exclusion/>)

Author: Graham King

Published: 2025-05-05T20:05:00Z

Content type: tutorial

Language: en

Sources: [Graham King](<https://devfeed.tech/sources/graham-king.md>)

Topics: [Rust](<https://devfeed.tech/topics/rust.md>), [Concurrent Programming](<https://devfeed.tech/topics/concurrent-programming.md>), [x86](<https://devfeed.tech/topics/x86.md>), [cpu](<https://devfeed.tech/topics/cpu.md>), [Assembly](<https://devfeed.tech/topics/assembly.md>)

Tags: [assembly](<https://devfeed.tech/tags/assembly.md>), [concurrent](<https://devfeed.tech/tags/concurrent.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [cycles](<https://devfeed.tech/tags/cycles.md>), [locking](<https://devfeed.tech/tags/locking.md>), [performance](<https://devfeed.tech/tags/performance.md>), [rust](<https://devfeed.tech/tags/rust.md>), [software](<https://devfeed.tech/tags/software.md>), [synchronization](<https://devfeed.tech/tags/synchronization.md>), [underrust](<https://devfeed.tech/tags/underrust.md>)

### AI overview

A Rust-focused analysis uses assembly output to examine the cost of Mutex, RwLock, and atomic operations for many concurrent readers and an occasional writer. It scopes the discussion to Linux and x86, noting that the fast-path operations discussed are roughly in the range of 20 to 30 CPU cycles.

### Source excerpt

With many concurrent readers and a single occasional writer, which mutual exclusion primitive should you use? Let's look at the assembly to find out.

## Underrust: How does u128 work on a 64-bit processor?

DevFeed: [Underrust: How does u128 work on a 64-bit processor?](<https://devfeed.tech/articles/underrust-how-does-u128-work-on-a-64-bit-processor-35481.md>)

Original publisher: [Read original article](<https://darkcoding.net/software/underrust-u128/>)

Author: Graham King

Published: 2025-04-05T20:45:00Z

Content type: tutorial

Language: en

Sources: [Graham King](<https://devfeed.tech/sources/graham-king.md>)

Topics: [cpu](<https://devfeed.tech/topics/cpu.md>), [x86](<https://devfeed.tech/topics/x86.md>), [Rust](<https://devfeed.tech/topics/rust.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>), [Assembly](<https://devfeed.tech/topics/assembly.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [assembly](<https://devfeed.tech/tags/assembly.md>), [code](<https://devfeed.tech/tags/code.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [processors](<https://devfeed.tech/tags/processors.md>), [rust](<https://devfeed.tech/tags/rust.md>), [simd](<https://devfeed.tech/tags/simd.md>), [software](<https://devfeed.tech/tags/software.md>), [sse](<https://devfeed.tech/tags/sse.md>), [underrust](<https://devfeed.tech/tags/underrust.md>), [x86](<https://devfeed.tech/tags/x86.md>)

### AI overview

The article explains how Rust u128 values work on x86-64 processors whose general-purpose registers are limited to 64 bits. It describes splitting values across two registers and distinguishes this from the use of 128-bit SSE registers for SIMD operations.

### Source excerpt

Wherein our hero learns the arcane secrets of the u128 sword in the depths of the Underrust.

## Underrust: What does vec!\[0u8; 1024\] really do?

DevFeed: [Underrust: What does vec!\[0u8; 1024\] really do?](<https://devfeed.tech/articles/underrust-what-does-vec-0u8-1024-really-do-35464.md>)

Original publisher: [Read original article](<https://darkcoding.net/software/rust-zeroed-vector-allocation/>)

Author: Graham King

Published: 2024-03-29T15:00:00Z

Content type: article

Language: en

Sources: [Graham King](<https://devfeed.tech/sources/graham-king.md>)

Topics: [Rust](<https://devfeed.tech/topics/rust.md>), [Linux](<https://devfeed.tech/topics/linux.md>), [cpu](<https://devfeed.tech/topics/cpu.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [glibc](<https://devfeed.tech/tags/glibc.md>), [linux](<https://devfeed.tech/tags/linux.md>), [memory](<https://devfeed.tech/tags/memory.md>), [rust](<https://devfeed.tech/tags/rust.md>), [software](<https://devfeed.tech/tags/software.md>), [underrust](<https://devfeed.tech/tags/underrust.md>), [x86](<https://devfeed.tech/tags/x86.md>)

### AI overview

This article traces how Rust creates a zero-initialized vector, following the allocation path through Rust's allocator, the platform abstraction layer, libc's calloc, and the Linux kernel. It examines allocation behavior and cost, with examples focused on 64-bit Linux, glibc, and an Intel Tiger Lake CPU.

### Source excerpt

How does Rust allocate a zeroed Vec and what does it cost?

## Underrust: Multiple Return Values

DevFeed: [Underrust: Multiple Return Values](<https://devfeed.tech/articles/underrust-multiple-return-values-35460.md>)

Original publisher: [Read original article](<https://darkcoding.net/software/rust-multiple-return-types/>)

Author: Graham King

Published: 2022-10-18T07:00:00Z

Content type: tutorial

Language: en

Sources: [Graham King](<https://devfeed.tech/sources/graham-king.md>)

Topics: [Rust](<https://devfeed.tech/topics/rust.md>), [Assembly](<https://devfeed.tech/topics/assembly.md>), [LLVM](<https://devfeed.tech/topics/llvm.md>), [Optimization](<https://devfeed.tech/topics/optimization.md>)

Tags: [assembly](<https://devfeed.tech/tags/assembly.md>), [avx](<https://devfeed.tech/tags/avx.md>), [llvm](<https://devfeed.tech/tags/llvm.md>), [optimization](<https://devfeed.tech/tags/optimization.md>), [rust](<https://devfeed.tech/tags/rust.md>), [simd](<https://devfeed.tech/tags/simd.md>), [software](<https://devfeed.tech/tags/software.md>), [underrust](<https://devfeed.tech/tags/underrust.md>)

### AI overview

This article examines how Rust returns values at the ABI and assembly levels. It covers integer and floating-point returns, multiple values, structs, function pointers, caller-stack returns, return-value optimization, and an LLVM SIMD optimization using AVX registers.

### Source excerpt

How does Rust return values, and does it make any difference to us programmers?

## Underrust: What is the cost of sync::Once?

DevFeed: [Underrust: What is the cost of sync::Once?](<https://devfeed.tech/articles/underrust-what-is-the-cost-of-sync-once-35384.md>)

Original publisher: [Read original article](<https://darkcoding.net/software/cost-of-sync-once/>)

Author: Graham King

Published: 2022-09-18T07:00:00Z

Content type: article

Language: en

Sources: [Graham King](<https://devfeed.tech/sources/graham-king.md>)

Topics: [Rust](<https://devfeed.tech/topics/rust.md>), [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [Assembly](<https://devfeed.tech/topics/assembly.md>), [Latency](<https://devfeed.tech/topics/latency.md>)

Tags: [assembly](<https://devfeed.tech/tags/assembly.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [llvm](<https://devfeed.tech/tags/llvm.md>), [performance](<https://devfeed.tech/tags/performance.md>), [rust](<https://devfeed.tech/tags/rust.md>), [software](<https://devfeed.tech/tags/software.md>), [underrust](<https://devfeed.tech/tags/underrust.md>)

### AI overview

This article analyzes the cost of calling Rust's std::sync::Once after initialization. It explains that repeated calls usually take a fast path, with the function call commonly inlined, a branch that is normally predicted correctly, and a small number of machine instructions whose latency is estimated for an Intel Tiger Lake CPU.

### Source excerpt

In Rust, what is the performance cost of using sync::Once after the initial setup?

## Underrust: Does it matter what type (u8, u32, ...) I use?

DevFeed: [Underrust: Does it matter what type (u8, u32, ...) I use?](<https://devfeed.tech/articles/underrust-does-it-matter-what-type-u8-u32-i-use-35390.md>)

Original publisher: [Read original article](<https://darkcoding.net/software/does-it-matter-what-type-i-use/>)

Author: Graham King

Published: 2022-09-02T07:00:00Z

Content type: tutorial

Language: en

Sources: [Graham King](<https://devfeed.tech/sources/graham-king.md>)

Topics: [Rust](<https://devfeed.tech/topics/rust.md>), [cpu](<https://devfeed.tech/topics/cpu.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>)

Tags: [assembly](<https://devfeed.tech/tags/assembly.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [memory](<https://devfeed.tech/tags/memory.md>), [performance](<https://devfeed.tech/tags/performance.md>), [rust](<https://devfeed.tech/tags/rust.md>), [software](<https://devfeed.tech/tags/software.md>), [underrust](<https://devfeed.tech/tags/underrust.md>)

### AI overview

This Rust article examines how primitive type choices affect memory usage, cache-line capacity, stack space, and potentially performance. It also explains that signed and unsigned integer types generate identical CPU assembly in the demonstrated cases.

### Source excerpt

In Rust, how does using a different primitive type (u8, i32, u64, ...) change the generated assembly?

## The Underrust: Rust's assembly output

DevFeed: [The Underrust: Rust's assembly output](<https://devfeed.tech/articles/the-underrust-rust-s-assembly-output-35480.md>)

Original publisher: [Read original article](<https://darkcoding.net/software/underrust-rust-assembly-output/>)

Author: Graham King

Published: 2022-08-31T07:00:00Z

Content type: tutorial

Language: en

Sources: [Graham King](<https://devfeed.tech/sources/graham-king.md>)

Topics: [Rust](<https://devfeed.tech/topics/rust.md>), [Assembly](<https://devfeed.tech/topics/assembly.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>), [LLVM](<https://devfeed.tech/topics/llvm.md>), [cpu](<https://devfeed.tech/topics/cpu.md>), [Linux](<https://devfeed.tech/topics/linux.md>), [linker](<https://devfeed.tech/topics/linker.md>)

Tags: [assembly](<https://devfeed.tech/tags/assembly.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [linker](<https://devfeed.tech/tags/linker.md>), [linux](<https://devfeed.tech/tags/linux.md>), [llvm](<https://devfeed.tech/tags/llvm.md>), [optimize](<https://devfeed.tech/tags/optimize.md>), [performance](<https://devfeed.tech/tags/performance.md>), [rust](<https://devfeed.tech/tags/rust.md>), [software](<https://devfeed.tech/tags/software.md>), [underrust](<https://devfeed.tech/tags/underrust.md>)

### AI overview

This article introduces the Underrust series, which examines Rust programs through their generated assembly. It explains a repeatable setup using Rust on Linux with an Intel processor, a stripped-down program, LLVM optimizations, a custom entry point, and release builds to make assembly easier to inspect.

### Source excerpt

Assembly: In all the world of the programmer, there is no more important output.