[erlang-questions] dict vs. ETS choice
Thu Jul 10 23:26:38 CEST 2014
Naturally, measure first.
Implement both methods. Switching from one to the other is trivial anyway.
For a hashtable store that is read-mostly I would suggest you use the
process dictionary instead of ETS.
I have measured a 100x speedup compared to ETS (details and implementation
Though you have to be careful with your writes as proc.dict. is a mutable
datastructure. You might be interested in reading this .
On 10 July 2014 22:56, zxq9 <zxq9@REDACTED> wrote:
> On Thursday 10 July 2014 14:29:42 Derek Brown wrote:
> > Let's say you want to store on the order of tens of thousands key/value
> > pairs, with integer keys and proplist values (less than 10 simple
> > pairs per proplist). Read-heavy with few writes.
> > What factors would you consider when going with a dict or an ETS table,
> > perhaps something else?
> Factors to consider? Whatever benchmarking both cases tells me. I would run
> each test case alongside a few different workloads on the same machine to
> figure out what good/bad things to expect from each approach.
> Someone will probably come along who actually has done this both ways and
> you there is indeed a Right Way, but usually I've found that taking the
> to run some informal benchmarks provides more insight (which winds up
> elsewhere) than adherence to advice/data structure guidelines. Also, data
> structure advice often turns out to be a wordy version of "it depends..."
> then a request for more information about the higher level problem you're
> actually trying to solve.
> What is the overall effect you're trying to achieve? It would be helpful to
> spell out the problem you're trying to solve (at the higher level like
> "how to
> best store 100k player's stats at once" instead of at the implementation
> detail of "is a dict or an ETS table better for 100k values?"). Very often
> you'll find someone has already tackled something similar and can give you
> some good advice you'd never get when asking just about the details of data
> structures. This prevents X->Y problem discussions.
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions