[erlang-questions] Re: Unicast 20k messages, $500-$1000 bounty
Paulo Sérgio Almeida
Thu Jul 16 17:35:02 CEST 2009
Joel Reymont wrote:
> Also, instead of duplicating the table data by building a list, why not
> use ets:first and ets:next?
To be sure one has to measure. But my intuition is that select followed
by list traversal avoids a ping-pong between built-in and user code. It
will use a built-in function (C) to operate in bulk over the table,
extracting only what is needed. Then you just traverse the list; and
Erlang is very good operating on lists.
Also the list produced should be quite compact, with good memory
locality. <- Is this true?
Also, the negative impact due to GC should be later, after the messages
have been sent. But in this case not even GC is a problem as the process
exits after sending the msgs.
Btw, now I noticed a pontential problem. I don't know what deliveery
semantics you aim for, but now you don't have total order in message
delivery even for the same topic. As the sending is in a spawned proc,
two clients can receive two msgs A and B from the same topic one in the
order A -> B and the other B -> A. As you already have middleman, why
not do the sending without spawning a proc?
More information about the erlang-questions