Go Optimizations 101 (Go 101)
- Length: 286 pages
- Edition: 1
- Language: English
- Publication Date: 2021-12-17
- ISBN-10: B09NT2HJCM
- Sales Rank: #1199195 (See Top 100 Books)
This book provides some code performance optimization tricks, tips, and suggestions. Most of the contents in this book are made based on the official standard Go compiler and runtime implementation.
Life is full of trade-offs, the programming world is, too. In programming, we often need to make trade-offs between code readability, maintainability, development efficiency, and program efficiency, etc. Even for one of the aspects, there are also trade-offs needing to be made. Taking program efficiency for an example, we might need to make trade-offs between memory saving, code execution speed, and implementation difficulty, etc.
In practice, most parts of the code base of a project don’t need to be implemented with high performances. Keeping them maintainable and readable is often more important (than making them memroy saving and run very fast). The suggestions made in this book are just for the code parts which implementations really need to be high performant. Some of the suggestions often causes more verbose code. And please note that some of the suggested implementation might only be performant at some certain scenarios, and might be not at others.
The contents in this book include:
- how to consume less CPU resources.
- how to consume less memory.
- how to make less memory allocations.
- how to control memory allocation places.
- how to reduce garbage collection pressure.
This book neither explain how to use performance analysis tools, such as pprof, nor try to study deeply on compiler and runtime implementation details. None of the contents provided in this book make use of unsafe pointers and cgo. The contents in this book also doesn’t talk about algorithms. In other words, this book tries to provide some optimization suggestions in a way which is clear and easy to understand, for daily general Go programming.