[erlang-questions] HTTP client with sessions support
Sat Jun 13 23:12:59 CEST 2015
> On 13 Jun 2015, at 21:35, Ingela Andin <ingela.andin@REDACTED> wrote:
> Creating a name for the profile is not that heavy?! The ets-table is an implementation detail not written in stone, it could use some other data structure like a dict or something. Feel free make a PR, if you make a good case it can be changed.
Creating an ets table really isn’t a heavy operation.
Consider the following program:
t(N) when N > 0 ->
T = ets:new(t, ),
Eshell V5.10.4 (abort with ^G)
That is, on my old Macbook Air, it takes about a microsecond to create an ets table*.
Creating an atom is also obviously cheap, but I cringe a bit when list_to_atom/1 is used in generic code - although in this particular case, I guess creating memory leaks because of it is not very likely.
* Obviously, this test doesn’t accumulate ets tables. I removed the ets:delete/1 call, and things looked much worse:
- Creating the first 1000 tables took ca 13 ms.
- Creating 1000 tables when there were already 67K tables, took 6.2 seconds.
- However, creating an ets table from another process was still pretty fast - ca 10 usec
I conclude that having thousands of ets tables owned by a single process is a *bad* idea (probably not for this reason alone).
Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions