[erlang-questions] mnesia async vs sync

Dan Gudmundsson dangud@REDACTED
Mon Mar 14 16:27:58 CET 2016


On Mon, Mar 14, 2016 at 1:54 PM Roberto Ostinelli <roberto@REDACTED>
wrote:

> On Mon, Mar 14, 2016 at 12:47 PM, Dan Gudmundsson <dangud@REDACTED>
> wrote:
>
>> Try using mnesia:write instead of mnesia:dirty_write inside your fun.
>>
>
> Making this change makes sync_dirty much slower when there are more than
> just one node. So, this clarifies that probably using dirty_write with
> sync_dirty falls back to async_dirty anyway.
>

dirty_write does not care if you use async_dirty, sync_dirty or apply fun
directly.


> However, the findings still persist: the more nodes you add, the slower
> the writing to mnesia is, even when using async_dirty.
>
>
I don't see the problem with that, you run more code, and send more
messages when you have more nodes.
When running with one node, you only use the local node with no
distribution at all, with several nodes you might block on send because
tcp buffers are full and so on.

You should use mnesia:write and compare async_ vs sync_.

/Dan


> Any other ideas?
>
> Best,
> r.
>
>
>
> %%%%% RESULTS %%%%%
>
> write_bench(Count) ->
>     F = fun(N) ->
>         mnesia:activity(sync_dirty, fun() ->
>             mnesia:write(#test_table{key = N, value = N})
>         end)
>     end,
>     lists:foreach(F, lists:seq(1, Count)).
>
>
>  mnesia_test:write(['1@REDACTED']).
> Written in 1.756049 sec, at a rate of 284730.095800288/sec
>
>  mnesia_test:write(['1@REDACTED','2@REDACTED']).
> Written in 37.094925 sec, at a rate of *13478*.932765061529/sec
>
>
> write_bench(Count) ->
>     F = fun(N) ->
>         mnesia:activity(async_dirty, fun() ->
>             mnesia:write(#test_table{key = N, value = N})
>         end)
>     end,
>     lists:foreach(F, lists:seq(1, Count)).
>
>  mnesia_test:write(['1@REDACTED']).
> Written in 1.914213 sec, at a rate of 261203.9517023445/sec
>
>  mnesia_test:write(['1@REDACTED','2@REDACTED']).
> Written in 3.402219 sec, at a rate of 146962.9086193452/sec
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160314/6a11ad87/attachment.htm>


More information about the erlang-questions mailing list