English 中文(简体)
Erlang file IO and asynchronous threads
原标题:Erlang file IO and asynchronous threads

我正在阅读关于fileio,并看到:

On operating systems with thread support, it is possible to let file operations be performed in threads of their own, allowing other Erlang processes to continue executing in parallel with the file operations. See the command line flag +A in erl(1).

so what I expected was that the time required for an IO operation would be reduced if I added asynchronous threads.
instead, when I tried running erl +A1,erl +A6 or erl +A12 (on a 6-core machine) the time required to write in a file increased 5-10 times.

I used timer:tc/3 to measures time and I used io:write/2, file:write/2 (改用二字)和<代码>:write/2 在向<代码>raw<>/代码>开放文档时 国旗。 该词的大小为170kb,书写了1,000次。 使用了R14B04(但我也取得了类似结果)。

我做过错,要么是利用超常的IO,要么衡量其效率?

采用这一术语(或许是因为其规模很小)后引入的间接费用是否超过了所加快的程度?

a) 《(不是这样)法典》:

-module(test).
-compile(export_all).

test()->
    {ok,F}=file:open(foo,[raw,write]),          % or just [write]
    {T,ok}=timer:tc(test,t,[F,1000]),
    file:close(F),
    T.

t(_,0)->ok;
t(F,A)->
    B=dsafasfagafssadagfsdsaasdfdsafasfagafssadagfsdsaasdfdsafasfagafssadagfsdsaasdfdsafasfagafssadagfsdsaasdfdsafasfagafssadagfsdsaasdfagafssadagfsdsaasdfdsafasfagafssadagfsdsaasdfdsafasfagafssadagfsdsaasdfdsafasfagafssadagfsdsaasdf,

    file:write(F,
term_to_binary([B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,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B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B])),
%or io:write(F,[B,..])
    t(F,A-1).

我有兴趣尽量降低国际交易日志的间接费用(基本上只是产出),因为我想在图谱中写一些数据,以软磁盘;为什么将数据发送到将做书面工作的其他一些进程并不有用(除非我能够把一个核心用于一个过程)。 至今,最佳方法似乎正在打开原始档案,积累数据,然后编写;任何提纲都会得到赞赏:

最佳回答

当我接受测试时,我与+A1一样,没有。 这在SOS Xnow Leopard,有双重核心处理器。 这也是我期望使用星座的情况。

添加象牙齿只增加了子read,使IO能够从事平行综合体的工作,从而增加其业绩,还使正常的地兰过程能够以更快的速度进行,因为这一过程的胎面不会忙于综合体的工作。

如果你与许多平行的工作一起进行测试,那么你就应当看到使用合成镜的性能提高。

为什么你们的连续测试表现下降,是一 my。

问题回答

暂无回答




相关问题
Asynchronous data loading in Entity-Framework?

Did anyone hear about asynchronous executing of an EF query? I want my items control to be filled right when the form loads and the user should be able to view the list while the rest of the items ...

Does PHP support asynchronous programming?

I m new to PHP. I am familiar with ASP.NET which support asynchronous programming. That is, if one request needs to do some I/O job. It is suggested to program the web page with BeginProcess/...

How to cancel an asynchronous call?

How to cancel an asynchronous call? The .NET APM doesn t seem to support this operation. I have the following loop in my code which spawns multiple threads on the ThreadPool. When I click a button on ...

What can cause select to block in Python?

Here s a snippet of code I m using in a loop: while True: print loop rlist, wlist, xlist = select.select(readers, [], [], TIMEOUT) print selected # do stuff At a certain point, ...

热门标签