forked from ArmDeveloperEcosystem/arm-learning-paths
-
Notifications
You must be signed in to change notification settings - Fork 1
Deploy Rust on Google Cloud C4A (Arm-based Axion VMs) #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
odidev
wants to merge
1
commit into
main
Choose a base branch
from
rust_LP
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
content/learning-paths/servers-and-cloud-computing/rust-on-gcp/_index.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" | ||
| --- |
8 changes: 8 additions & 0 deletions
8
content/learning-paths/servers-and-cloud-computing/rust-on-gcp/_next-steps.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. | ||
| --- |
24 changes: 24 additions & 0 deletions
24
content/learning-paths/servers-and-cloud-computing/rust-on-gcp/background.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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/). |
63 changes: 63 additions & 0 deletions
63
content/learning-paths/servers-and-cloud-computing/rust-on-gcp/baseline.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. |
118 changes: 118 additions & 0 deletions
118
content/learning-paths/servers-and-cloud-computing/rust-on-gcp/benchmarking.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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): | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where is cargo.toml located?? Mention the location clearly. |
||
| ```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: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add spacing to avoid overlapping of lines. Check on Hugo. |
||
|
|
||
| ```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. | ||
Binary file added
BIN
+261 KB
content/learning-paths/servers-and-cloud-computing/rust-on-gcp/images/gcp-vm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions
48
content/learning-paths/servers-and-cloud-computing/rust-on-gcp/installation.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. |
31 changes: 31 additions & 0 deletions
31
content/learning-paths/servers-and-cloud-computing/rust-on-gcp/instance.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. | ||
|
|
||
|  | ||
|
|
||
| - 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. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you missed adding steps to verify the installation???
Probably below: