[erlang-questions] gen_server mailbox scans
Thu Jan 15 10:08:51 CET 2009
On Thu, Jan 15, 2009 at 4:58 AM, Chandru
> 2009/1/14 Ben Hood <0x6e6562@REDACTED>
> * process_info(Pid, message_queue_len) will probably lie now because the
> mailbox has been drained into an internal queue. If your message queue is
> indeed building up in a message storm, diagnosing the problem will become
> more difficult.
True - we would have to implement the queue length function in the
> * And if you did a sys:get_status(Pid) on the gen_server, you will copying
> the entire message queue just to view it...
> * Crash reports will be MUCH bigger.
Sure - transferring the mailbox to process memory does make reading
the state of the process much more heavyweight.
So it would be a good idea to try to avoid this standard calls.
However, I still think the benefit of avoiding the scan outweighs
these disadvantages in our particular use case. Previously, we used an
intermediate process as a buffering proxy to solve this problem, but
modifying gen_server seems less intrusive from an API perspective, and
it means that we have one less moving part.
Ideally it would nice to have an index on the mailbox to avoid the linear scan.
Thanks for your thoughts on this issue,
More information about the erlang-questions