Skip to content

Commit 29e4331

Browse files
authored
Convert benchMarkMultiTarget to a nightly test (#3633)
This test compares the time it takes to build 4 indexes individually to the time it takes to build them as multi target. For now there is no assertion that the multi target session is faster than the individuals, but it can be added in the future. Resolve #3632
1 parent 86bf52b commit 29e4331

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexerIndexFromIndexTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
*/
5959
class OnlineIndexerIndexFromIndexTest extends OnlineIndexerTest {
6060

61-
private void populateData(final long numRecords, final long numOtherRecords) {
61+
private void populateDataSimpleAndOther(final long numRecords, final long numOtherRecords) {
6262
openSimpleMetaData();
6363
List<TestRecords1Proto.MySimpleRecord> simpleRecords = LongStream.range(0, numRecords).mapToObj(val ->
6464
TestRecords1Proto.MySimpleRecord.newBuilder()
@@ -177,7 +177,7 @@ void testNonIdempotentIndexFromIndex(boolean reverseScan) {
177177
Index tgtIndex = new Index("tgt_index", field("num_value_3_indexed").ungrouped(), IndexTypes.SUM);
178178
FDBRecordStoreTestBase.RecordMetaDataHook hook = myHook(srcIndex, tgtIndex);
179179

180-
populateData(numRecords, otherRecords);
180+
populateDataSimpleAndOther(numRecords, otherRecords);
181181

182182
openSimpleMetaData(hook);
183183
buildIndexClean(srcIndex);
@@ -208,7 +208,7 @@ void testCanBuildNonIdempotentIndexFromIndexOnNewStoreWithOldFormatVersionInInde
208208
Index tgtIndex = new Index("tgt_index", field("num_value_3_indexed").ungrouped(), IndexTypes.SUM);
209209
FDBRecordStoreTestBase.RecordMetaDataHook hook = myHook(srcIndex, tgtIndex);
210210

211-
populateData(numRecords, otherRecords);
211+
populateDataSimpleAndOther(numRecords, otherRecords);
212212

213213
openSimpleMetaData(hook);
214214
buildIndexClean(srcIndex);
@@ -244,7 +244,7 @@ void testNonIdempotentIndexFromIndexOldFormatFallback(boolean reverseScan) {
244244
Index tgtIndex = new Index("tgt_index", field("num_value_3_indexed").ungrouped(), IndexTypes.SUM);
245245
FDBRecordStoreTestBase.RecordMetaDataHook hook = myHook(srcIndex, tgtIndex);
246246

247-
populateData(numRecords, otherRecords);
247+
populateDataSimpleAndOther(numRecords, otherRecords);
248248

249249
openSimpleMetaData(hook);
250250
buildIndexClean(srcIndex);
@@ -277,7 +277,7 @@ void testNonIdempotentIndexFromIndexOldFormatNoFallback() {
277277
Index tgtIndex = new Index("tgt_index", field("num_value_3_indexed").ungrouped(), IndexTypes.SUM);
278278
FDBRecordStoreTestBase.RecordMetaDataHook hook = myHook(srcIndex, tgtIndex);
279279

280-
populateData(numRecords, otherRecords);
280+
populateDataSimpleAndOther(numRecords, otherRecords);
281281

282282
openSimpleMetaData(hook);
283283
buildIndexClean(srcIndex);

fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexerMultiTargetTest.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.apple.foundationdb.record.metadata.expressions.GroupingKeyExpression;
3131
import com.apple.foundationdb.synchronizedsession.SynchronizedSessionLockedException;
3232
import com.apple.test.BooleanSource;
33+
import com.apple.test.SuperSlow;
3334
import com.apple.test.Tags;
3435
import org.junit.jupiter.api.Tag;
3536
import org.junit.jupiter.api.Test;
@@ -663,22 +664,26 @@ void testSingleTargetCompletion() {
663664
assertEquals(numRecords, timer.getCount(FDBStoreTimer.Counts.ONLINE_INDEX_BUILDER_RECORDS_INDEXED));
664665
}
665666

666-
// uncomment to compare
667-
// @Test
667+
@Test
668+
@SuperSlow
668669
void benchMarkMultiTarget() {
670+
// Expected to run in a nightly test. To run in intellij, add "-Ptests.nightly=true" to the run configuration
671+
// (As in `:fdb-record-layer-core:test --tests "com.apple.foundationdb.record.provider.foundationdb.OnlineIndexerMultiTargetTest.benchMarkMultiTarget" -Ptests.nightly=true`)
669672
// compare single target build to multi target index building
670673
final FDBStoreTimer singleTimer = new FDBStoreTimer();
671674
final FDBStoreTimer multiTimer = new FDBStoreTimer();
672-
final int numRecords = 5555;
675+
final int populateChunkSize = 5555;
676+
final int numRecords = 5 * populateChunkSize;
677+
for (int i = 0; i < 5; i++) {
678+
populateData(populateChunkSize, i * populateChunkSize);
679+
}
673680

674681
List<Index> indexes = new ArrayList<>();
675682
indexes.add(new Index("indexA", field("num_value_2"), EmptyKeyExpression.EMPTY, IndexTypes.VALUE, IndexOptions.UNIQUE_OPTIONS));
676683
indexes.add(new Index("indexB", field("num_value_3_indexed"), IndexTypes.VALUE));
677684
indexes.add(new Index("indexC", field("num_value_unique"), EmptyKeyExpression.EMPTY, IndexTypes.VALUE, IndexOptions.UNIQUE_OPTIONS));
678685
indexes.add(new Index("indexD", new GroupingKeyExpression(EmptyKeyExpression.EMPTY, 0), IndexTypes.COUNT));
679686

680-
populateData(numRecords);
681-
682687
FDBRecordStoreTestBase.RecordMetaDataHook hook = allIndexesHook(indexes);
683688

684689
long startSingle = System.currentTimeMillis();
@@ -702,6 +707,10 @@ void benchMarkMultiTarget() {
702707

703708
System.out.printf("%d indexes, %d records. Single build took %d milliSeconds, MultiIndex took %d%n",
704709
indexes.size(), numRecords, endSingle - startSingle, endMulti - startMulti);
710+
711+
// validate
712+
assertReadable(indexes);
713+
scrubAndValidate(indexes);
705714
}
706715

707716
@Test

fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexerTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,12 @@ protected void scrubAndValidate(List<Index> indexes) {
228228
}
229229

230230
protected void populateData(final long numRecords) {
231+
populateData(numRecords, 0L);
232+
}
233+
234+
protected void populateData(final long numRecords, final long start) {
231235
openSimpleMetaData();
232-
List<TestRecords1Proto.MySimpleRecord> records = LongStream.range(0, numRecords).mapToObj(val ->
236+
List<TestRecords1Proto.MySimpleRecord> records = LongStream.range(start, start + numRecords).mapToObj(val ->
233237
TestRecords1Proto.MySimpleRecord.newBuilder()
234238
.setRecNo(val)
235239
.setNumValue2((int)val * 19)

0 commit comments

Comments
 (0)