The software design is described on the main page.
The workloads are in the folder ./src/contention/benchmark/workload/.
Each entity's folder has the following structure:
./src/contention/benchmark/workload/<entity>/
├── abstracrion
├── builders
└── implsThe <entity>.java file contains the interface that needs to be implemented,
<entity>_builder.java — the interface of entity builder.
The builders and impls folders contain the corresponding implementations.
The key entities are:
- Distribution — a distribution of a random variable;
- DataMap — converts a distribution's output into a key;
- ArgsGenerator — creates operands for an operation;
- ThreadLoop — the logic for interacting with a data structure;
There are builders each type of entity: ThreadLoopBuilder, ArgsGeneratorBuilder, DistributionBuilder, DataMapBuilder.
There is also a StopCondition – a condition in which the load stops working.
The first part is the implementation of an Entity:
public class ExampleEntity implements Entity {
/*EntityFields*/
public ExampleEntity(/*entityParameters*/) {...}
/*overriding entity functions*/
}The second part is the implementation of an EntityBuilder:
public class ExampleEntityBuilder implements EntityBuilder {
/*rawParameters*/
/*transient finalParameters*/
public ExampleEntityBuilder() {...}
/*overriding entity functions*/
@Override
public ExampleEntityBuilder init(/*initParameters*/) {
/*initializing final parameters by processing raw parameters*/
}
/**
* called only after the init function
*/
@Override
public ExampleEntity build() {
/*creating the new instance of ExampleEntity*/
}
@Override
public StringBuilder toStringBuilder(int indents) {
/*converting the class to string format for writing to the console*/
}
}To convert to json format, the Gson implementation is used. Conversion occurs through the JsonConvector class.
Sign parameters that should not be converted to json format using the transient modifier.
For convenient conversion to a string representation, use the
indentedTitle, indentedTitleWithData and indentedTitleWithDataPercent functions
from StringFormat.
In contrast to other entities, StopCondition does not have builders, so it is converted to json format on its own
and initialization occurs during the call to the start(numThreads) function.
The ArrayDataMap creates an array filled with values from the entire range of keys and shuffles them randomly.
When calling the get(index) method, returns the corresponding element from the array.
The implementation
and builder of ArrayDataMap.
The SkewedUniformDistribution depends on two variables hotSize and hotRatio, which take values from 0 to 1.
The range is divided into two interval:
the random variable returns from first interval with hotRatio probability and from second with 1 - hotRatio;
the size of first interval is range * hotSize, the size of second if range * (1 - hotSize).
The random variable in intervals chooses uniformly.
The implementation
and builder of SkewedUniformDistribution.
The SkewedSetsArgsGenerator uses two SkewedUniformDistributions separately for read and update operations,
and takes the following parameters:
rp%of read operations are performed on a random subset of keys of proportionrs%where a key is taken uniformly. All other read operations are performed on the rest of the set.wp%of update operations are performed on a random subset of keys of proportionws%where a key is taken uniformly. All other update operations are performed on the rest of the set.inter%of keys are in the intersection of the working sets of read and update operations.
The implementation
and builder of SkewedSetsArgsGenerator.
The DefaultThreadLoop selects the next operation with some fixed probability. It accepts the following parameters:
ui%of operations are insert operations;ue%of operations are remove operations;- while
100 - ui - ue%of operations are get operations.
The implementation
and builder of DefaultThreadLoop.
The Timer accepts a workTime parameter in milliseconds, and the isStopped method returns true during that time.
The implementation are presented in Timer file