Software engineers today typically put performance optimizations low on the list of development priorities. But despite significant technological advancements and lower-priced hardware, software efficiency still matters. With this book, Go programmers will learn how to approach performance topics for applications written in this open source language.

How and when should you apply performance efficiency optimization without wasting your time? Authors Bartlomiej Plotka and Frederic Branczyk provide the tools and knowledge you need to make your system faster using fewer resources. Once you learn how to address performance in your Go applications, you'll be able to bring small but effective habits to your programming and development cycle.

This book shows you how to:

  • Continuously monitor for performance and efficiency regressions
  • Find the root cause of performance bottlenecks using metrics, logging, tracing, and profiling
  • Use tools like pprof, go test, benchstat and k6.io to create reliable micro- and macro-benchmarks
  • Improve and optimize your code to meet your goals without sacrificing simplicity and readability
  • Make data-driven decisions by prioritizing changes that make a difference
  • Introduce basic "performance hygiene" in day-to-day Go programming and testing

Table of Contents

  1. 1. Software Efficiency Matters
    1. Motivation For This Book
    2. Behind Performance
    3. Common Performance Misconceptions
    4. Optimized Code is Not Readable
    5. You Aren’t Going to Need It (YAGNI)
    6. Hardware is Getting Faster and Cheaper
    7. We Can Scale Horizontally Instead
    8. Time to Market is More Important
    9. Be Vigilant to Simplifications
    10. Efficiency: The Key to Pragmatic Code Performance
    11. Summary
  2. 2. Efficient Introduction to Go
    1. Basics You Should Know About Go
    2. Imperative, Compiled and Statically Typed Language
    3. Designed to Improve Serious Codebases
    4. Governed by Google, Yet Open Source
    5. Simplicity, Safety and Readability are Paramount
    6. Packaging and Modules
    7. Dependencies Transparency by Default
    8. Consistent Tooling
    9. Single Way of Handling Errors
    10. Strong Ecosystem
    11. Unused Import or Variable Causes Build Error
    12. Unit Testing and Table Tests
    13. Advanced Language Elements
    14. Code Documentation as a First Citizen
    15. Backwards Compatibility and Portability
    16. Go Runtime
    17. Object Oriented Programming in Go
    18. Is Go “Fast”?
    19. Summary