User Tools

Site Tools


gophercon_2018

Gophercon 2018

My notes…

Ultimate Go

Taught by Bill Kennedy

  • Go targets a real machine, not a VM; Go is “hardware sympathetic”
  • Escape analysis Go's compiler performs static analysis to allocate values on the heap
    • go build -gcflags “-m -m” options to show the escape analysis
    • always use value semantics when constructing and assigning
  • Pacing algorithm determines how often GC runs. One of the configs: GOGC env.var.
  • How does the GC “recruit” a goroutine that went “rogue” during GC activity to help?
  • When GC runs, it uses 25% of CPU capacity
  • Tight loops that don't make function calls can stall the GC, because STW can only stop goroutines at function calls to turn the Write Barrier GC course material
  • Arrays Scott Myers videos about relative speed of L1/2/3 caches vs. main memory
    • “There's value semantics at the hardware level when we talk about caches”
    • Arrays and slices are sympathetic to predictable access patterns to memory, helping the pre-fetch logic in the CPU
    • TLB cache is not shown in the Core i7-9xxx Cache Hierarchy diagram
    • There are Linux distros with 2MB pages that are faster for handling big data
    • See Damian Gryski's talk “Slices: performance through cache-friendliness”
    • Important:
      • CPU Caches and Why You Care - Video - Scott Meyers
      • NUMA Deep Dive Series - Frank Denneman
      • Pitfalls of OOP - Tony Albrecht
    • Strings should always use value semantics, unless it's necessary to have a “null” string value
    • The factory function tells you whether value or pointer semantics are used
    • In the Time package, only marshalling functions use pointer semantics
    • The Open function uses pointer semantics
    • Declare and receiver behavior (from)
    • Gooogle has code readability reviews in addition to technical review
    • “This was two days of value vs pointer semantics compressed in 4 hours”
    • Go has a cooperative scheduler; 1.12 may introduce some preemption
    • “I use atomic instructions and mutexes more than channels”
    • Synchronization (atomic instructions & mutexes) vs orchestration (channels)
  • Orchestration, presented by Arti Parikh
  • Live coding, with Bill Kennedy
    • “Channel buffers are not about performance.”
    • “You can't solve problems by using very large buffers.”
    • Logger example: will not crash program if disk is full (disk is simulated by a custom io.Writer “device”), it will drop messages instead (see *Logger.Println)
    • Trace example: demo of go tool pprof -http :3000. A web command in the pprof prompt displays a diagram with the call stack and cumulative timings.
    • New trace API has the concept of a “user defined task”, which helps detect specific places where there are bottlenecks.
    • Find excessive allocations: they are the low hanging fruit
    • Service: a project that provides a starter-kit for a REST based web service. It provides best practices around Go web services using POD architecture and design
    • validate_test.go: Sample program to show you need to validate your benchmark results.
gophercon_2018.txt · Last modified: 2018/08/29 14:18 by luciano