Profiling & Optimizing Go Training
Go ships with amazing profiling tools, but understanding how and when to use them, as well as understanding their output, can be quite challenging. This course was designed to take experienced developers through the fundamentals of the pprof tool, and show them how to and when to create proper profiles for their code. It then shows them how to spot performance issues, identifies common performance pitfalls, and shows the proper fixes for many of them.
Length
1 day. Each day is 4 hours long including a 15 minute break.Class Size
Our classes are priced for small and large classes. We offer classes starting at only five students, up to 100 students. We recognize that each company has specific needs and budgets.
For pricing, fill out our contact us form and you'll receive an automated reply with our current rates.
Target Audience
- You have been doing daily Go development for 3-6 months and want to master more advanced topics.
- You want to learn how to profile your Go code and improve performance.
Prerequisites
- Familiarity and comfort navigating and basic file manipulation at the command line.
- Familiarity and comfort with a modern code editor, including creating and modifying files and projects.
- You have 3 to 6 months of daily Go experience.
- You have at least 1 year of experience with other modern development languages such as Java, C#, Swift, JavaScript, Python, Rust, etc.
- Familiarity with basic programming concepts and structures such as variables, loops, conditionals, etc.
- Computers should be capable of modern software development, such as access to install and run binaries, install a code editor, etc. Full instructions referenced here: preparing your environment for Go development. It may be necessary for them to have root/admin access to their computer.
Recommended Preparation
- Install and configure an editor for Go.
- Have a functioning Go environment installed with Go 1.13 or later.
- Sign up for a Github account if you don't already have one.
- Install GraphViz (needed for generating Go profiles).
Suggested Followup Learning
Expected Outcomes
- Students will understand how to install and run the pprof tool.
- Students will understand how to configure their Go code to create and capture performance profiles.
- Students will understand how to read a Go profile, torch graph, and navigate other pprof generated output.
- Students will understand the Go test ecosystem, as well as how to configure and run their Go tests efficiently.
- Students will be able to identify common performance pitfalls and correct them in their Go code.
Course Details
Day One
Welcome
This chapter covers general information about your instructor and course materials.
Profiling
Go ships with a number of profiling tools. This chapter will walk you through how to:
- Use interactive
pprof
with a cpu profile - Use interactive
pprof
with different types of memory profiles - Generate profiles from benchmarks
- Generate profiles from live/running applications
- Generate torch graphs from benchmarks or live/running applications
Optimizing Go Services
Understanding how to use tools like pprof
and writing benchmarks is important, but understanding common coding pitfalls and how to spot them with those tools is the end goal.
In this interactive workshop, you will:
- Learn several compiler tricks to spot areas for improvement
- Learn how to properly buffer readers and writers
- Find and remove unnecessary memory allocations
Break
Tea/Coffee Break.
Tracing
The execution trace captures a wide range of execution events such as goroutine creation/blocking/unblocking, syscall enter/exit/block, GC-related events, changes of heap size, processor start/stop, etc. A precise nanosecond-precision timestamp and a stack trace is captured for most events. The generated trace can be interpreted using go tool trace
.
This chapter will walk through how to enable tracing, use the trace tool, and spot performance issues.
Finalize
This chapter covers where to get more support on Go, recommends books and videos, and list the contact information for our instructors.
Prerequisites
Benchmarking
Go comes with a powerful set of tools for profiling and improving the performance of your code. Benchmarking is one of those tools, and the first one most developers start with. In this chapter we will cover basic benchmarking, some common benchmarking mistakes, and how to compare benchmarks to see if performance has improved.