diff --git a/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/_index.md b/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/_index.md new file mode 100644 index 0000000000..5c3fe89ca4 --- /dev/null +++ b/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/_index.md @@ -0,0 +1,58 @@ +--- +title: Deploy Rust on Google Cloud C4A (Arm-based Axion VMs) + +minutes_to_complete: 30 + +who_is_this_for: This learning path is intended for software developers deploying and optimizing Rust workloads on Linux/Arm64 environments, specifically using Google Cloud C4A virtual machines powered by Axion processors. + +learning_objectives: + - Provision an Arm-based SUSE SLES virtual machine on Google Cloud (C4A with Axion processors) + - Install Rust and configure the development environment on a SUSE Arm64 (C4A) instance + - Verify Rust setup by compiling and running a sample program to ensure toolchain functionality + - Benchmark Rust using cargo bench with Criterion to measure execution speed, stability, and performance on Arm64 systems + +prerequisites: + - A [Google Cloud Platform (GCP)](https://cloud.google.com/free) account with billing enabled + - Basic familiarity with [Rust](https://www.rust-lang.org/) + +author: Pareena Verma + +##### Tags +skilllevels: Introductory +subjects: Performance and Architecture +cloud_service_providers: Google Cloud + +armips: + - Neoverse + +tools_software_languages: + - Rust + - Cargo + - Criterion + +operatingsystems: + - Linux + +# ================================================================================ +# FIXED, DO NOT MODIFY +# ================================================================================ +further_reading: + - resource: + title: Google Cloud documentation + link: https://cloud.google.com/docs + type: documentation + + - resource: + title: Rust documentation + link: https://doc.rust-lang.org/stable/ + type: documentation + + - resource: + title: Cargo bench documentation + link: https://doc.rust-lang.org/cargo/commands/cargo-bench.html + type: documentation + +weight: 1 +layout: "learningpathall" +learning_path_main_page: "yes" +--- diff --git a/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/_next-steps.md b/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/_next-steps.md new file mode 100644 index 0000000000..c3db0de5a2 --- /dev/null +++ b/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/_next-steps.md @@ -0,0 +1,8 @@ +--- +# ================================================================================ +# FIXED, DO NOT MODIFY THIS FILE +# ================================================================================ +weight: 21 # Set to always be larger than the content in this path to be at the end of the navigation. +title: "Next Steps" # Always the same, html page title. +layout: "learningpathall" # All files under learning paths have this same wrapper for Hugo processing. +--- diff --git a/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/background.md b/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/background.md new file mode 100644 index 0000000000..f777c8c4d5 --- /dev/null +++ b/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/background.md @@ -0,0 +1,24 @@ +--- +title: Getting started with Rust on Google Axion C4A (Arm Neoverse-V2) + +weight: 2 + +layout: "learningpathall" +--- + +## Google Axion C4A Arm instances in Google Cloud + +Google Axion C4A is a family of Arm-based virtual machines built on Google’s custom Axion CPU, which is based on Arm Neoverse-V2 cores. Designed for high-performance and energy-efficient computing, these virtual machines offer strong performance for modern cloud workloads such as CI/CD pipelines, microservices, media processing, and general-purpose applications. + +The C4A series provides a cost-effective alternative to x86 virtual machines while leveraging the scalability and performance benefits of the Arm architecture in Google Cloud. + +To learn more about Google Axion, refer to the [Introducing Google Axion Processors, our new Arm-based CPUs](https://cloud.google.com/blog/products/compute/introducing-googles-new-arm-based-cpu) blog. + +## Rust + +[Rust](https://www.rust-lang.org/) is a modern, high-performance systems programming language designed for safety, speed, and concurrency. It provides memory safety without garbage collection, making it ideal for building reliable and efficient software. + +Developed by Mozilla, Rust is widely used in system-level programming, web assembly, embedded systems, and performance-critical applications. +Its strong type system and ownership model help prevent common bugs like data races and memory leaks. + +To learn more, visit the [official Rust website](https://www.rust-lang.org/). diff --git a/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/baseline.md b/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/baseline.md new file mode 100644 index 0000000000..8c43e5328f --- /dev/null +++ b/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/baseline.md @@ -0,0 +1,63 @@ +--- +title: Rust Baseline Testing on Google Axion C4A Arm Virtual Machine +weight: 5 + +### FIXED, DO NOT MODIFY +layout: learningpathall +--- + +## Rust Baseline Testing on GCP SUSE VMs +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. + +### Verify Installation +Check the Rust version and toolchain setup: + +```console +rustc --version +cargo --version +``` + +### Create a Sample Rust Program +Create and build a simple “Hello, World” application to ensure everything is functioning properly: + +```console +mkdir rust-baseline +cd rust-baseline +cargo new hello +cd hello +cargo run +``` +- **`mkdir rust-baseline`** – Creates a new directory named `rust-baseline`. +- **`cd rust-baseline`** – Enters the `rust-baseline` directory. +- **`cargo new hello`** – Creates a new Rust project named `hello` with default files (`main.rs`, `Cargo.toml`). +- **`cd hello`** – Moves into the newly created `hello` project directory. +- **`cargo run`** – Compiles and runs the Rust program, printing **“Hello, world!”**, confirming that Rust and Cargo are properly set up. + +You should see an output similar to: +```output + Compiling hello v0.1.0 (/home/gcpuser/rust-baseline/hello) + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.19s + Running `target/debug/hello` +Hello, world! +``` + +### Measure Compilation Speed +Use the time command to measure how long Rust takes to compile a small program: + +```console +cargo clean +time cargo build +``` +This gives a rough idea of compilation performance on the Arm64 CPU. + +You should see an output similar to: +```output +Removed 21 files, 7.7MiB total + Compiling hello v0.1.0 (/home/gcpuser/rust-baseline/hello) + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.14s + +real 0m0.186s +user 0m0.118s +sys 0m0.071s +``` +This confirms that Rust is working properly on your Arm64 VM. diff --git a/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/benchmarking.md b/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/benchmarking.md new file mode 100644 index 0000000000..9af710801a --- /dev/null +++ b/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/benchmarking.md @@ -0,0 +1,118 @@ +--- +title: Rust Benchmarking +weight: 6 + +### FIXED, DO NOT MODIFY +layout: learningpathall +--- + + +## Rust Benchmarking by cargo bench +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. + +### Verify Rust and Cargo +Ensure that Rust and Cargo are properly installed before running benchmarks + +```console +rustc --version +cargo --version +``` + +### Create a New Rust Project +Create a new Rust project for benchmarking: + +```console +cargo new rust-benchmark +cd rust-benchmark +``` +### Add Criterion Benchmarking Dependency +**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 (for example, rust-benchmark/Cargo.toml): + +```toml +[dependencies] +criterion = "0.5" + +[[bench]] +name = "my_benchmark" +harness = false +``` +This enables Criterion for high-precision benchmarking. + +### Create the Benchmark File +Create a new benchmark file inside the `benches/` directory: + +```console +mkdir benches +vi benches/my_benchmark.rs +``` +Benchmark files in this directory are automatically detected by Cargo. + +**Add the Benchmark Code** + +Paste the following benchmark code: + +```rust +use criterion::{black_box, Criterion, criterion_group, criterion_main}; + +// Example benchmark function +fn fibonacci(n: u64) -> u64 { + match n { + 0 => 0, + 1 => 1, + n => fibonacci(n - 1) + fibonacci(n - 2), + } +} + +fn benchmark_fibonacci(c: &mut Criterion) { + c.bench_function("fibonacci 20", |b| b.iter(|| fibonacci(black_box(20)))); +} + +criterion_group!(benches, benchmark_fibonacci); +criterion_main!(benches); +``` +This code measures how efficiently Rust computes the 20th Fibonacci number. + +### Run the Benchmark +Now run the benchmark using Cargo: + +```console +cargo bench +``` +Cargo compiles your code in optimized mode and runs the Criterion benchmarks, showing execution time, performance deviation, and stability metrics for your Rust functions. + +You should see an output similar to: +```output +Running benches/my_benchmark.rs (target/release/deps/my_benchmark-f40a307ef9cad515) +Gnuplot not found, using plotters backend +fibonacci 20 time: [12.026 µs 12.028 µs 12.030 µs] +Found 1 outliers among 100 measurements (1.00%) + 1 (1.00%) low mild +``` + +### Benchmark Metrics Explanation + +- **Average Time:** Mean execution time across benchmark runs. +- **Outliers:** Represent runs significantly slower or faster than average. +- **Plotting Backend:** Used `plotters` since Gnuplot was not found. +- The results show **consistent performance** with only slight variation across 100 measurements. + +### Benchmark summary on x86_64 +To compare the benchmark results, the following results were collected by running the same benchmark on a `x86 - c4-standard-4` (4 vCPUs, 15 GB Memory) x86_64 VM in GCP, running SUSE: + +| **Benchmark** | **Average Time (µs)** | **Min (µs)** | **Max (µs)** | **Outliers (%)** | **Remarks** | +|--------------------|----------------------:|--------------:|--------------:|-----------------:|----------------------------------| +| **fibonacci 20** | 19.152 | 19.100 | 19.205 | 6.00% | Minor outliers, stable overall. | + +### Benchmark summary on Arm64 +Results from the earlier run on the `c4a-standard-4` (4 vCPU, 16 GB memory) Arm64 VM in GCP (SUSE): + +| **Benchmark** | **Average Time (µs)** | **Min (µs)** | **Max (µs)** | **Outliers (%)** | **Remarks** | +|--------------------|----------------------:|--------------:|--------------:|-----------------:|----------------------------------| +| **fibonacci 20** | 12.028 | 12.026 | 12.030 | 1.00% | Very stable performance, minimal variation. | + +### Rust benchmarking comparison on Arm64 and x86_64 + +- The **Fibonacci (n=20)** benchmark demonstrated **consistent performance** with minimal deviation. +- **Average execution time** was around **12.028 µs**, indicating efficient CPU computation on **Arm64**. +- Only **1% outliers** were detected, showing **high stability** and **repeatability** of results. +- Overall, the test confirms **Rust’s reliable execution speed** and **low variance** on the Arm64 platform. diff --git a/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/images/gcp-vm.png b/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/images/gcp-vm.png new file mode 100644 index 0000000000..0d1072e20d Binary files /dev/null and b/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/images/gcp-vm.png differ diff --git a/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/installation.md b/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/installation.md new file mode 100644 index 0000000000..0e5d971393 --- /dev/null +++ b/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/installation.md @@ -0,0 +1,48 @@ +--- +title: Install Rust +weight: 4 + +### FIXED, DO NOT MODIFY +layout: learningpathall +--- + +## Rust Installation on GCP SUSE VM +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. + +### System Preparation +Updates the system and installs essential build tools for compiling Rust programs. + +```console +sudo zypper refresh +sudo zypper update -y +sudo zypper install -y curl gcc make +``` +### Install Rust Using rustup +Rust provides an official installer script via `rustup`, which handles the setup automatically: + +```console +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +``` +When prompted, you can choose **option 1** (default installation). + +### Configure Rust Environment +Activates Rust’s environment variables for the current shell session. + +```console +source $HOME/.cargo/env +``` + +### Verify Rust Installation +Confirms successful installation of Rust and Cargo by checking their versions. + +```console +rustc --version +cargo --version +``` + +You should see an output similar to: +```output +rustc 1.91.0 (f8297e351 2025-10-28) +cargo 1.91.0 (ea2d97820 2025-10-10) +``` +Rust installation is complete. You can now go ahead with the baseline testing of Rust in the next section. diff --git a/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/instance.md b/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/instance.md new file mode 100644 index 0000000000..2b93bc950d --- /dev/null +++ b/content/learning-paths/servers-and-cloud-computing/rust-on-gcp/instance.md @@ -0,0 +1,31 @@ +--- +title: Create a Google Axion C4A Arm virtual machine on GCP +weight: 3 + +### FIXED, DO NOT MODIFY +layout: learningpathall +--- + +## Overview + +In this section, you will learn how to provision a Google Axion C4A Arm virtual machine on Google Cloud Platform (GCP) using the `c4a-standard-4` (4 vCPUs, 16 GB memory) machine type in the Google Cloud Console. + +{{% notice Note %}} +For support on GCP setup, see the Learning Path [Getting started with Google Cloud Platform](https://learn.arm.com/learning-paths/servers-and-cloud-computing/csp/google/). +{{% /notice %}} + +## Provision a Google Axion C4A Arm VM in Google Cloud Console + +To create a virtual machine based on the C4A instance type: +- Navigate to the [Google Cloud Console](https://console.cloud.google.com/). +- Go to **Compute Engine > VM Instances** and select **Create Instance**. +- Under **Machine configuration**: + - Populate fields such as **Instance name**, **Region**, and **Zone**. + - Set **Series** to `C4A`. + - Select `c4a-standard-4` for machine type. + + ![Create a Google Axion C4A Arm virtual machine in the Google Cloud Console with c4a-standard-4 selected alt-text#center](images/gcp-vm.png "Creating a Google Axion C4A Arm virtual machine in Google Cloud Console") + +- Under **OS and Storage**, select **Change**, then choose an Arm64-based OS image. For this Learning Path, use **SUSE Linux Enterprise Server**. Pick the preferred version for your Operating System. Ensure you select the **Arm image** variant. Click **Select**. +- Under **Networking**, enable **Allow HTTP traffic**. +- Click **Create** to launch the instance.