Skip to content

Commit 23b2138

Browse files
Merge pull request #2560 from jasonrandrews/review
review Rust on Axion Learning Path
2 parents d04e121 + 43c806e commit 23b2138

File tree

3 files changed

+92
-82
lines changed

3 files changed

+92
-82
lines changed
Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
11
---
2-
title: Rust Baseline Testing on Google Axion C4A Arm Virtual Machine
2+
title: Test Rust baseline performance on Google Axion C4A Arm virtual machines
33
weight: 5
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9-
## Rust Baseline Testing on GCP SUSE VMs
10-
This guide demonstrates how to perform baseline testing of Rust on GCP SUSE Arm64 VMs, verifying installation, build functionality, and compilation performance on the Arm-based Axion C4A platform.
9+
## Perform baseline testing
1110

12-
### Verify Installation
13-
Check the Rust version and toolchain setup:
11+
You can perform baseline testing of Rust on GCP SUSE aarch64 VMs to verify installation, build functionality, and compilation performance on the Arm-based Axion C4A platform.
1412

15-
```console
16-
rustc --version
17-
cargo --version
18-
```
19-
20-
You should see an output similar to:
21-
```output
22-
rustc 1.91.0 (f8297e351 2025-10-28)
23-
cargo 1.91.0 (ea2d97820 2025-10-10)
24-
```
13+
### Create a sample Rust program
2514

26-
### Create a Sample Rust Program
27-
Create and build a simple “Hello, World” application to ensure everything is functioning properly:
15+
Create and build a simple "Hello, World" application to verify that Rust is working correctly:
2816

2917
```console
3018
mkdir rust-baseline
@@ -33,30 +21,33 @@ cargo new hello
3321
cd hello
3422
cargo run
3523
```
36-
- **`mkdir rust-baseline`** – Creates a new directory named `rust-baseline`.
37-
- **`cd rust-baseline`** – Enters the `rust-baseline` directory.
38-
- **`cargo new hello`** – Creates a new Rust project named `hello` with default files (`main.rs`, `Cargo.toml`).
39-
- **`cd hello`** – Moves into the newly created `hello` project directory.
40-
- **`cargo run`** – Compiles and runs the Rust program, printing **“Hello, world!”**, confirming that Rust and Cargo are properly set up.
4124

42-
You should see an output similar to:
25+
This creates a new Rust project and runs it immediately. The `cargo new hello` command generates a default Rust project with the necessary files including `main.rs` and `Cargo.toml`.
26+
27+
The output is similar to:
28+
4329
```output
4430
Compiling hello v0.1.0 (/home/gcpuser/rust-baseline/hello)
4531
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.19s
4632
Running `target/debug/hello`
4733
Hello, world!
4834
```
4935

50-
### Measure Compilation Speed
51-
Use the time command to measure how long Rust takes to compile a small program:
36+
This confirms that Rust and Cargo are properly configured on your aarch64 VM.
37+
38+
### Measure compilation performance
39+
40+
Use the `time` command to measure compilation performance on the Arm64 processor:
5241

5342
```console
5443
cargo clean
5544
time cargo build
5645
```
57-
This gives a rough idea of compilation performance on the Arm64 CPU.
5846

59-
You should see an output similar to:
47+
The `cargo clean` command removes all build artifacts, ensuring you measure a complete compilation from scratch.
48+
49+
The output is similar to:
50+
6051
```output
6152
Removed 21 files, 7.7MiB total
6253
Compiling hello v0.1.0 (/home/gcpuser/rust-baseline/hello)
@@ -66,4 +57,5 @@ real 0m0.186s
6657
user 0m0.118s
6758
sys 0m0.071s
6859
```
69-
This confirms that Rust is working properly on your Arm64 VM.
60+
61+
The timing results show that Rust compilation performs well on the Arm64 architecture, with the "real" time indicating the total elapsed time for the build process.
Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,27 @@
11
---
2-
title: Rust Benchmarking
2+
title: Benchmark Rust performance using Criterion
33
weight: 6
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9+
## Benchmark Rust performance
910

10-
## Rust Benchmarking by cargo bench
11-
This section demonstrates how to benchmark Rust performance using **official Rust benchmarking tools**`cargo bench` and the **Criterion** library — to measure code execution speed, stability, and performance consistency on Arm64 hardware.
11+
This section demonstrates how to benchmark Rust performance using `cargo bench` and the Criterion library to measure code execution speed and performance consistency on aarch64 hardware.
1212

13-
### Verify Rust and Cargo
14-
Ensure that Rust and Cargo are properly installed before running benchmarks
13+
### Create a benchmark project
1514

16-
```console
17-
rustc --version
18-
cargo --version
19-
```
20-
21-
You should see an output similar to:
22-
```output
23-
rustc 1.91.0 (f8297e351 2025-10-28)
24-
cargo 1.91.0 (ea2d97820 2025-10-10)
25-
```
26-
27-
### Create a New Rust Project
28-
Create a new Rust project for benchmarking:
15+
Create a new Rust project specifically for benchmarking:
2916

3017
```console
3118
cargo new rust-benchmark
3219
cd rust-benchmark
3320
```
34-
### Add Criterion Benchmarking Dependency
35-
**Criterion** is the officially recommended benchmarking crate for Rust. Add it to your project by editing the `Cargo.toml` file located inside your project root directory using your favorite editor (location example: rust-benchmark/Cargo.toml). Replace your "[dependencies]" tag within your file with this content, then save the file:
21+
22+
### Configure Criterion as a dependency
23+
24+
Criterion is the recommended benchmarking crate for Rust. Edit the `Cargo.toml` file in your project root directory and replace the existing content with:
3625

3726
```toml
3827
[dependencies]
@@ -42,20 +31,24 @@ criterion = "0.5"
4231
name = "my_benchmark"
4332
harness = false
4433
```
45-
This enables Criterion for high-precision benchmarking.
4634

47-
### Create the Benchmark File
48-
Create a new benchmark file inside the `benches/` directory using your favorite editor ("edit" used in the example below):
35+
This configuration enables Criterion for high-precision benchmarking and disables the default test harness.
36+
37+
### Create the benchmark directory and file
38+
39+
Create the benchmark structure that Cargo expects:
4940

5041
```console
5142
mkdir benches
52-
edit benches/my_benchmark.rs
5343
```
54-
Benchmark files in this directory are automatically detected by Cargo.
5544

56-
**Add the Benchmark Code**
45+
Create a new benchmark file in the `benches/` directory:
46+
47+
```console
48+
edit benches/my_benchmark.rs
49+
```
5750

58-
Paste the following benchmark code:
51+
Add the following benchmark code to measure Fibonacci number calculation performance:
5952

6053
```rust
6154
use criterion::{black_box, Criterion, criterion_group, criterion_main};
@@ -76,17 +69,21 @@ fn benchmark_fibonacci(c: &mut Criterion) {
7669
criterion_group!(benches, benchmark_fibonacci);
7770
criterion_main!(benches);
7871
```
79-
This code measures how efficiently Rust computes the 20th Fibonacci number.
8072

81-
### Run the Benchmark
82-
Now run the benchmark using Cargo:
73+
This code implements a recursive Fibonacci function and measures how efficiently Rust computes the 20th Fibonacci number. The `black_box` function prevents the compiler from optimizing away the benchmark.
74+
75+
### Run the benchmark
76+
77+
Execute the benchmark using Cargo:
8378

8479
```console
8580
cargo bench
8681
```
87-
Cargo compiles your code in optimized mode and runs the Criterion benchmarks, showing execution time, performance deviation, and stability metrics for your Rust functions.
8882

