TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Some notes on making a random Erlang program (egitd) faster

69 点作者 billiob超过 14 年前

5 条评论

jerf超过 14 年前
Actually I learned this myself just this week. Don't fear the binaries in Erlang. You need to learn how they work, and in particular they can surprise you a bit if you don't turn fullsweep on by hanging around in the binary heap longer than you'd expect after all processes are done with it, but you are <i>not</i> doing the runtime any favors by using a lot of "strings" instead. (Fullsweep isn't the only answer either, it's just an easy thing to quickly say in an HN post.)<p>In Erlang, slices of binaries are by default references to the original, and if you want a true copy (within a single Erlang OS process, sending it across processes will make one automatically of course) you need to ask for it, with binary:copy, available only in relatively recent releases. In the context of where Erlang tends to run, I think this is the correct default behavior, but it does mean that you end up having to do at least a little smidge of memory-management-type thinking. Since your Erlang code is very likely to be something that takes a packet in, does "something", and sends it somewhere else without hanging on to it indefinitely, this can work well as long as you don't leak references.
评论 #2225925 未加载
TeMPOraL超过 14 年前
For those who didn't notice - this series currently has 5 more articles - you need to click "Next post" at the bottom. Wasn't immediately obvious for me.
zck超过 14 年前
I wonder what Github thinks about the changes to this program -- whether it's fast enough for their needs. I tweeted this at github; I hope they respond. <a href="http://twitter.com/zckzck/status/36447074698399744" rel="nofollow">http://twitter.com/zckzck/status/36447074698399744</a>
jankassens超过 14 年前
Mailing list post announcing the blog series:<p><a href="http://www.erlang.org/cgi-bin/ezmlm-cgi?4:mss:56379:201102:pmcahfadajbdldpnmegi" rel="nofollow">http://www.erlang.org/cgi-bin/ezmlm-cgi?4:mss:56379:201102:p...</a>
ddkrone超过 14 年前
This was really cool. It just goes to show you what an experienced programmer with the proper understanding of the tools can accomplish. He right away zeroed in on the blocking nature of certain operations and "erlangized" it, making the entire thing almost as fast as git-daemon.