November 12, 2018Jacob Walker
Go Instructor
Goroutine leaks are a common source of memory leaks in concurrent programs. This post defines Goroutine leaks and provides one example of a leak that is easy to miss in production code.
Continue reading Prelude This is the second post in a three part series that will provide an understanding of the mechanics and semantics behind the scheduler in Go. This post focuses on the Go scheduler.
Index of the three part series:
Scheduling In Go : Part I - OS Scheduler Scheduling In Go : Part II - Go Scheduler Scheduling In Go : Part III - Concurrency Introduction In the first part of this scheduling series, I explained aspects of the operating-system scheduler that I believe are important in understanding and appreciating the semantics of the Go scheduler.
Continue readingAugust 14, 2018Erick Zelaya
Creative Director
In the months leading up to GopherCon, my wife Jamilet and I had come up with the idea of creating a “small” browser-based game for the convention using the racing theme. Neither of us had ever worked on a game before and we had no idea what was involved. However, we knew we wanted to design and build something special for the awesome Gopher community.
The original idea was to create a game where Gophers raced each other around a track.
Continue reading Prelude This is the first post in a three part series that will provide an understanding of the mechanics and semantics behind the scheduler in Go. This post focuses on the operating system scheduler.
Index of the three part series:
Scheduling In Go : Part I - OS Scheduler Scheduling In Go : Part II - Go Scheduler Scheduling In Go : Part III - Concurrency Introduction The design and behavior of the Go scheduler allows your multithreaded Go programs to be more efficient and performant.
Continue readingIntroduction I teach a class called Ultimate Go. The class is three days long and teaches you the history, mechanics and semantics of the Go programming language. The idea is to teach you how to read code to the level that you can understand the behavior and impact your program is having on the machine. This helps you make better and more consistent engineering decisions.
At the same time, the class is very focused on teaching you how to optimize for correctness so the code you are writing is readable as a first priority.
Continue readingIntroduction One day I was talking to Damian Gryski in Slack about some performance improvements he made to his go-metro package. When I first looked at the changes I was completely confused how this could have any effect on the performance of the code. I felt the code was more readable, but more performant? I didn’t see it.
Then Damian started to talk to me about a compiler optimization called Bounds Check Elimination or BCE.
Continue readingIntroduction I’ve been seeing a lot of question about interfaces lately on Slack. Most of the time the answers are technical and focus on implementation details. Implementation is important to help with debugging, but implementation doesn’t help with design. When it comes to designing code with interfaces, behavior has to be the main focus.
In this post, I hope to provide a different way to think about interfaces and how to design code with them.
Continue readingIntroduction I was guided for many years to write functions that are generalized and to create layers upon layers of abstraction so things don’t break as business requirements change. That the cost of breaking a function signature, for example, is expensive and something that should be avoided. Therefore, write functions that take more generic parameters or hide things in a receiver or context to be less prone to breakage.
On the surface this seems like a good and reasonable idea.
Continue readingPrelude It will be helpful to read this four-part series first on escape analysis and data semantics. Details on how to read an escape analysis report and pprof output have been outlined here.
https://www.ardanlabs.com/blog/2017/05/language-mechanics-on-stacks-and-pointers.html
Introduction Even after working with Go for 4 years, I am continually amazed by the language. Thanks to the static code analysis the compiler performs, the compiler can apply interesting optimizations to the code it produces. One type of analysis the compiler performs is called escape analysis.
Continue readingIntroduction When I started to work with Go’s channels for the first time, I made the mistake of thinking about channels as a data structure. I saw channels as a queue that provided automatic synchronized access between goroutines. This structural understanding caused me to write a lot of bad and complicated concurrent code.
I learned over time that it’s best to forget about how channels are structured and focus on how they behave.
Continue reading