89-
You should see an output similar to:
83+
Cargo compiles your code with optimizations enabled and runs the Criterion benchmarks, providing detailed performance metrics.
84+
85+
The output is similar to:
86+
9087
```output
9188
Running benches/my_benchmark.rs (target/release/deps/my_benchmark-f40a307ef9cad515)
9289
Gnuplot not found, using plotters backend
@@ -102,14 +99,22 @@ Found 1 outliers among 100 measurements (1.00%)
10299
- **Plotting Backend:** Used `plotters` since Gnuplot was not found.
103100
- The results show **consistent performance** with only slight variation across 100 measurements.
104101

105-
### Benchmark summary
106-
Results from the earlier run on the `c4a-standard-4` (4 vCPU, 16 GB memory) Arm64 VM in GCP (SUSE):
102+
### Understand the results
103+
104+
The benchmark output provides several key metrics:
105+
106+
- **Average time**: Mean execution time across benchmark runs
107+
- **Outliers**: Runs significantly slower or faster than average
108+
- **Plotting backend**: Uses plotters since Gnuplot wasn't found
109+
110+
The results show consistent performance with only slight variation across 100 measurements.
111+
112+
### Performance summary
113+
114+
The following table shows results from running the benchmark on a `c4a-standard-4` (4 vCPU, 16 GB memory) aarch64 VM in GCP using SUSE:
107115

108-
| **Benchmark** | **Average Time (µs)** | **Min (µs)** | **Max (µs)** | **Outliers (%)** | **Remarks** |
109-
|--------------------|----------------------:|--------------:|--------------:|-----------------:|----------------------------------|
110-
| **fibonacci 20** | 12.028 | 12.026 | 12.030 | 1.00% | Very stable performance, minimal variation. |
116+
| Benchmark | Average Time (µs) | Min (µs) | Max (µs) | Outliers (%) | Remarks |
117+
|---------------|------------------:|---------:|---------:|-------------:|---------|
118+
| fibonacci 20 | 12.028 | 12.026 | 12.030 | 1.00% | Stable performance with minimal variation |
111119

112-
- The **Fibonacci (n=20)** benchmark demonstrated **consistent performance** with minimal deviation.
113-
- **Average execution time** was around **12.028 µs**, indicating efficient CPU computation on **Arm64**.
114-
- Only **1% outliers** were detected, showing **high stability** and **repeatability** of results.
115-
- Overall, the test confirms **Rust’s reliable execution speed** and **low variance** on the Arm64 platform.
120+
The Fibonacci benchmark demonstrates consistent performance on the aarch64 platform. The average execution time of 12.028 µs indicates efficient CPU computation, while only 1% of measurements were outliers. This low variance confirms Rust's reliable execution speed and performance stability on aarch64 architecture.

content/learning-paths/servers-and-cloud-computing/rust-on-gcp/installation.md

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,56 @@ weight: 4
66
layout: learningpathall
77
---
88

9-
## Rust Installation on GCP SUSE VM
10-
This guide explains how to install and configure Rust on a GCP SUSE Arm64 VM, ensuring the environment is ready for building and benchmarking Rust applications.
9+
## Install Rust
1110

12-
### System Preparation
13-
Updates the system and installs essential build tools for compiling Rust programs.
11+
This section explains how to install and configure Rust on a GCP SUSE aarch64 VM, preparing your environment for building and benchmarking Rust applications.
12+
13+
### Update your system
14+
15+
Update the system and install essential build tools required for compiling Rust programs:
1416

1517
```console
1618
sudo zypper refresh
1719
sudo zypper update -y
1820
sudo zypper install -y curl gcc make
1921
```
20-
### Install Rust Using rustup
21-
Rust provides an official installer script via `rustup`, which handles the setup automatically:
22+
23+
This ensures your system has the latest packages and the necessary compilation tools.
24+
25+
### Install Rust using rustup
26+
27+
Rust provides an official installer script via `rustup` that handles the setup automatically:
2228

2329
```console
2430
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
2531
```
26-
When prompted, you can choose **option 1** (default installation).
2732

28-
### Configure Rust Environment
29-
Activates Rust’s environment variables for the current shell session.
33+
When prompted, select option 1 for the default installation. This installs the latest stable version of Rust along with Cargo, Rust's package manager and build system.
34+
35+
### Configure your environment
36+
37+
Activate Rust's environment variables for your current shell session:
3038

3139
```console
3240
source $HOME/.cargo/env
3341
```
3442

35-
### Verify Rust Installation
36-
Confirms successful installation of Rust and Cargo by checking their versions.
43+
This command adds the Rust toolchain to your PATH, making the `rustc` compiler and `cargo` commands available.
44+
45+
### Verify the installation
46+
47+
Confirm that Rust and Cargo installed successfully by checking their versions:
3748

3849
```console
3950
rustc --version
4051
cargo --version
4152
```
4253

43-
You should see an output similar to:
54+
The output is similar to:
55+
4456
```output
4557
rustc 1.91.0 (f8297e351 2025-10-28)
4658
cargo 1.91.0 (ea2d97820 2025-10-10)
4759
```
48-
Rust installation is complete. You can now go ahead with the baseline testing of Rust in the next section.
60+
61+
Your Rust installation is now complete and ready for development on the aarch64 platform.

0 commit comments

Comments
 (0)