[erlang-questions] where it's the best way to store a very big term object shared between processes

Caragea Silviu silviu.cpp@REDACTED
Thu Oct 22 10:29:17 CEST 2015


Hello.

In one of my projects I need to use a radix tree. I found out a very nice
library :
https://github.com/okeuday/trie

Lookup performances are great. But I have one problem.

Basically my tree has around 100 000 elements so building it it's an
extremely operation. For this reason I'm building it once and all processes
that needs to do lookups need to share the btrie object (created using
btrie:new/1).

Here I see several options:

1. Use a gen server and store the btrie object on the state or process
dictionary. - I didn't tried this
2. Use a ets table and store the tire object on a public table where all
processes can read and  write.

Doing some benchmarks I see that lookup-ing for the longest prefix (btrie:
find_prefix_longest) in around 100 K elements by prefix it's around 2- 5 ms
and 95% of the time is spent in the ets:lookup.

I think the time spent there is so big because also my term stored there is
very big.

Any other suggestions ?

Silviu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20151022/57a56795/attachment.htm>


More information about the erlang-questions mailing list