Make use of TransactionFactoryBuilder and expose STM transaction settings
Move the creation of the TransactionFactory from the transaction to the Actor itself. Set the name of the Actor as tx family name.
TransactionFactoryBuilder:
http://multiverse.codehaus.org/apidocs/org/multiverse/api/TransactionFactoryBuilder.html
Example:
Peter Veentjer (6 May):
In Multiverse I expose these property through annotation parameters, e.g.
I'm not sure about closures in Scala since I'm a Scala noob, but they should be configurable somehow
e.g.
Using the correct settings can have a big performance impact, even though Multiverse
already tries to learn from past executions (readonly, trackreads for retry behavior,
and optimal transaction size).
Make sure that the transactionFactoryBuilder is configured with:
setSpeculativeConfigurationEnabled(true) to let Multiverse use speculative executions to figure out the best settings (readonly vs update, non readtracking vs readtracking (for blocking operations) and figure out the optimal transaction implementation based on the transaction length).
And make sure that the
setExplicitRetryAllowed(false)
If you are creating transactors because they should not block. If a user somehow does an explicit retry (needed for blocking operations), the retry is rejected and the a noretrypossibleexception is thrown.
On Thu, May 6, 2010 at 12:24 PM, Peter Vlugter wrote:
At the moment, as far as I know, there's no transaction factory or builder being used explicitly. So there's:
def atomic[T](body: => T): T = {
new TransactionTemplate[T]() {
...
which I'm assuming uses a general transaction factory from the stm?
Yes.. the transactiontemplate creates one if one is not specified. If you look at the constructors of the TransactionTemplate you will see that there also is one with the TransactionFactory. The constructor you are using is a convenience constructor.. but should not be used.
http://multiverse.codehaus.org/apidocs/org/multiverse/templates/TransactionTemplate.html
TransactionFactoryBuilder:
http://multiverse.codehaus.org/apidocs/org/multiverse/api/TransactionFactoryBuilder.html
Example:
class MyActor extends Actor{
static final TransactionFactory txFactory = GlobalStmInstance().getGlobalStmInstance().
.getTransactionFactoryBuilder()
.setSpeculativeConfigurationEnabled(true)
.setExplicitRetryAllowed(false)
.setReadonly(false)
.setTrackReads(true)
.build();
final TransactionTemplate template = new TransactionTemplate(txFactory){
public Object execute(Transaction tx){
.... user code
return null;
}
}
void receive(){
template.execute();
}
}
Peter Veentjer (6 May):
In Multiverse I expose these property through annotation parameters, e.g.
@TransactionalMethod(readonly = false, trackReads = true, writeSkew = false)
public void foo(){
,,,
}
I'm not sure about closures in Scala since I'm a Scala noob, but they should be configurable somehow
e.g.
atomic(readonly =true, writeSkew=false){
...
}
Using the correct settings can have a big performance impact, even though Multiverse
already tries to learn from past executions (readonly, trackreads for retry behavior,
and optimal transaction size).
Make sure that the transactionFactoryBuilder is configured with:
setSpeculativeConfigurationEnabled(true) to let Multiverse use speculative executions to figure out the best settings (readonly vs update, non readtracking vs readtracking (for blocking operations) and figure out the optimal transaction implementation based on the transaction length).
And make sure that the
setExplicitRetryAllowed(false)
If you are creating transactors because they should not block. If a user somehow does an explicit retry (needed for blocking operations), the retry is rejected and the a noretrypossibleexception is thrown.
On Thu, May 6, 2010 at 12:24 PM, Peter Vlugter wrote:
At the moment, as far as I know, there's no transaction factory or builder being used explicitly. So there's:
def atomic[T](body: => T): T = {
new TransactionTemplate[T]() {
...
which I'm assuming uses a general transaction factory from the stm?
Yes.. the transactiontemplate creates one if one is not specified. If you look at the constructors of the TransactionTemplate you will see that there also is one with the TransactionFactory. The constructor you are using is a convenience constructor.. but should not be used.
http://multiverse.codehaus.org/apidocs/org/multiverse/templates/TransactionTemplate.html
Leave a comment
on 2010-05-18 09:28 *
By Jonas Bonér
Description changed from TransactionFactoryBuilder:
... to Move the creation of the Tr...
on 2010-06-03 00:30 *
By Peter Vlugter
Assigned to set to pvlugter
Status changed from New to Accepted