<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Case Study: Fast File IO in Erlang</title>
	<atom:link href="http://erlang-china.org/study/erlang_fast_file_io.html/feed" rel="self" type="application/rss+xml" />
	<link>http://erlang-china.org/study/erlang_fast_file_io.html</link>
	<description>erlang 中文社区</description>
	<lastBuildDate>Tue, 03 Jan 2012 15:49:56 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
	<item>
		<title>By: jackyz</title>
		<link>http://erlang-china.org/study/erlang_fast_file_io.html/comment-page-1#comment-1718</link>
		<dc:creator>jackyz</dc:creator>
		<pubDate>Mon, 05 Nov 2007 02:13:43 +0000</pubDate>
		<guid isPermaLink="false">http://erlang-china.org/study/erlang_fast_file_io.html#comment-1718</guid>
		<description>@Arbow well done.</description>
		<content:encoded><![CDATA[<p>@Arbow well done.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arbow</title>
		<link>http://erlang-china.org/study/erlang_fast_file_io.html/comment-page-1#comment-1716</link>
		<dc:creator>Arbow</dc:creator>
		<pubDate>Fri, 02 Nov 2007 17:42:57 +0000</pubDate>
		<guid isPermaLink="false">http://erlang-china.org/study/erlang_fast_file_io.html#comment-1716</guid>
		<description>事情现在有了新的进展了，jackyz让俺写个类似的后续报道，因为一直没有跟进，写不出来，只能提提之后的情况，还是蛮精彩，不容错过。

在文中，继使用bfile模块和并行算法来提高效率后，大伙们仍然在继续研究。dcaoyuan在 http://blogtrader.org/page/dcaoyuan/entry/learning_coding_binary_was_tim 里面公布了最新的进展，这个纯Erlang的方案能够在3秒内完成计算：

$ erlc -smp tbray5.erl
$ time erl +h 8192 -smp -noshell -run tbray5 start o1000k.ap -s erlang halt

real    0m2.972s
user    0m9.685s
sys     0m0.748s

诀窍是如下几个要点：
I. Don&#039;t split a binary unless the split binaries are what you exactly want
II. Calculate the final offsets first, then split it when you&#039;ve got the exactly offsets
III. Use &quot;+h Size&quot; option or [{min_heap_size, Size}] with spawn_opt
IV. Others
    * Don&#039;t forget to compile to native by adding &quot;-compile([native]).&quot; in your code.
    * Maybe &quot;+A Size&quot; to set the number of threads in async thread pool also helps a bit when do IO.

代码可以在 http://blogtrader.net/page/dcaoyuan/resource/code/tbray5.erl 下载。


过了几天，http://www.erlang.org/pipermail/erlang-questions/2007-October/030273.html 中，pichi同学上传了他的更快更强的方案，含 chunk_reader.erl,nlt_reader.erl,file_map_reduce.erl和wf_pichi3.erl四个文件，代码量达到500+之巨。

紧接着(http://www.erlang.org/pipermail/erlang-questions/2007-October/030278.html)，
Anders改进了自己的代码(wfinder1_1 + wfbm4_ets1_1)，在 8-core 2.33GHz Intel Xeon Linux,2G RAM的机器上，取得了
real 0m0.567s
user 0m2.249s
sys  0m0.956s
的高性能。

10.30，http://www.tbray.org/ongoing/When/200x/2007/10/30/WF-Results 公布了结果，第一版代码中相对Ruby代码极差的性能，现在性能幅度已经提升得相当高了：

Name 	   Language 	Elapsed User 	System 	LoC
wfinder1_1 Erlang 	6.46 	34.07 	8.02 	287 	
wf_pichi3  Erlang 	8.28 	51.98 	9.38 	545
tbray5 	   Erlang 	20.74 	3:51.33 8.00 	76
wf_p 	   Ruby 	50.16 	37.58 	12.50 	39

11.1 dcaoyuan在 http://blogtrader.org/page/dcaoyuan/entry/learning_coding_binary_was_tim 更新补充了 Boyer-Moore搜索算法，性能可以提高100%。</description>
		<content:encoded><![CDATA[<p>事情现在有了新的进展了，jackyz让俺写个类似的后续报道，因为一直没有跟进，写不出来，只能提提之后的情况，还是蛮精彩，不容错过。</p>
<p>在文中，继使用bfile模块和并行算法来提高效率后，大伙们仍然在继续研究。dcaoyuan在 <a href="http://blogtrader.org/page/dcaoyuan/entry/learning_coding_binary_was_tim" rel="nofollow">http://blogtrader.org/page/dcaoyuan/entry/learning_coding_binary_was_tim</a> 里面公布了最新的进展，这个纯Erlang的方案能够在3秒内完成计算：</p>
<p>$ erlc -smp tbray5.erl<br />
$ time erl +h 8192 -smp -noshell -run tbray5 start o1000k.ap -s erlang halt</p>
<p>real    0m2.972s<br />
user    0m9.685s<br />
sys     0m0.748s</p>
<p>诀窍是如下几个要点：<br />
I. Don&#8217;t split a binary unless the split binaries are what you exactly want<br />
II. Calculate the final offsets first, then split it when you&#8217;ve got the exactly offsets<br />
III. Use &#8220;+h Size&#8221; option or [{min_heap_size, Size}] with spawn_opt<br />
IV. Others<br />
    * Don&#8217;t forget to compile to native by adding &#8220;-compile([native]).&#8221; in your code.<br />
    * Maybe &#8220;+A Size&#8221; to set the number of threads in async thread pool also helps a bit when do IO.</p>
<p>代码可以在 <a href="http://blogtrader.net/page/dcaoyuan/resource/code/tbray5.erl" rel="nofollow">http://blogtrader.net/page/dcaoyuan/resource/code/tbray5.erl</a> 下载。</p>
<p>过了几天，http://www.erlang.org/pipermail/erlang-questions/2007-October/030273.html 中，pichi同学上传了他的更快更强的方案，含 chunk_reader.erl,nlt_reader.erl,file_map_reduce.erl和wf_pichi3.erl四个文件，代码量达到500+之巨。</p>
<p>紧接着(http://www.erlang.org/pipermail/erlang-questions/2007-October/030278.html)，<br />
Anders改进了自己的代码(wfinder1_1 + wfbm4_ets1_1)，在 8-core 2.33GHz Intel Xeon Linux,2G RAM的机器上，取得了<br />
real 0m0.567s<br />
user 0m2.249s<br />
sys  0m0.956s<br />
的高性能。</p>
<p>10.30，http://www.tbray.org/ongoing/When/200x/2007/10/30/WF-Results 公布了结果，第一版代码中相对Ruby代码极差的性能，现在性能幅度已经提升得相当高了：</p>
<p>Name 	   Language 	Elapsed User 	System 	LoC<br />
wfinder1_1 Erlang 	6.46 	34.07 	8.02 	287<br />
wf_pichi3  Erlang 	8.28 	51.98 	9.38 	545<br />
tbray5 	   Erlang 	20.74 	3:51.33 8.00 	76<br />
wf_p 	   Ruby 	50.16 	37.58 	12.50 	39</p>
<p>11.1 dcaoyuan在 <a href="http://blogtrader.org/page/dcaoyuan/entry/learning_coding_binary_was_tim" rel="nofollow">http://blogtrader.org/page/dcaoyuan/entry/learning_coding_binary_was_tim</a> 更新补充了 Boyer-Moore搜索算法，性能可以提高100%。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mryufeng</title>
		<link>http://erlang-china.org/study/erlang_fast_file_io.html/comment-page-1#comment-846</link>
		<dc:creator>mryufeng</dc:creator>
		<pubDate>Thu, 11 Oct 2007 06:58:35 +0000</pubDate>
		<guid isPermaLink="false">http://erlang-china.org/study/erlang_fast_file_io.html#comment-846</guid>
		<description>个人感觉IO不会慢  而是处理数据的时候变形太多 导致效率不理想。这种应用还是让erlang作master的工作 cport用来作worker最简单。不过这篇讨论把erlang 能想出来提高效率的招都摆到桌面上来了 对于应用的开发有很大的参考意义。</description>
		<content:encoded><![CDATA[<p>个人感觉IO不会慢  而是处理数据的时候变形太多 导致效率不理想。这种应用还是让erlang作master的工作 cport用来作worker最简单。不过这篇讨论把erlang 能想出来提高效率的招都摆到桌面上来了 对于应用的开发有很大的参考意义。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pi1ot</title>
		<link>http://erlang-china.org/study/erlang_fast_file_io.html/comment-page-1#comment-797</link>
		<dc:creator>pi1ot</dc:creator>
		<pubDate>Mon, 08 Oct 2007 03:45:13 +0000</pubDate>
		<guid isPermaLink="false">http://erlang-china.org/study/erlang_fast_file_io.html#comment-797</guid>
		<description>只是提供一套高效的regex就可以算是高效处理大文本吗？</description>
		<content:encoded><![CDATA[<p>只是提供一套高效的regex就可以算是高效处理大文本吗？</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackyz</title>
		<link>http://erlang-china.org/study/erlang_fast_file_io.html/comment-page-1#comment-796</link>
		<dc:creator>jackyz</dc:creator>
		<pubDate>Mon, 08 Oct 2007 02:46:45 +0000</pubDate>
		<guid isPermaLink="false">http://erlang-china.org/study/erlang_fast_file_io.html#comment-796</guid>
		<description>实际工作中的log分析还是用perl/awk这些传统工具比较靠谱。

erlang的文件io，bluetail的bfile方案是很不错的选择，如果能尽快纳入OTP就太好了。</description>
		<content:encoded><![CDATA[<p>实际工作中的log分析还是用perl/awk这些传统工具比较靠谱。</p>
<p>erlang的文件io，bluetail的bfile方案是很不错的选择，如果能尽快纳入OTP就太好了。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dcaoyuan</title>
		<link>http://erlang-china.org/study/erlang_fast_file_io.html/comment-page-1#comment-786</link>
		<dc:creator>dcaoyuan</dc:creator>
		<pubDate>Sun, 07 Oct 2007 06:14:43 +0000</pubDate>
		<guid isPermaLink="false">http://erlang-china.org/study/erlang_fast_file_io.html#comment-786</guid>
		<description>perl</description>
		<content:encoded><![CDATA[<p>perl</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pi1ot</title>
		<link>http://erlang-china.org/study/erlang_fast_file_io.html/comment-page-1#comment-785</link>
		<dc:creator>pi1ot</dc:creator>
		<pubDate>Sun, 07 Oct 2007 02:23:12 +0000</pubDate>
		<guid isPermaLink="false">http://erlang-china.org/study/erlang_fast_file_io.html#comment-785</guid>
		<description>说到log分析，有什么适于处理大文本的语言么，主要是性能方面。</description>
		<content:encoded><![CDATA[<p>说到log分析，有什么适于处理大文本的语言么，主要是性能方面。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dcaoyuan</title>
		<link>http://erlang-china.org/study/erlang_fast_file_io.html/comment-page-1#comment-779</link>
		<dc:creator>dcaoyuan</dc:creator>
		<pubDate>Fri, 05 Oct 2007 15:37:51 +0000</pubDate>
		<guid isPermaLink="false">http://erlang-china.org/study/erlang_fast_file_io.html#comment-779</guid>
		<description>刚刚重写了代码：http://blogtrader.net/page/dcaoyuan?entry=tim_bray_s_erlang_exercise1
新版本用了Per的部分代码，差不多是个完整本了，而且，比较地象一个真正的并行处理。在2-core的机器上可以有差不多177%的性能提升。
Erlang的binary match看来目前不适合做太细节的binary处理，还是转换成一小段一小段的list好些。</description>
		<content:encoded><![CDATA[<p>刚刚重写了代码：http://blogtrader.net/page/dcaoyuan?entry=tim_bray_s_erlang_exercise1<br />
新版本用了Per的部分代码，差不多是个完整本了，而且，比较地象一个真正的并行处理。在2-core的机器上可以有差不多177%的性能提升。<br />
Erlang的binary match看来目前不适合做太细节的binary处理，还是转换成一小段一小段的list好些。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pi1ot</title>
		<link>http://erlang-china.org/study/erlang_fast_file_io.html/comment-page-1#comment-777</link>
		<dc:creator>pi1ot</dc:creator>
		<pubDate>Thu, 04 Oct 2007 08:46:46 +0000</pubDate>
		<guid isPermaLink="false">http://erlang-china.org/study/erlang_fast_file_io.html#comment-777</guid>
		<description>erlang适合做把文本分析的任务分解到几十个节点上然后再合并结果的工作，每个节点一个c port。</description>
		<content:encoded><![CDATA[<p>erlang适合做把文本分析的任务分解到几十个节点上然后再合并结果的工作，每个节点一个c port。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xushiwei</title>
		<link>http://erlang-china.org/study/erlang_fast_file_io.html/comment-page-1#comment-776</link>
		<dc:creator>xushiwei</dc:creator>
		<pubDate>Thu, 04 Oct 2007 08:46:22 +0000</pubDate>
		<guid isPermaLink="false">http://erlang-china.org/study/erlang_fast_file_io.html#comment-776</guid>
		<description>再仔细看了Caoyuan的程序，看起来直接操作binary是可行的（我原先有点担心binary的split是一个费时的行为，另外有点不太熟悉binary的语法）。</description>
		<content:encoded><![CDATA[<p>再仔细看了Caoyuan的程序，看起来直接操作binary是可行的（我原先有点担心binary的split是一个费时的行为，另外有点不太熟悉binary的语法）。</p>
]]></content:encoded>
	</item>
</channel>
</rss>

