[erlang-questions] process dictionary, anyone?
Ulf Wiger (TN/EAB)
Tue Apr 24 09:33:26 CEST 2007
Robert Virding wrote:
> Trouble is that it breaks the functional part of the
> language. Now that is only really done in process
> dictionary, processes/message, ports and ets. Though
> both ets and ports can be considered as processes/messages
> and can be implemented as such though a bit less efficiently.
And the process dictionary could be implemented with processes
and messages too, although a bit less efficiently.
> So globals variables in the process dictionary is not
> really a Good Thing. Using them as settable constants
> would be perhaps ok. How about having them as variables
> and only be set-once?
The most common users of the process dictionary in OTP are
proc_lib and mnesia. Proc_lib inserts observable properties
in the process dictionary, and these are never changed.
They are used mainly for debugging and error reporting.
Mnesia inserts a transaction identifier in the process
dictionary, and this Tid lives for the duration of the
transaction. It has dynamic parts, and is modified/
extended if nested transactions are started.
Addressing these two needs will probably get you
Personally, I'm intrigued by the proc_lib aspect.
I've spent some time thinking about how one would
go about debugging systems with several hundred
thousand, or millions of, processes. Clearly,
introspection functions that begin with calling
processes() are not going to be that useful - nor
functions that pretty-print all meta data for all
processes in the system. I'm leaning towards having
a central process dictionary index, where selected
entries in the process dictionary could be indexed.
This could then be used to find processes sharing
a common trait.
More information about the erlang-questions