Skip to content

Go/Sweet benchmarks #2027

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
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
65e957e
Creating the index and first page.
geremyCohen May 8, 2025
e6e34b8
Creating the C4 install page.
geremyCohen May 9, 2025
4854a63
automatic update of stats files
May 19, 2025
bc6a339
Merge branch 'main' into go_sweet_bench
geremyCohen May 21, 2025
9643f63
Creating file structure
geremyCohen May 21, 2025
6fa780b
v1 of overview
geremyCohen May 21, 2025
3415039
wip
geremyCohen May 22, 2025
f4681c0
wip w/running remote benchmark runner
geremyCohen May 22, 2025
d89df07
Run benchmarks in parallel
geremyCohen May 22, 2025
a467fac
First version of visualizer, tested on etcd txt benchmark output
geremyCohen May 26, 2025
8ae04ff
automatic update of stats files
May 26, 2025
60c7259
Grouped values by instance by metric
geremyCohen May 27, 2025
313fb41
Added delta % below each grouping
geremyCohen May 27, 2025
3b1f133
Cleaned up labels a bit more
geremyCohen May 29, 2025
01eacdb
fixed formatting, unused imports
geremyCohen May 29, 2025
6f55cfb
Added arg parsing to override test defaults, and requirements.txt
geremyCohen May 30, 2025
e4502ab
Remove geomean chart since it is not a consistent metric.
geremyCohen May 30, 2025
cd98edc
Remove overall geomean chart, derive hostnames for instances, and fix…
geremyCohen May 30, 2025
7a57b36
Added argparse enhancements
geremyCohen May 30, 2025
b93d620
automatic update of stats files
Jun 2, 2025
6a5e8a3
Made some charting optimizations
geremyCohen Jun 2, 2025
74e3173
Set bar chart mode to group
geremyCohen Jun 2, 2025
a82824a
Tested install script for both archs
geremyCohen Jun 2, 2025
0e0137f
Sped up instances selection
geremyCohen Jun 2, 2025
1923e1b
Enhanced instance selection and visualization prompts in benchmark ex…
geremyCohen Jun 2, 2025
9772c30
Inlined benchstat_report into rexec_sweet
geremyCohen Jun 3, 2025
5930176
Improved chart labels
geremyCohen Jun 3, 2025
157891f
Enhance report generation output and automatically open in browser
geremyCohen Jun 3, 2025
691cff8
autoselect directory to chart
geremyCohen Jun 3, 2025
c07fbab
removed gvisor as its not supported on arm
geremyCohen Jun 3, 2025
6186594
WIP: Added manual benchstat/benchmarking procedure.
geremyCohen Jun 3, 2025
b5ed42b
WIP: Added automated procedure
geremyCohen Jun 4, 2025
42dcfc7
WIP: Added automated procedure
geremyCohen Jun 4, 2025
14a4f50
WIP: Added automated procedure
geremyCohen Jun 4, 2025
677d11f
Refactored into modules
geremyCohen Jun 6, 2025
276b2d9
automatic update of stats files
Jun 9, 2025
db12396
Refactored v2 with Q
geremyCohen Jun 9, 2025
eba8f76
Added tests
geremyCohen Jun 9, 2025
db8bb89
better defaults
geremyCohen Jun 9, 2025
184059d
Refactor WIP
geremyCohen Jun 10, 2025
2fd095d
WIP
geremyCohen Jun 10, 2025
57e6c07
WIP
geremyCohen Jun 10, 2025
66aa6bc
WIP
geremyCohen Jun 10, 2025
51dd7c2
WIP
geremyCohen Jun 11, 2025
3da5263
Finished final chapter
geremyCohen Jun 11, 2025
cb09dea
UI clean up
geremyCohen Jun 11, 2025
7f71cb6
Final copyedits before PR
geremyCohen Jun 11, 2025
b8ce091
Merge branch 'main' into go_sweet_bench
geremyCohen Jun 11, 2025
95b777d
Merge branch 'main' into go_sweet_bench
geremyCohen Jun 11, 2025
6a6ddb3
Delete content/learning-paths/servers-and-cloud-computing/go-benchmar…
geremyCohen Jun 11, 2025
71d971c
Delete content/learning-paths/servers-and-cloud-computing/go-benchmar…
geremyCohen Jun 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: Go Benchmarks with Sweet and Benchstat

minutes_to_complete: 60

who_is_this_for: This learning path is for developers who are interested in measuring the performance of Go-based applications on their servers.

learning_objectives:
- Bring up two instances of GCP VMs
- Install Go, benchmarks, benchstat, and sweet on the two VMs
- Using sweet and benchstat, compare performance of Go applications on the two VMs

