Our backend developer Sandra recently went to GopherCon UK. Check out her main insights into the conference and Bill Kennedy’s session.
This year GopherCon UK worked closely with two companies (Ardan Labs and Rawkode Academy) to deliver two optional full-day training workshops that were held on the 27th of October 2021. This took place immediately after the GopherCon UK conference where several talks were held from many companies that use golang as their development language and also incorporated the use of Kubernetes. Both courses offered by the workshop (Advanced Ultimate Go and Introduction to Kubernetes) were full-day training programs. Each ticket offered access to hands-on immersive training with top professionals in the field of golang and Kubernetes.
I attended the Advanced Ultimate Go Workshop. The workshop focused on how to use profiling and tracing in golang. Coming from any level of golang, it was easy to pick up and follow along as access to a detailed repository as well as hands-on help were provided when setting up the system to match the expected environment.
William Kennedy (Speaker of the workshop)
To give you some context on who ran the session, Bill Kennedy is a co-author of the book Go in Action, Ultimate Go Notebook, and the blog GoingGo.Net. He is a founding member of GoBridge which works to increase Go adoption through diversity. He is also a managing partner at Ardan Labs in Miami, a mobile, web, and systems development company. Bill carried out the main workshop virtually and although he could not fly in for the talk due to some flight issues, the talk went off without a hitch and everyone was excited to learn more. Having attended a previous talk hosted by Bill, I was extremely impressed and excited to attend this talk as I went away from the last talk with a breadth of knowledge around golang. It was also the key factor in my decision to attend the GopherCon UK held in London this year.
Advanced Ultimate Go
The workshop was extremely interesting and taught the class how to write better and more performant code in golang with a focus on the architecture and the workings of a computer. Bill focused on Go internals which are critical in understanding the tradeoffs the language makes on simplicity, readability, and performance.
The class was targeted to any skill level and challenged us to think about every action we are doing and why we are doing it. I came out of the workshop feeling like a better developer with a much deeper understanding of the language. I started to notice things that I wouldn’t normally have noticed, taking into account memory leaks, and actively thinking about the resources that go into the garbage collector on any system I use to run my application.
Benchmarking, Profiling, and Tracing in Golang
Benchmarking in golang is done through testing tools. The results of a typical benchmark done in golang includes:
- How long it took the program to run
- The amount of memory allocated to the heap
- The amount of allocation
There are two ways to typically run a benchmark:
- With time: go test ./main -bench .
- With memory and time: go test ./main -bench . benchmem
Also, I should note that it is possible to compare past benchmarks with new sets of benchmarks in order to check and compare differences and improvements (if applicable).
Profiling shows a function’s execution duration i. e. when running a profile you get a detailed view with memory consumption used. There are two ways of retrieving profiling data from benchmarks. The CPUs profile measures elapsed time and the memory profile measures heap allocation while ignoring the stack.
An example of this is:
Tracing are events collected during a program’s execution. They give a chronological view of a program’s execution with more detailed information about the garbage collector, heap, goroutines, etc.
To generate and visualise the data the following commands are used:
Some prerequisites are required in order to use the trace tool successfully:
To enjoy and learn more in-depth about golang I definitely recommend getting: https://www.amazon.co.uk/Ultimate-Go-Notebook-William-Kennedy/dp/1737384426/
Additional Sources for anyone who is interested:
All images by GopherCon UK