org.multiverse.stms.gamma
Class GammaStmConfig

java.lang.Object
  extended by org.multiverse.stms.gamma.GammaStmConfig

public final class GammaStmConfig
extends Object

Contains the default configuration for all transactions created by the GammaStm. With the TxnFactoryBuilder, this behavior can be overridden.

Once the GammaStm has been created, changes on this structure are ignored because the content of this configuration is copied.

Author:
Peter Veentjer.

Field Summary
 BackoffPolicy backoffPolicy
          If a transaction fails for a read/write conflict it should not hammer the system by trying again and running in the same conflict The default backoff policy helps to back threads of by sleeping/yielding.
 boolean blockingAllowed
          The default behavior if blocking transactions are allowed.
 boolean controlFlowErrorsReused
          If control flow errors should be reused.
 boolean dirtyCheck
          The default behavior for writing 'dirty' changes for an update transaction.
 boolean interruptible
          The default behavior for blocking transactions if they are allowed to be interrupted.
 boolean isFat
          Should only be used internally to select fat instead of lean transactions.
 IsolationLevel isolationLevel
          The default isolation level for all transactions executed by the GammaStm.
 int maxFixedLengthTransactionSize
          The maximum size size of a fixed length transaction.
 int maximumPoorMansConflictScanLength
          The maximum size of a transaction that is allowed to do a full conflict scan instead of arrive/depart operations.
 int maxRetries
          The default number of retries a transaction is allowed to do if a transaction fails for a read/write conflict.
 int minimalVariableLengthTransactionSize
          The minimal size for the internal array for a variable length transaction.
 List<TxnListener> permanentListeners
          Contains the permanent TxnListeners that should always be executed.
 PropagationLevel propagationLevel
          The default propagation level for all transactions executed by the Stm.
 int readBiasedThreshold
          The number of times a transactional object is only read before becoming readbiased.
 LockMode readLockMode
          The default isolation level for all reads.
 boolean readonly
          The default readonly behavior.
 boolean speculativeConfigEnabled
          The GammaStm makes use of a speculative mechanism to select the optimal transaction settings/implementation for executing a transactional closure.
 int spinCount
          The default number of spins a transaction is allowed for a read/write/commit if something is locked.
 long timeoutNs
          The default timeout for a transaction if it blocks.
 TraceLevel traceLevel
          With the trace level you have control if you get output of transactions executing.
 boolean trackReads
          If reads should be tracked by the transaction (this is something else than (semi)visible reads).
 LockMode writeLockMode
          The default isolation level for all writes.
 
Constructor Summary
GammaStmConfig()
           
 
Method Summary
 void validate()
          Checks if the configuration is valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

permanentListeners

public List<TxnListener> permanentListeners
Contains the permanent TxnListeners that should always be executed. Null references are not allowed.


propagationLevel

public PropagationLevel propagationLevel
The default propagation level for all transactions executed by the Stm.


isolationLevel

public IsolationLevel isolationLevel
The default isolation level for all transactions executed by the GammaStm.


readLockMode

public LockMode readLockMode
The default isolation level for all reads. Putting this to a level higher than LockMode.None has the same effect as putting the isolationLevel to IsolationLevel.Serialized although the former approach will be pessimistic and the later be optimistic.


writeLockMode

public LockMode writeLockMode
The default isolation level for all writes. For a write also a read is acquired, so the highest one wins.

Putting it the LockMode.Write gives the same behavior as you have with Oracle. Reads are still allowed (even though a WriteLock is allowed) only other transactions are not able to acquire a lock on it (whatever the lock should be).


blockingAllowed

public boolean blockingAllowed
The default behavior if blocking transactions are allowed.


interruptible

public boolean interruptible
The default behavior for blocking transactions if they are allowed to be interrupted.


timeoutNs

public long timeoutNs
The default timeout for a transaction if it blocks. A Long.MAX_VALUE indicates that there is no timeout.


readonly

public boolean readonly
The default readonly behavior. Setting this to true would be quite useless.


spinCount

public int spinCount
The default number of spins a transaction is allowed for a read/write/commit if something is locked.


dirtyCheck

public boolean dirtyCheck
The default behavior for writing 'dirty' changes for an update transaction. If it is set to true, a change needs to be made. If there is no change, it will not be written (and essentially be seen as a read).


minimalVariableLengthTransactionSize

public int minimalVariableLengthTransactionSize
The minimal size for the internal array for a variable length transaction. A variable length transaction internally uses an array to store its content and when the transaction grows, the array will grow accordingly.


trackReads

public boolean trackReads
If reads should be tracked by the transaction (this is something else than (semi)visible reads). The advantage of readtracking is there is less overhead once it has been read, but the disadvantage is that the transaction needs to track more changes.


maxRetries

public int maxRetries
The default number of retries a transaction is allowed to do if a transaction fails for a read/write conflict. The GammaStm also uses a speculative configuration mechanism that can consume some, so setting it to a very low value in combination with speculativeConfigEnabled is not recommended.


speculativeConfigEnabled

public boolean speculativeConfigEnabled
The GammaStm makes use of a speculative mechanism to select the optimal transaction settings/implementation for executing a transactional closure. An TxnExecutor will start cheap and grow to use more expensive transaction implementations (see the Lean/Fat transactions) and use the automatic retry mechanism of the STM to rescue itself from a situation where the speculation was incorrect. Setting it to false reduces the number of unwanted conflicts (once the TxnExecutor has learned it will not make the same mistakes again, so you only need to pay the price of speculation in the beginning) at the cost of overhead.


maxFixedLengthTransactionSize

public int maxFixedLengthTransactionSize
The maximum size size of a fixed length transaction. A fixed length transaction is very cheap compared to a variable length, but the big problem of the fixed length is that it needs to do a full transaction scan to see if the desired data is there. So there is a point where the full scan gets more expensive (O(N) vs O(log n)) expensive.

Atm there has not been put much research in finding the optimal size and it could differ from machine to machine.

It also is important that the fixed length transactions are able to put a frequently read ref in a hot spot, making the overhead of searching lower.


backoffPolicy

public BackoffPolicy backoffPolicy
If a transaction fails for a read/write conflict it should not hammer the system by trying again and running in the same conflict The default backoff policy helps to back threads of by sleeping/yielding.


traceLevel

public TraceLevel traceLevel
With the trace level you have control if you get output of transactions executing. It helps with debugging. If the org.multiverse.MultiverseConstants.___TracingEnabled is not set to true, this value is ignored and the whole profiling stuff is removed by the JIT since it effectively has become dead code.


controlFlowErrorsReused

public boolean controlFlowErrorsReused
If control flow errors should be reused. Normally exception reuse would be a very very very bad thing to do. But if they are used to regulate control flow, they can be thrown thousands of times a second and this puts a lot of pressure on the gc. The most expensive part is building the StackTrace.

For more info about the control flow errors see the subclasses of the ControlFlowError like the ReadWriteConflict, RetryError and the SpeculativeConfigurationError.


isFat

public boolean isFat
Should only be used internally to select fat instead of lean transactions. Normally the speculative configuration takes care of this but for testing purposes you want to control it manually.


maximumPoorMansConflictScanLength

public int maximumPoorMansConflictScanLength
The maximum size of a transaction that is allowed to do a full conflict scan instead of arrive/depart operations. Arrive/depart is more expensive since it increased the pressure on refs that a full conflict scan for short transactions, but at a certain length of the transaction only needing to do a full conflict scan when the global conflict counter increases, becomes cheaper.


readBiasedThreshold

public int readBiasedThreshold
The number of times a transactional object is only read before becoming readbiased. The advantage of a readBiased transactional object is that you don't need to arrive/depart (richmans conflict scan), but the disadvantage is that it could cause transactions to do full conflict scans even though they are not required.

Constructor Detail

GammaStmConfig

public GammaStmConfig()
Method Detail

validate

public void validate()
Checks if the configuration is valid.

Throws:
IllegalStateException - if the configuration isn't valid.


Copyright © 2012. All Rights Reserved.