prerequisites:
- A [Google Cloud account](https://console.cloud.google.com/). This learning path can be run on-prem or on any cloud provider, but specifically documents the process on GCP's Google Axion platform.
- A local machine with [Google Cloud CLI](/install-guides/gcloud/) installed.

author: Geremy Cohen

### Tags
skilllevels: Introductory
subjects: Performance and Architecture
armips:
- Neoverse
tools_software_languages:

operatingsystems:
- Linux



### FIXED, DO NOT MODIFY
# ================================================================================
weight: 1 # _index.md always has weight of 1 to order correctly
layout: "learningpathall" # All files under learning paths have this same wrapper
learning_path_main_page: "yes" # This should be surfaced when looking for related content. Only set for _index.md of learning path content.
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# ================================================================================
# FIXED, DO NOT MODIFY THIS FILE
# ================================================================================
weight: 999 # 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.
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: Launching an Intel C4 Instance
weight: 30

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## Section Overview
In this section, you will set up the second benchmarking system, an Intel-based c4-standard-8 instance.

## Creating the Instance

To create the second system, follow the previous lesson's c4a install instructions, but make the following changes:

1. **Name your instance:** For the `Name` field, enter "c4".

2. **Select machine series:** Scroll down to the Machine series section, and select the C4 radio button.

![](images/launch_c4/3.png)

3. **View machine types:** Scroll down to the Machine type dropdown, and click it to show all available options.

![](images/launch_c4/4.png)

4. **Choose machine size:** Select "c4-standard-8" under the Standard tab.

![](images/launch_c4/5.png)

After the c4 instance starts up, you are ready to continue to the next section, where you'll install the benchmarking software.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
title: Launching an Arm Axion C4a Instance
weight: 20

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## Section Overview
In this section, you'll learn how to spin up the first of two different systems used in our benchmarking tests, an Arm-based Google Axion c4a-standard-4 (c4a for short).

## Creating the c4a-standard-4 Instance

1. **Access Google Cloud Console:** Navigate to [https://console.cloud.google.com/welcome](https://console.cloud.google.com/welcome)

2. **Search for VM instances:** Click into the Search field.

3. **Find VM Instances:** Start typing `vm` until the UI auto-completes `VM Instances`, then click it.

![](images/launch_c4a/3.png)

The VM Instances page appears.

4. **Create a new instance:** Click `Create instance`

![](images/launch_c4a/4.png)

The Machine configuration page appears.

5. **Name your instance:** Click the `Name` field, and enter "c4a" for the `Name`.

![](images/launch_c4a/5.png)

6. **Select machine series:** Scroll down to the Machine series section, and select the C4A radio button.

![](images/launch_c4a/7.png)

7. **View machine types:** Scroll down to the Machine type dropdown, and click it to show all available options.

![](images/launch_c4a/8.png)

8. **Choose machine size:** Select "c4a-standard-4" under the Standard tab.

![](images/launch_c4a/9.png)

9. **Configure storage:** Click the "OS and Storage" tab.

![](images/launch_c4a/10.png)

10. **Modify storage settings:** Click "Change"

![](images/launch_c4a/11.png)

11. **Set disk size:** Double-click the "Size (GB)" field, then enter "1000" for the value.

![](images/launch_c4a/16.png)

12. **Confirm storage settings:** Click "Select" to continue.

![](images/launch_c4a/18.png)

13. **Launch the instance:** Click "Create" to bring up the instance.

![](images/launch_c4a/19.png)

After a few seconds, your c4a instance starts up, and you are ready to continue to the next section. In the next step, you will launch the second system, an Intel-based Emerald Rapids c4-standard-8 (c4 for short), which will serve as the comparison system for our benchmarking tests.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---
title: Installing Go and Sweet
weight: 40

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## Section Overview

In this section, you'll install Go, Sweet, and the Benchstat comparison tool on both VMs.

## Installation Script

Sweet is a Go benchmarking tool that provides a standardized way to run performance tests across different systems. Benchstat is a companion tool that analyzes and compares benchmark results, helping you understand performance differences between systems. Together, these tools will allow us to accurately measure and compare Go performance on Arm and x86 architectures.


{{% notice Note %}}
Subsequent steps in the learning path assume you are running this script (installing) from your home directory (`~`), resulting in the creation of a `~/benchmarks/sweet` final install path. If you decide to install elsewhere, adjust the path accordingly when prompted to run the benchmark logic later in the learning path.
{{% /notice %}}


Copy and paste this script to **both** of your GCP VMs.

**You don't need to run it after pasting**, just paste it into your home directory and press enter to install all needed dependencies:

```bash
#!/usr/bin/env bash

# Write the script to filesystem using a HEREDOC
cat <<'EOF' > install_go_and_sweet.sh

sudo apt-get -y update
sudo apt-get -y install git build-essential

# Detect architecture - this allows the same script to work on both
# our Arm (c4a) and x86 (c4) VMs without modification
ARCH=$(uname -m)
case "$ARCH" in
arm64|aarch64)
GO_PKG="go1.24.2.linux-arm64.tar.gz"
;;
x86_64|amd64)
GO_PKG="go1.24.2.linux-amd64.tar.gz"
;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac

# Download and install architecture-specific Go environments

URL="https://go.dev/dl/${GO_PKG}"
echo "Downloading $URL..."
wget -q --show-progress "$URL"

echo "Extracting $GO_PKG to /usr/local..."
sudo tar -C /usr/local -xzf "$GO_PKG"


echo "Go 1.24.2 installed successfully for $ARCH."

export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN:/usr/local/go/bin

# Install Sweet, benchmarks, and benchstat tools
go install golang.org/x/benchmarks/sweet/cmd/sweet@latest
go install golang.org/x/perf/cmd/benchstat@latest

git clone https://github.com/golang/benchmarks
cd benchmarks/sweet
sweet get -force # to get assets

# Create a configuration file

cat <<CONFFILE > config.toml
[[config]]
name = "arm-benchmarks"
goroot = "/usr/local/go"

CONFFILE

EOF

# Make the script executable
chmod 755 install_go_and_sweet.sh

# Run the script
./install_go_and_sweet.sh

```



## Verify Installation

To test that everything is installed correctly, run the following command on each VM after the script completes:

```bash
# Run the benchmarks
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN:/usr/local/go/bin
cd benchmarks/sweet
sweet run -count 10 -run="markdown" config.toml # run one, 1X
```

You should see output similar to the following:

```bash
# Example output:
[sweet] Work directory: /tmp/gosweet3444550660
[sweet] Benchmarks: markdown (10 runs)
[sweet] Setting up benchmark: markdown
[sweet] Running benchmark markdown for arm-benchmarks: run 1
...
[sweet] Running benchmark markdown for arm-benchmarks: run 10
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: Manually running benchmarks
weight: 51

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## Section Overview

In this section, you'll run benchmarks manually to understand how `sweet` and `benchstat` work together.

## Run Benchmarks on Each Machine
The following explains how to run the benchmarks by hand on each machine.

1. **Access VM instances:** Navigate to the GCP [VM Instances](https://console.cloud.google.com/compute/instances) console.

2. **Connect to c4a instance:** Click on the `SSH` button next to your `c4a` instance.
An SSH terminal will open in a new tab.

![](images/run_manually/2.png)

3. **Set up environment:** Copy and paste the following into the SSH terminal to setup the environment and change to the sweet directory:

```bash
cd benchmarks/sweet
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN:/usr/local/go/bin
```

![](images/run_manually/3.png)

{{% notice Note %}}
The above instructions assume you installed the benchmarks in the `~/benchmarks/sweet` directory. If you installed them elsewhere, adjust the path accordingly.
{{% /notice %}}


4. **Run the benchmark:** Copy and paste the following command to run the `markdown` benchmark with `sweet`:

```bash
sweet run -count 10 -run="markdown" config.toml
```

5. **Locate results:** After the benchmark completes, cd to the `results/markdown` directory and list the files to see the `arm-benchmarks.result` file:

```bash
cd results/markdown
ls -d $PWD/*
```

6. **Copy result path:** Copy the absolute pathname of `arm-benchmarks.result`.

7. **Download results:** Click `DOWNLOAD FILE`, and paste the **ABSOLUTE PATHNAME** you just copied for the filename, and then click `Download`. This will download the benchmark results to your local machine.

![](images/run_manually/6.png)

8. **Rename the file:** Once downloaded, on your local machine, rename this file to `c4a.result` so you can distinguish it from the x86 results you'll download later. This naming convention will help you clearly identify which results came from which architecture. You'll know the file downloaded successfully if you see the file in your Downloads directory with the name `c4a.result`, as well as the confirmation dialog in your browser:

![](images/run_manually/7.png)

9. **Repeat for c4 instance:** Repeat steps 2-8 with your `c4` (x86) instance. Do everything the same, except after downloading the c4's `arm-benchmarks.result` file, rename it to `c4.result`.

Now that you have the results from both VMs, in the next section, you'll learn how to use benchstat to analyze these results and understand the performance differences between the two architectures.
Loading