[erlang-questions] Wanted additions to the maps module?

Raimo Niskanen raimo+erlang-questions@REDACTED
Tue May 10 16:15:53 CEST 2016


On Tue, May 10, 2016 at 01:39:57PM +0000, Grzegorz Junka wrote:
:
> 
> > Performance wise Maps usually beats ETS. Apples and Oranges however. 
> > ETS has other features so it's not a fair comparison.
> 
> Yeah, that's what my test concluded. Initially for small key/values maps 
> are slightly faster. The difference would only grow in favour of maps 
> for more complex payload because of the copying between ETS and the 
> process. But maps consume much more memory than ETS. I believe the 
> memory released when reallocating structures in ETS doesn't need to be 
> garbage collected since it's implemented in C outside of any process memory?

ETS does not even store the payload infact the whole stored tuple in
process heap memory, so the only thing affecting the process heap are the
accumulating fetched tuples that you probably throw away immediately.

The memory used is taken from the memory allocators that probably will get
some fragmentation but as I said it does not show up on any process heap.

> 
> 
> >>     https://gist.github.com/amiramix/d43c9a73a6fe6d651d7f
> >>
> >>     Maps are quite performant but process dictionary is still quicker
> >>     and maps are the worst when it comes to consumed memory, taking
> >>     twice as much as dict or process dictionary and over 5 times as
> >>     much memory as ets.
> >>
> >> Well, you are comparing apples and oranges. Process dictionary and 
> >> ETS are something completely different from gb_trees, dict, maps or 
> >> orddict.
> 
> What's the point of comparing gb_tress to gb_trees or maps to maps?

Please misunderstand correctly.  Nobody is talking about comparing gb_trees
to gb_trees.  What Björn-Egil said was that it is fair to compare any
within the group (gb_trees, dict, maps, orddict) with each other since all
are functional heap based data structures.  But it is not fair to compare
any one in the group with neither the process dictionary nor with ETS.

It is also hard to compare the process dictionary with ETS since the
process dictionary stores on the process heap while ETS stores in other
allocated memory.

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list