Any recommendation for golang gc tuning resources?

agolangf · · 459 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I am looking for resources that explains golang garbage collector and how to tune gc.</p> <p>Does golang have the concept of eden and survivor space? And can golang switch gc strategy like concurrent mark sweep vs g1?</p> <hr/>**评论:**<br/><br/>kostix: <pre><ol> <li><p>The concurrent GC has been implemented in 1.5, so see <a href="https://golang.org/doc/go1.5#gc" rel="nofollow">this</a> and — most importantly — <a href="https://golang.org/s/go15gcpacing" rel="nofollow">this design doc</a>.</p> <p>Basically, the only knob controlling the GC is the <a href="https://golang.org/pkg/runtime/" rel="nofollow"><code>GOGC</code>env. variable</a> and its <a href="https://golang.org/pkg/runtime/debug/#SetGCPercent" rel="nofollow"><code>runtime/debug.SetGCPercent()</code></a> counterpart.</p> <p>You can also force garbage collection with <a href="https://golang.org/pkg/runtime/#GC" rel="nofollow"><code>runtime.GC()</code></a> but note that prior to 1.9 that would be an STW operation.</p></li> <li><p>No, you can&#39;t switch the GC strategy. See <a href="https://blog.golang.org/go15gc" rel="nofollow">this</a> for backgrounds and the roadmap.</p></li> </ol></pre>natefinch: <pre><p>It would be good to know what problem you&#39;re trying to solve. The garbage collector is intentionally not tweakable. This isn&#39;t java. The default works for the vast majority of cases.</p></pre>ChristophBerger: <pre><p>By pure chance, I just came across <a href="https://medium.com/samsara-engineering/running-go-on-low-memory-devices-536e1ca2fe8f" rel="nofollow">this post</a> that might be of help--scroll down to the section &#34;Tuning the Garbage Collector&#34;, where the author describes how to tweak the GC for a low-memory scenario. </p> <p>TL;DR: The GC only returns those pages to the OS that are unused for 5 minutes. To trigger this more frequently, use the method <code>FreeOSMemory()</code> from the <code>runtime/debug</code>package that forces a GC cycle and returns as much memory to the OS as possible.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

459 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传