You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/go-gc-default-settings/_index.md
+3-12Lines changed: 3 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,14 @@
1
1
---
2
-
title: Measure Go GC behavior on AWS Graviton with default runtime settings
3
-
description: Learn how to run a Go allocation benchmark on AWS Graviton and measure garbage collection behavior without changing Go runtime settings.
2
+
title: Measure Go GC behavior on AWS Graviton
3
+
description: Learn how to measure and observe Go garbage collection metrics on AWS Graviton instances.
4
4
5
5
minutes_to_complete: 75
6
6
7
-
who_is_this_for: This Learning Path is for Go developers and performance engineers who want to measure garbage collection behavior on Arm servers without changing Go runtime GC settings.
7
+
who_is_this_for: This Learning Path is for engineers interested in learning more about Go garbage collection (GC) behavior on Arm.
8
8
9
9
learning_objectives:
10
10
- Select an AWS Graviton instance for repeatable Go GC measurements
11
11
- Install Go and Benchstat on an Arm Linux server
12
-
- Confirm that Go runtime tuning variables are unset
13
12
- Run a Go benchmark that reports allocation, GC, and pause-time metrics
14
13
- Capture CPU and heap profiles without changing GC behavior
15
14
@@ -66,11 +65,3 @@ weight: 1 # _index.md always has weight of 1 to order corr
66
65
layout: "learningpathall"# All files under learning paths have this same wrapper
67
66
learning_path_main_page: "yes"# This should be surfaced when looking for related content. Only set for _index.md of learning path content.
68
67
---
69
-
70
-
## Measure default Go GC behavior on Arm servers
71
-
72
-
Go applications can spend meaningful time allocating memory and running garbage collection (GC). You should measure that behavior before you change runtime settings.
73
-
74
-
In this Learning Path, you run Go benchmarks on an AWS Graviton instance and keep the Go runtime in its default GC mode. You do not set `GOGC`, `GOMEMLIMIT`, `GODEBUG`, or `GOMAXPROCS`.
75
-
76
-
The goal is to build a clean baseline. You will measure operation time, allocation rate, GC frequency, GC pause cost, and profiles before making tuning decisions.
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/go-gc-default-settings/choose_aws_instance.md
+13-19Lines changed: 13 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,35 +5,31 @@ weight: 2
5
5
### FIXED, DO NOT MODIFY
6
6
layout: learningpathall
7
7
---
8
+
## What is Garbage Collection? (GC)
9
+
Memory management is a critical aspects of application performance, and Garbage Collection (GC) plays a central role in automating that process. GC continuously identifies and removes objects that are no longer needed, freeing memory for re-use for other purposes..
8
10
9
-
## Select an instance for Go GC measurements
11
+
While this automation improves productivity and application safety, inefficient garbage collection can lead to increased CPU usage, longer response times, and unexpected application pauses.
10
12
11
-
Use an AWS Graviton instance that has enough CPU and memory to make Go runtime behavior visible, while keeping the Learning Path inexpensive to run.
13
+
Tracking GC metrics provides a window into an application's memory health, helping engineers optimize performance, and ensuring the system can scale efficiently under load.
12
14
13
-
For the first prototype, use `m8g.xlarge`.
15
+
## Measuring default Go GC behavior on Arm servers
14
16
15
-
`m8g.xlarge` is a good starting point because it provides four vCPUs and 16 GiB of memory on AWS Graviton4. Four vCPUs are enough to observe default Go CPU parallelism and GC worker behavior without requiring a large benchmark host. The 16 GiB memory size is enough for allocation-heavy benchmarks without immediately making the lab memory-bound.
17
+
Go is one such language which implements GC. As Go applications can spend meaningful time allocating memory and running garbage collection, it is important to understand how the Go runtime behaves under default settings.
16
18
17
-
Avoid burstable `t4g` instances for this Learning Path. CPU credits can affect benchmark repeatability and make GC measurements harder to explain.
19
+
In this Learning Path, you'll run Go benchmarks on an AWS Graviton instance. The goal is to build a clean baseline, measuring operation time, allocation rate, GC frequency, and GC pause cost.
18
20
19
-
If `m8g.xlarge` is not available in your AWS Region or Availability Zone, use `m7g.xlarge` as the fallback. It has the same vCPU and memory shape on an earlier Graviton generation, so the commands and benchmark workflow remain the same.
21
+
## Selecting an instance for Go GC measurements
20
22
21
-
## Recommended prototype machine
23
+
An AWS Graviton `m8g.xlarge` instance has enough CPU and memory to make Go runtime behavior visible, while keeping costs minimal. It's a good starting point as it provides four vCPUs and 16 GiB of memory on AWS Graviton4. If you choose to run this Learning Path on a different instance, make sure it has at least 4 vCPUs and 16 GiB of memory to ensure the benchmark runs smoothly and provides meaningful GC metrics.
22
24
23
-
Use this instance shape for the first version of the Learning Path:
Avoid burstable `t4g` instances as CPU credits can affect benchmark repeatability and make GC measurements harder to explain.
29
26
30
27
{{% notice Note %}}
31
28
You can use larger instances, such as `m8g.2xlarge`, when you want more CPU width or more memory headroom. Start with `m8g.xlarge` so the first benchmark run is easy to reproduce and inexpensive.
32
29
{{% /notice %}}
33
30
34
-
The commands in this Learning Path were validated on an `m8g.xlarge` instance running Ubuntu 24.04 LTS Arm64 and Go 1.26.3.
35
31
36
-
## Check instance availability
32
+
## Checking instance availability
37
33
38
34
Use the AWS CLI to check whether `m8g.xlarge` is available in your selected Region.
If the command returns one or more Availability Zones, you can use `m8g.xlarge` in that Region.
52
-
53
-
Run the same command for `m7g.xlarge` if `m8g.xlarge` is not available:
47
+
If the command returns one or more Availability Zones, you can use `m8g.xlarge` in that Region. If you are unable to find `m8g.xlarge` in your Region, you can try a different Region, or fallback to an 'm7g.xlarge' instance, which is based on the previous generation AWS Graviton3:
You have now selected a repeatable AWS Graviton test machine. You will confirm the default Go runtime environment before running the benchmark.
58
+
Once you have chosen an instance type, provision it to run Ubuntu 24.04 LTS Arm64. Once the instance is running, and you are ssh'd into it, you can proceed to the next step.
This benchmark repeatedly parses and allocates strings. It reports the default Go benchmark metrics plus three GC-specific metrics:
80
-
81
-
| Metric | Meaning |
82
-
| --- | --- |
83
-
|`gc/op`| GC cycles per completed benchmark operation |
84
-
|`stw-ns/op`| GC stop-the-world pause nanoseconds per completed operation |
85
-
|`stw-ns/GC`| GC stop-the-world pause nanoseconds per GC cycle |
162
+
The benchmark code is now ready to run! Give it a try by running the following command:
86
163
87
-
The benchmark reads `runtime.MemStats` before and after the timed loop. It does not set Go runtime tuning variables.
88
-
89
-
## Confirm the benchmark builds
90
-
91
-
Run one short benchmark pass:
92
-
93
-
```console
164
+
```bash
94
165
cd$HOME/go-gc-default
95
166
go test ./parsebench -run '^$' -bench BenchmarkParseAndAllocate -benchmem -count 1 -benchtime=2s
96
167
```
97
168
98
-
You should see output with `ns/op`, `B/op`, `allocs/op`, and the GC-specific metrics:
169
+
You should see output similar to below:
99
170
100
171
```output
101
172
goos: linux
@@ -106,4 +177,7 @@ PASS
106
177
ok example.com/go-gc-default/parsebench 4.127s
107
178
```
108
179
109
-
Your exact numbers will differ by instance type, Go version, operating system, and system load.
180
+
Your exact numbers will differ by instance type, Go version, operating system, and system load. If this test run yields results with no errors, you're ready to move on to the next step.
0 commit comments