pure go linux AIO library

polaris · · 1309 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I built a pure go kernel supported AIO library that doesn&#39;t rely on goroutines or channels and lets the kernel do the hard work. All the AIO libraries I could find seemed to do it &#34;the go way&#34; in userland.</p> <p>And before you ask &#34;why in the hell would you do that?!?!?!&#34; it was because I was adapting some really performant code from C to golang and didn&#39;t want to change the structure too much (and because deep down i enjoy the pain). This seems to be really quick and figured I would share and get some feedback. I had to do some hackery on getting structure sizes correct for the syscalls, so if there is a better way of getting properly aligned structures without architecture specific files and padding I would love to know.</p> <p><a href="https://github.com/traetox/goaio" rel="nofollow">https://github.com/traetox/goaio</a></p> <hr/>**评论:**<br/><br/>brogrammingsins: <pre><p>Why the hell would you do that? Because the idiomatic Go version was slower than the previous C one? Or because you didn&#39;t wanted to change the code when you ported it? In which case why bother porting it in the first place.</p></pre>traetox: <pre><p>My previous implementation was using cgo calls with C doing the heavy lifting. Under some circumstances the cgo overhead was outweighing the benefits of using C. So I decided to move the C bits to pure go and see what the performance looked like. I wanted to keep the structure as close as possible to speed up the conversion.</p> <p>The AIO library is born mostly out of wanting a reason to better learn the syscall interface as implemented by golang, and the above.</p> <p>As far as performance goes, reads and writes that are small (&lt;32MB) are about the same as io/ioutil (ioutil is probably a little bit faster as my test did not account for the time taken to perform the Open in ioutil.WriteFile). However, on the hardware I have available as the chunks get larger the AIO library starts getting faster. I am showing about a 20-30% increase in speed vs using ioutil.WriteFile when I write 1GB+ chunks out to EXT4 or ZFS. Now, I fully accept that the use cases for writing 1GB chunks in one operation are probably between never and almost never, but there you go.</p></pre>brogrammingsins: <pre><p>Interesting, thanks for your reply. I hope you don&#39;t mind the pun on the question but had to do it :p Also, this could be in the description next time :p Do you have any benchmarks / comparison for how the code looks like between version? Thank could also be interesting to look at. Cheers </p></pre>

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

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