Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/main/java/com/backblaze/erasure/CodingLoop.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ public interface CodingLoop {
new OutputInputByteTableCodingLoop(),
};

/**
* The best implementation as determined by {@link ReedSolomonBenchmark} over
* {@link #ALL_CODING_LOOPS}.
*/
CodingLoop BEST_CODING_LOOP = new InputOutputByteTableCodingLoop();

/**
* Multiplies a subset of rows from a coding matrix by a full set of
* input shards to produce some output shards.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/backblaze/erasure/ReedSolomon.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class ReedSolomon {
* Creates a ReedSolomon codec with the default coding loop.
*/
public static ReedSolomon create(int dataShardCount, int parityShardCount) {
return new ReedSolomon(dataShardCount, parityShardCount, new InputOutputByteTableCodingLoop());
return new ReedSolomon(dataShardCount, parityShardCount, CodingLoop.BEST_CODING_LOOP);
}

/**
Expand Down
14 changes: 11 additions & 3 deletions src/main/java/com/backblaze/erasure/ReedSolomonBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ public class ReedSolomonBenchmark {

private static final long MEASUREMENT_DURATION = 2 * 1000;

private static final CodingLoop[] CODING_LOOPS = CodingLoop.ALL_CODING_LOOPS;
// alternatively, just benchmark the most-performant CodingLoop
// private static final CodingLoop[] CODING_LOOPS = new CodingLoop[] {CodingLoop.BEST_CODING_LOOP};

private static final int BANDWIDTH_COUNT = DATA_COUNT;
// alternatively, add parity shards for the bandwidth calculation, to compare with other implementations
// private static final int BANDWIDTH_COUNT = TOTAL_COUNT;

private static final Random random = new Random();

private int nextBuffer = 0;
Expand All @@ -52,7 +60,7 @@ public void run() {
List<String> summaryLines = new ArrayList<String>();
StringBuilder csv = new StringBuilder();
csv.append("Outer,Middle,Inner,Multiply,Encode,Check\n");
for (CodingLoop codingLoop : CodingLoop.ALL_CODING_LOOPS) {
for (CodingLoop codingLoop : CODING_LOOPS) {
Measurement encodeAverage = new Measurement();
{
final String testName = codingLoop.getClass().getSimpleName() + " encodeParity";
Expand Down Expand Up @@ -113,7 +121,7 @@ private Measurement doOneEncodeMeasurement(ReedSolomon codec, BufferSet[] buffer
codec.encodeParity(shards, 0, BUFFER_SIZE);
long endTime = System.currentTimeMillis();
encodingTime += (endTime - startTime);
bytesEncoded += BUFFER_SIZE * DATA_COUNT;
bytesEncoded += BUFFER_SIZE * BANDWIDTH_COUNT;
passesCompleted += 1;
}
double seconds = ((double)encodingTime) / 1000.0;
Expand All @@ -139,7 +147,7 @@ private Measurement doOneCheckMeasurement(ReedSolomon codec, BufferSet[] bufferS
}
long endTime = System.currentTimeMillis();
checkingTime += (endTime - startTime);
bytesChecked += BUFFER_SIZE * DATA_COUNT;
bytesChecked += BUFFER_SIZE * BANDWIDTH_COUNT;
passesCompleted += 1;
}
double seconds = ((double)checkingTime) / 1000.0;
Expand Down