go gc settings
play

Go GC Settings Bryan Boreham (@bboreham) Hi, Im Bryan Boreham At - PowerPoint PPT Presentation

Go GC Settings Bryan Boreham (@bboreham) Hi, Im Bryan Boreham At Weaveworks, I work on Open Source DevOps tools doing system visualisation, monitoring and CI/CD I also contribute to Container Network Interface, Kubernetes, Prometheus


  1. Go GC Settings Bryan Boreham (@bboreham)

  2. Hi, I’m Bryan Boreham At Weaveworks, I work on Open Source DevOps tools doing system visualisation, monitoring and CI/CD I also contribute to Container Network Interface, Kubernetes, Prometheus Program optimisation is my video-game. @bboreham 2

  3. Why care about Garbage? (this is the point where Bryan moans about never having enough RAM) https://www.redbubble.com/people/clgtart/ 3

  4. CPU memory architecture CPU Logic Level 2 Cache RAM RAM Level 1 Cache (Not to scale) 4

  5. Caches in use CPU Logic Level 2 Cache RAM RAM Level 1 Cache 5

  6. After GC has run CPU Logic Level 2 Cache RAM RAM Level 1 Cache 6

  7. Stack vs Heap 7 http://www.clipartpanda.com/clipart_images/stack-files-max-39545601 Photo: JohnNyberg, rgbstock.com

  8. GC Options -XX:ParallelGCThreads=n -Xms n -XX:ConcGCThreads=n -Xmx n -XX:G1ReservePercent=n -XX:-UseConcMarkSweepGC -XX:G1HeapRegionSize=n -XX:-UseParallelGC -XX:MaxHeapFreeRatio=n -XX:-UseParallelOldGC -XX:MaxNewSize=size -XX:-UseSerialGC -XX:MaxPermSize=n -XX:+UseG1GC -XX:MinHeapFreeRatio=n -XX:+UseGCOverheadLimit -XX:NewSize=n -XX:MaxGCPauseMillis=n -XX:NewRatio=n -XX:InitiatingHeapOccupancyPercent=n -XX:SurvivorRatio=n -XX:MaxTenuringThreshold=n -XX:TargetSurvivorRatio=n -XX:+ScavengeBeforeFullGC -XX:+HandlePromotionFailure 8

  9. Go GC Options GOGC 9

  10. Test set-up Server: github.com/stefanprodan/k8s-podinfo - microservice skeleton Client: github.com/rakyll/hey - HTTP load generator hey -z 2m -c 10 -q 20 ".../metrics" 10

  11. Situation: large stable data set 11

  12. Lower GOGC to save RAM (at the cost of CPU) 12

  13. Situation: high GC rate, small heap 13

  14. Raise GOGC to save CPU 14

  15. GOGC=1000 15

  16. What’s happening here? (no load, GOGC=100 ) 16

  17. There is another setting! /usr/local/go/src/runtime/proc.go line 4310(!): // If we go this long without a garbage collection, // one is forced to run. var forcegcperiod int64 = 2 * 60 * 1e9 17

  18. What if we turn off GC completely? GOGC=off 18

  19. Building podinfo $ go clean -cache $ go clean -cache $ export GOGC=off $ time go build $ time go build real 0m7.331s real 0m5.412s user 0m12.152s user 0m8.460s sys 0m0.660s sys 0m0.704s 19

  20. The future? SetMaxHeap GOGCMIN https://twitter.com/ashleymcnamara 20

  21. THANK YOU! @bboreham https://twitter.com/ashleymcnamara 21

  22. More information Good explanation of GOGC and other settings https://dave.cheney.net/tag/gogc Really detailed history https://blog.golang.org/ismmkeynote 22

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend