[erlang-questions] Mnesia Reads and Writes

Håkan Mattsson hm@REDACTED
Fri Oct 19 14:15:47 CEST 2012


On Fri, Oct 19, 2012 at 1:26 PM, Jesper Louis Andersen
<jesper.louis.andersen@REDACTED> wrote:
> On Jul 23, 2012, at 12:53 AM, Genti Bogu <gentibogu@REDACTED> wrote:
>
>> I would be glad if somebody could help me understand some basic stuff
>> about Mnesia IO operations.
>> Thanks,
>
> Mnesia is in general optimistic about locking. So upon a possible
> conflict it will retry the transaction. I cannot explain why your
> read-load is 7 times higher, but I would advise that simple
> one-record reads are done in a dirty fashion.

Do not confuse this with optimistic locking. Mnesia uses
*pessimistic* locking combined with deadlock prevention. Newly
started transactions are restarted in favour to older ones in
case of potential deadlocks.

> Note that a dirty read is still atomic for the record, but it
> runs outside the lock manager and is thus much faster.

Dirty access is (of course) faster than access within
transactions. But 7 times seems to be an extreme case.
Transactional access does however involve communication with the
centralized lock manager (one lock manager per node). This may
cause a severe performance penalty on multi core systems. Perhaps
it can explain performance difference in your test. Remote dirty
access do suffer of a similar performance penalty as it also
involves communication with a centralized process (one on the
remote node).

/Håkan



More information about the erlang-questions mailing list