mifrai
2012-03-17 11:00:49 UTC
Hi,
I have a few questions about AcidState best practices / behavior and I
was hoping to get some help. In particular, I'm wondering about the
following things:
* Should I use a single monolithic AcidState or should l use several
smaller ones? What are the advantages of one vs. the other?
I have a few guesses, but I'm not too familiar with AcidState - so
please correct me if I'm wrong. One advantage of a single monolithic
one that I can think of is that you can get transactions across every
piece of data in your code. A disadvantage is that all writes must
happen sequentially and thus you're essentially introducing a global
lock on your database writes. Is AcidState typically 'fast enough'
that this is negligible?
* Speaking of global write locking - I'm also wondering about how you
should form your Query / Update events and how you should handle long
running Update events. For example, if I had code (using lenses) like:
updateSomething :: Update ...
updateSomething = do
something <- access (deep . inside)
(deep . inside) ~= someLongExpensiveOperation something
Is there a preferred way to deal with something like that? Should
these be split into Query and Update and them join them in IO?
Would someLongExpensiveOperation occur within the AcidState Core lock
or will it occur outside? If within, is there a preferred way to make
it occur outside?
How do I decide between splitting them and using them as a single
event?
* On a related note, are arguments passed in lazily going to be
calculated in the core lock instead of outside it? For example, if I
had: update as $ UpdateEvent (someLongExpensiveOperation something).
* Oh, and one more question - am I right to assume that Query events
do not block Update events and vice versa?
Thanks,
- Mike
I have a few questions about AcidState best practices / behavior and I
was hoping to get some help. In particular, I'm wondering about the
following things:
* Should I use a single monolithic AcidState or should l use several
smaller ones? What are the advantages of one vs. the other?
I have a few guesses, but I'm not too familiar with AcidState - so
please correct me if I'm wrong. One advantage of a single monolithic
one that I can think of is that you can get transactions across every
piece of data in your code. A disadvantage is that all writes must
happen sequentially and thus you're essentially introducing a global
lock on your database writes. Is AcidState typically 'fast enough'
that this is negligible?
* Speaking of global write locking - I'm also wondering about how you
should form your Query / Update events and how you should handle long
running Update events. For example, if I had code (using lenses) like:
updateSomething :: Update ...
updateSomething = do
something <- access (deep . inside)
(deep . inside) ~= someLongExpensiveOperation something
Is there a preferred way to deal with something like that? Should
these be split into Query and Update and them join them in IO?
Would someLongExpensiveOperation occur within the AcidState Core lock
or will it occur outside? If within, is there a preferred way to make
it occur outside?
How do I decide between splitting them and using them as a single
event?
* On a related note, are arguments passed in lazily going to be
calculated in the core lock instead of outside it? For example, if I
had: update as $ UpdateEvent (someLongExpensiveOperation something).
* Oh, and one more question - am I right to assume that Query events
do not block Update events and vice versa?
Thanks,
- Mike
--
You received this message because you are subscribed to the Google Groups "HAppS" group.
To post to this group, send email to happs-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to happs+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/happs?hl=en.
You received this message because you are subscribed to the Google Groups "HAppS" group.
To post to this group, send email to happs-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to happs+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/happs?hl=en.