Short and sweet; I'm building a new project which I could back with ETS, but I'd prefer to back with Mnesia - due to things like built-in transactions which may come in handy. I don't care about replication and scaling onto other nodes, which is why I assume Mnesia's performance has overhead on ETS.
zackehh:~/GitHub/my_project$ MIX_ENV=test mix bench
Settings:
duration: 1.0 s
## BasicBench
[19:24:15] 1/4: retrieve key hit mnesia
[19:24:23] 2/4: retrieve key hit
[19:24:30] 3/4: insert new key mnesia
[19:24:33] 4/4: insert new key
Finished in 25.24 seconds
## BasicBench
insert new key 10000000 0.63 µs/op
retrieve key hit 10000000 0.64 µs/op
retrieve key hit mnesia 10000000 0.69 µs/op
insert new key mnesia 500000 4.70 µs/op
I ran a few (local) benchmarks, and it's clear that Mnesia is comparable for read perf, but the write perf is far slower. I'd like to know if there are any ways to speed it up (e.g. turning off replication checking, etc).
Additional info:
Mnesia Table:
[
{ :ram_copies, [node()] },
{ :local_content, true },
{ :attributes, [:key,:value] }
]
Tests
- ETS operations use
:ets.lookup/2
and:ets.insert/2
- Mnesia operations use
:mnesia.dirty_write/1
and:mnesia.dirty_read/2
I've been trawling the docs for hours and nothing has jumped out as a potential way to speed this up - so I might be staring into a perf wall, but if someone could clarify/confirm/suggest, it'd be appreciated.