[erlang-questions] How does gproc register global names?

Pablo Platt pablo.platt@REDACTED
Wed Oct 27 00:58:19 CEST 2010


> True, but my idea was that OTP integrate gproc and make gen.erl
> aware of gproc-registered names. :)

Why doesn't OTP integrate gproc?
It is already used and tested by several people.
The code and api are very good.

Can someone from the Erlang team pick up the glove?






________________________________
From: Ulf Wiger <ulf.wiger@REDACTED>
To: Pablo Platt <pablo.platt@REDACTED>
Cc: erlang-questions@REDACTED
Sent: Tue, October 26, 2010 7:27:45 PM
Subject: Re: [erlang-questions] How does gproc register global names?


On 26 Oct 2010, at 18:49, Pablo Platt wrote:

> Why doesn't mnesia have a 'light weight' transaction that works like gproc?

Mnesia has a slightly different charter, ensuring consistent persistency.


> When a new leader is elected, how does other nodes knows which names it doesn't 
>know about?

In the Mod:elected() callback, the newly elected leader can 
pass data to the others, which they receive in Mod:surrender().

> I'm using gproc to register gen_server processes.
> It might be useful to have gproc:cast and gproc:call that use gen_server:cast 
>and gen_server:call in addition to gproc:send.

True, but my idea was that OTP integrate gproc and make gen.erl
aware of gproc-registered names. :)

> Is it possible to count all registered processes without using a counter?

It would be possible if the function gproc:pattern/2 were exported, or 
a function gproc:select_count/2 were added, similar to select/2 et all,
which are already there.

> Is it possible to page thorough all registered processes?

Yes, with either QLC (using gproc:table/1) or using gproc:select/3 (using 
the Limit argument to fetch a give number of objects at a time.

BR,
Ulf W


> 
> Thanks
> 
> 
> 
> From: Ulf Wiger <ulf.wiger@REDACTED>
> To: Pablo Platt <pablo.platt@REDACTED>
> Cc: erlang-questions@REDACTED
> Sent: Tue, October 26, 2010 5:31:24 PM
> Subject: Re: [erlang-questions] How does gproc register global names?
> 
> 
> It is correct that gproc uses gen_leader.
> All registration reguests are passed on to the leader process,
> and it broadcasts the results to the other candidates & workers.
> Monitoring of registered processes is done by the local gproc
> instance.
> 
> When a new leader is elected, it sends its list of registered names
> to the others; if they happen to have names that the new leader 
> doesn't know about, they will send them to the new leader.
> 
> This is not terribly unlike how global does things, although it uses
> a multicall mechanism to handle atomicity. In measurements that 
> I've made, the gproc method is much more efficient.
> 
> OTOH, global has facilities to handle partitioned networks. Gproc
> doesn't... yet.
> 
> Using mnesia would not give better consistency, unless transactions
> are used - but that would kill performance. And there are no persistency
> reasons to use it either. Gproc uses ets tables, which are rigged to survive
> even if the gproc process dies; the restarted gproc scans the table and 
> sets new monitors.
> 
> BR,
> Ulf W
> 
> On 26 Oct 2010, at 15:48, Pablo Platt wrote:
> 
> > Hi
> > 
> > I'm using gproc to register local names and properties.
> > I've read that gen_leader is needed to use gproc in the global scope.
> > 
> > How does the data get synced across all nodes?
> > Why isn't mnesia being used for that?
> > How do you solve race conditions and failures?
> > 
> > Thanks
> > 
> > 
> > 
> 
> Ulf Wiger, CTO, Erlang Solutions, Ltd.
> http://erlang-solutions.com
> 
> 
> 
> 
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
> 
> 
> 

Ulf Wiger, CTO, Erlang Solutions, Ltd.
http://erlang-solutions.com


      


More information about the erlang-questions mailing list