[erlang-questions] Can gen_tcp/inets store connection-specific user state?
Tony Arcieri
tony.arcieri@REDACTED
Tue Jul 20 18:46:41 CEST 2010
On Tue, Jul 20, 2010 at 5:57 AM, Tony Rogvall <tony@REDACTED> wrote:
> Why do you lose the O(1) ? ets:lookup on a set table is O(1) ? ordered_set
> is O(log(N)) .
> Please enlighten me ;-)
>
I'm afraid you're the one who will have to enlighten me here.
My understanding is that ETS are implemented as Judy tables, which I know
very little about and sound rather complicated. I can't find specific
details about the algorithmic complexity of Judy lookup, except one
reference to it being worse case O(log_256 n). Are you suggesting it
is amortized O(1) or something?
Round tripping the state end-to-end ensures it never needs to be placed in
any kind of associative data structure and precludes the issue entirely.
However, as you mentioned, yes it would seem that there would be a degree
of copying involved, or rather the construction of new terms which
delivering the gen_tcp messages has to do anyway.
It's sounding to me like a proxy process is probably the best way to go.
This at least lets me link the proxy to the controlling process of a
particular socket, so I don't have to worry about "garbage collecting" the
ports/socket objects from an ets table.
--
Tony Arcieri
Medioh! A Kudelski Brand
More information about the erlang-questions
mailing list