高效GO語言(影印版)
出版時(shí)間:2023年03月
頁數(shù):476
“本書精彩且富有見地,改變了人們對于Go軟件效率的看法。你會學(xué)到如何在優(yōu)化代碼庫和識別可優(yōu)化模式的同時(shí)進(jìn)行數(shù)據(jù)驅(qū)動的評估。作者想做的就是減輕你的學(xué)習(xí)負(fù)擔(dān),讓你一敲代碼就忍不住關(guān)心代碼的效率!”
——Saswata Mukherjee
Red Hat工程師
隨著技術(shù)的進(jìn)步、市場的快速發(fā)展和系統(tǒng)復(fù)雜性的日益增加,軟件工程師傾向于跳過軟件效率這個令人不舒服的話題。然而,要想節(jié)省資金并確保業(yè)務(wù)成功,戰(zhàn)術(shù)性的、由可觀測性驅(qū)動的性能優(yōu)化對于所有產(chǎn)品來說都是至關(guān)重要的。
通過本書,任何工程師都可以輕松學(xué)會如何有效、專業(yè)且無壓力地提高軟件效率。作者Bartlomiej Plotka講解了提高系統(tǒng)速度和降低資源消耗所需的工具和知識。本書將指導(dǎo)你使用Go實(shí)現(xiàn)更好的日常工作效率。此外,書中大多數(shù)內(nèi)容與語言無關(guān),以便你將小而有效的習(xí)慣帶入編程或產(chǎn)品管理周期。
本書將教會你如何:
● 闡明并協(xié)商效率目標(biāo)
● 優(yōu)化各個層面的效率
● 有效利用CPU和內(nèi)存等公共資源
● 通過Prometheus、Jaeger、Parca等開源項(xiàng)目,使用指標(biāo)、日志記錄、跟蹤和(連續(xù))剖析等可觀測性信號評估效率
● 應(yīng)用go test、pprof、benchstat和k6等工具創(chuàng)建可靠的微觀和宏觀基準(zhǔn)
● 高效地使用Go及其特性,如切片、泛型、goroutines、分配語義、垃圾收集等
- Preface
- 1. Software Efficiency Matters
- Behind Performance
- Common Efficiency Misconceptions
- The Key to Pragmatic Code Performance
- Summary
- 2. Efficient Introduction to Go
- Basics You Should Know About Go
- Advanced Language Elements
- Is Go “Fast”?
- Summary
- 3. Conquering Efficiency
- Beyond Waste, Optimization Is a Zero-Sum Game
- Optimization Challenges
- Understand Your Goals
- Got an Efficiency Problem? Keep Calm!
- Optimization Design Levels
- Efficiency-Aware Development Flow
- Summary
- 4. How Go Uses the CPU Resource (or Two)
- CPU in a Modern Computer Architecture
- Assembly
- Understanding Go Compiler
- CPU and Memory Wall Problem
- Schedulers
- When to Use Concurrency
- Summary
- 5. How Go Uses Memory Resource
- Memory Relevance
- Do We Have a Memory Problem?
- Physical Memory
- OS Memory Management
- Go Memory Management
- Summary
- 6. Efficiency Observability
- Observability
- Example: Instrumenting for Latency
- Efficiency Metrics Semantics
- Summary
- 7. Data-Driven Efficiency Assessment
- Complexity Analysis
- The Art of Benchmarking
- Reliability of Experiments
- Benchmarking Levels
- Summary
- 8. Benchmarking
- Microbenchmarks
- Tips and Tricks for Microbenchmarking
- Macrobenchmarks
- Common Macrobenchmarking Workflows
- Summary
- 9. Data-Driven Bottleneck Analysis
- Root Cause Analysis, but for Efficiency
- Profiling in Go
- Capturing the Profiling Signal
- Common Profile Instrumentation
- Tips and Tricks
- Summary
- 10. Optimization Examples
- Sum Examples
- Optimizing Latency
- Optimizing Memory Usage
- Optimizing Latency Using Concurrency
- Bonus: Thinking Out of the Box
- Summary
- 11. Optimization Patterns
- Common Patterns
- The Three Rs Optimization Method
- Don’t Leak Resources
- Pre-Allocate If You Can
- Overusing Memory with Arrays
- Memory Reuse and Pooling
- Summary
- Next Steps
- A. Latencies for Napkin Math Calculations
- Index
書名:高效GO語言(影印版)
國內(nèi)出版社:東南大學(xué)出版社
出版時(shí)間:2023年03月
頁數(shù):476
書號:978-7-5766-0659-1
原版書書名:Efficient Go
原版書出版商:O'Reilly Media
Bart?omiej P?otka
Bart?omiej P?otka是Red Hat的首席軟件工程師,擁有可觀測性和SRE方面的專業(yè)背景。他是CNCF大使、TAG可觀測性技術(shù)負(fù)責(zé)人以及Thanos項(xiàng)目的聯(lián)合創(chuàng)始人。此外,他還是包括Prometheus和bingo在內(nèi)的開源Go項(xiàng)目的核心維護(hù)者。
The animal on the cover of Efficient Go is a purple heron (Ardea purpurea). There is a wide variety of subspecies of these herons, and they are occasionally confused with their larger relative, the gray heron.
Purple herons are recognized by their long bills and necks, as well as by their narrow bodies and wings. Light grayish-purple feathers cover the majority of their bodies with some areas of black, chestnut brown, and white throughout. Their long, snakelike neck is brown with black stripes running down the sides. Black feathers crown their head, belly, and tail tip. Long legs allow them to wade through water and help them see from higher vantage points.
They can be found across the globe in temperate and tropical Europe, Asia, and Africa. While they favor freshwater and tall reed beds, they can also be found living in sedge beds, mangroves, brackish water, swamps, rice fields, rivers, lake shores, and coastal mudflats. They prefer areas covered with thick vegetation and are more commonly seen flying rather than nestled into their habitat.
Water is key to the survival of purple herons, as their primary diet is small-tomedium-sized fish. Insects (beetles, locusts, and dragonflies) also provide ample nourishment, as well as the occasional frog, salamander, or small mammal.