Errata

Async Rust

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
O'Reilly learning platform Page chapter 1
What is Async, paragraph after main code sample

"If we then run this code, we will see that our even though the number of threads and processes do not even come close to doubling, but our CPU usage jumps to 99.95%."

This is awkwardly phrased.
"see that our even though" => "see that even though"

The use of comas doesn't seem right ("but" should be removed?).
"if we then run this code, ..., but ..."

Technically, the 99.95% cpu usage assumes it's running on a machine with <= 8 cores.

Anonymous  Dec 16, 2023 
O'Reilly learning platform Page Chapter 1
What is Async, paragraph after main code sample

"There’s multiple nuances" => "There are multiple nuances"

Anonymous  Dec 16, 2023 
O'Reilly learning platform Page Chapter 1 "What is Async"
2nd paragraph after main example

"runs until it is interrupted or it is yielded by the CPU voluntarily"

The paragraph is attempting to talk about nuances in CPU design, but I don't understand how the statement above relates. An interrupt can cause a context switch to the operating system that can then schedule other work on the CPU, but I'm not sure what it means for a CPU to voluntarily yield. Is this trying to say that the thread returned with the calculated result?

Anonymous  Dec 16, 2023 
O'Reilly learning platform Page Chapter 1 "What is Async"
paragraph after figure 1-1

"If we were to use Tokio to join four Fibonacci computations we would not get an increase in speed as we are only using one thread."

This is misleading. If used similar to the Tokio reqwest example a multi-threaded runtime will be instantiated. Note the default behavior of the Tokio main macro is multi-threaded. The code sample below consumes 400% CPU. It would be more accurate to say "using one thread per task".

The point the author is trying to convey is that asynchrony does not speed up cpu-bound workloads. The following sentence gets back on track by describing that the work for one instance of the fibonacci calculation would need to be distributed across multiple cores.

#[tokio::main]
async fn main() {
let mut threads = Vec::new();

for i in 0..4 {
let handle = tokio::spawn(async move {
let result = fibonacci(4000);
println!("Thread {} result: {}", i, result);
});
threads.push(handle);
}
for handle in threads {
handle.await.unwrap();
}
}

fn fibonacci(n: u64) -> u64 {
if n == 0 || n == 1 {
return n;
}
fibonacci(n - 1) + fibonacci(n - 2)
}

Anonymous  Dec 16, 2023 
O'Reilly learning platform Page Chapter 1 "Introduction to Processes"
first paragraph

"A process is a program or application that is executed by the CPU."

A process is an abstraction provided by an operating system. It would be more correct to say it is executed by the operating system on a CPU. For a book focusing on asynchronous programming it seems like it would be important to clearly describe how the application makes use of OS-provided abstractions and functionality.

In the embedded space where applications run on bare metal asynchrony makes use of hardware interrupts but none of the context in this chapter suggests that's what's being discussed.

Anonymous  Dec 16, 2023 
O'Reilly learning platform Page ch2
Pinning in Futures

the duplicated 'expose expose'

Anonymous  May 11, 2024 
O'Reilly learning platform Page ch2
Pinning in Futures

in the example 'SelfReferential'.
"If you try and run the code, you will get a segmentation fault. The segmentation fault is an error caused by accessing memory that does not belong to the program." which is true because it's accessing the "freed" stack memory of SelfReferential::new() after it has returned, the error has no relationships with the ptr::swap operation.

correct the example by moving the self_pointer manipulation on main()'s stack and then do the swap + print is more clear.

Bruce  May 11, 2024 
O'Reilly learning platform Page ch2
HOW FUTURES IN RUST ARE DIFFERENT

duplicated 'when when'.

"The callback model uses a function that fires -->when when<-- another function completes."

Bruce  May 11, 2024 
O'Reilly learning platform Page ch4
ch4

typos in multiple paragraphs: "steam" should be "stream".

Bruce  May 13, 2024 
O'Reilly learning platform Page 1
chapter 1, first sentance

The phrase "increase in power of hardware" is awkward. It's not necessarily the "power" of the hardware that is interesting here but the relative performance. Perhaps the phrase "increase in hardware performance" would work better.

Anonymous  Dec 16, 2023 
O'Reilly learning platform Page 1
chapter 1, first paragraph

"microprocessor manufactures" should be "microprocessor manufacturers"

Anonymous  Dec 16, 2023