[HN Gopher] Go Optimization Guide
       ___________________________________________________________________
        
       Go Optimization Guide
        
       Author : jedeusus
       Score  : 56 points
       Date   : 2025-03-31 20:29 UTC (2 hours ago)
        
 (HTM) web link (goperf.dev)
 (TXT) w3m dump (goperf.dev)
        
       | parhamn wrote:
       | Noticed the object pooling doc, had me wondering: are there any
       | plans to make packages like `sync` generic?
        
         | arccy wrote:
         | eventually: https://github.com/golang/go/issues/71076
        
       | roundup wrote:
       | Additionally...
       | 
       | - https://go101.org/optimizations/101.html
       | 
       | - https://github.com/uber-go/guide
       | 
       | I wish this content existed as a model context protocol (MCP)
       | tool to connect to my IDE along w/ local LLM.
       | 
       | After 6 months or switching between different language projects,
       | it's challenging to remember all the important things.
        
       | nopurpose wrote:
       | Every perf guide recommends to minimize allocations to reduce GC
       | times, but if you look at pprof of a Go app, GC mark phase is
       | what takes time, not GC sweep. GC mark always starts with known
       | live roots (goroutine stacks, globals, etc) and traverse
       | references from there colouring every pointer. To minimize GC
       | time it is best to avoid _long living_ allocations. Short lived
       | allocations, those which GC mark phase will never reach, has
       | almost neglible effect on GC times.
       | 
       | Allocations of any kind have an effect on triggering GC earlier,
       | but in real apps it is almost hopeless to avoid GC, except for
       | very carefully written programs with no dependenciesm, and if GC
       | happens, then reducing GC mark times gives bigger bang for the
       | buck.
        
         | MarkMarine wrote:
         | Are you including in this analysis the amount of time/resources
         | it takes to allocate? GC isn't the only thing you want to
         | minimize for when you're making a high performance system.
        
       | ljm wrote:
       | You're not really writing 'Go' anymore when you're optimising it,
       | it's defeating the point of the language as a simple but powerful
       | interface over networked services.
        
       ___________________________________________________________________
       (page generated 2025-03-31 23:00 UTC)