Help reading pprof web output

agolangf · · 541 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I have been profiling a project I&#39;ve been working on and have found a lot of my calls or rather the majority of my long running calls equate to the following:</p> <p> </p> <ul> <li>String / Int conversions</li> <li>Slice / Map Growth &amp; allocations</li> <li>What I presume is runtime &amp; GC ?***</li> </ul> <p> </p> <p>My questions:</p> <p> </p> <ul> <li>What is the most efficient way to convert a string to int and int to string (knowing that it is probably best to keep everything all one type) ?</li> <li>What (from looking at the attached cpuprofile) do you notice in the cpu profile output?</li> <li>To address my *** point, what is happening during the runtime calls? I will be diving into the source later to try to make sense of the calls being made but wonder if someone has a high level explanation off hand.</li> </ul> <p> </p> <p><a href="http://i.imgur.com/kdpwu9f.png" rel="nofollow">Pprof web output (imgur)</a></p> <hr/>**评论:**<br/><br/>1lann: <pre><blockquote> <p>What is the most efficient way to convert a string to int and int to string (knowing that it is probably best to keep everything all one type) ?</p> </blockquote> <p>I don&#39;t think that&#39;s something people usually worry about. The strconv library should be fine. If Go&#39;s performance isn&#39;t good enough, perhaps you should consider using C, C++ or Rust.</p> <blockquote> <p>To address my *** point, what is happening during the runtime calls? I will be diving into the source later to try to make sense of the calls being made but wonder if someone has a high level explanation off hand.</p> </blockquote> <p>I don&#39;t know the internals of Go that well, but I believe that majority of it would just be the GC which is a mark-and-sweep GC, and the scheduler which determines which goroutines are running.</p> <p>Ideally you should just either decrease your allocations to improve GC performance, or understand how Go&#39;s escape analysis works, to take advantage of it and limit allocations into the heap. You should also think about whether or not your program is repeating any operations that can otherwise be cached between requests, or use a different data structure to reduce time complexity.</p> <p>Take my words with a grain of salt though, I don&#39;t understand the internals of Go that well and what I&#39;ve said is based on what I&#39;ve read, and a bit from experience.</p></pre>nastus: <pre><p>Thanks for the reply it is much appreciated! What you&#39;re saying makes sense, I know I probably have a ton of things wrong with my code - as I&#39;m new to go - but the performance isn&#39;t bad I just don&#39;t know what the threshold between &#34;good&#34; and &#34;bad&#34; really is. E.g. Obviously a function that benchmarks are 100ns/op is fast but what about those are 20,000ns/op is that still considered good? I have much to learn :)</p></pre>dericofilho: <pre><p>I couldn&#39;t find, but there&#39;s a video version of these slides. </p> <p><a href="http://gotocon.com/dl/goto-chicago-2016/slides/FrancescCampoyFlores_GoToolingInAction.pdf" rel="nofollow">http://gotocon.com/dl/goto-chicago-2016/slides/FrancescCampoyFlores_GoToolingInAction.pdf</a></p> <p>It&#39;s a nice walk through on how to improve your code. </p></pre>dericofilho: <pre><p>The video</p> <p><a href="https://m.youtube.com/watch?v=uBjoTxosSys" rel="nofollow">https://m.youtube.com/watch?v=uBjoTxosSys</a></p></pre>nastus: <pre><p>Thanks!!</p></pre>

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

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