[erlang-questions] Does read-write lock has a better performance than actor model?

Xiao Jia me@REDACTED
Tue Apr 15 16:03:45 CEST 2014

I want to propose a possible solution, but I am not confident:

We probably want to publish readable states to a process (or several
processes with load balancing?) dedicated to serving read requests.  The
cost is that after each write operation, the state must be published again.
 If there are much more reads than writes, the read serving process's
mailbox size will be much larger than the write serving process.  If I
remember it correctly, this helps the scheduler to give more priority to
the read serving process, or to give less priority to readers because the
mailbox is already full of requests.

As I said, I am not confident about my proposal.  Hope someone helps to
correct me :-D

On Tue, Apr 15, 2014 at 3:46 PM, Bin Wang <wbin00@REDACTED> wrote:

> I meas if there is a write, then give it a lock. If all the requests are
> read operations, then no lock is needed. That means multiple read
> operations could be doing at the same time while there is no write
> operations.
> However, in actor model, the requests are always handled one by one no
> matter they are reads or writes. So didn't it slow at some situations?
> (Read are more that write).
> ---
> Bin Wang
> 2014-04-15 21:37 GMT+08:00 Dmitry Kolesnikov <dmitry@REDACTED>:
>> Hello,
>> No, this is not good.
>> Any on-going "write request" makes changes to the state. The read request
>> does not know when the state becomes consistent unless there is a lock on
>> the state. You cannot ensure safe reading while writes is going on.
>> Therefore, actor model has bigger advantage.
>> - Dmitry
>> On 15 Apr 2014, at 16:31, Bin Wang <wbin00@REDACTED> wrote:
>> > In Erlang, we handle concurrency in such a way: a process receives
>> messages in its mailbox. And handle them one by one, just one in the same
>> time.
>> >
>> > But in some situation, the request just want to read the resource. So
>> the read requests should be able to execute at the same time since they
>> don't change or break anything.
>> >
>> > So dose this meas if we use a write lock in such situation, we will
>> have a better performance? If so, does Erlang have a proper way to do that?
>> >
>> > Thanks.
>> >
>> > ---
>> > Bin Wang
>> > _______________________________________________
>> > erlang-questions mailing list
>> > erlang-questions@REDACTED
>> > http://erlang.org/mailman/listinfo/erlang-questions
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

Xiao Jia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140415/5f534b49/attachment.htm>

More information about the erlang-questions mailing list