Skip to content

Commit 1f078c0

Browse files
committed
Reduce time to execute microbench-test
Set 1 thread and 1 second for the measurement iteration (note: it is a smoke test only, we do not analyze results from such short measurements) Exclude some options for heavy benchmarks by default Shutdown all threads once JMH test is completed to avoid awaiting of a forked JVM till timeout at the end patch by Dmitry Konstantinov; reviewed by Michael Semb Wever for CASSANDRA-21388
1 parent d1b76b6 commit 1f078c0

9 files changed

Lines changed: 43 additions & 23 deletions

.build/build-bench.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@
4949
<!-- Only used to test jmh classes run without error. Not to be used for actual performance tests -->
5050
<jmh>
5151
<extra-args>
52-
<arg value="-f"/><arg value="1"/>
53-
<arg value="-wi"/><arg value="0"/>
54-
<arg value="-i"/><arg value="1"/>
52+
<arg value="-f"/><arg value="1"/> <!-- forks -->
53+
<arg value="-wi"/><arg value="0"/> <!-- warmup iterations -->
54+
<arg value="-i"/><arg value="1"/> <!-- fork -->
55+
<arg value="-r"/><arg value="1"/> <!-- measurement iteration time -->
56+
<arg value="-t"/><arg value="1"/> <!-- threads -->
5557
</extra-args>
5658
</jmh>
5759
</target>

test/microbench/org/apache/cassandra/test/microbench/BatchStatementBench.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@
2626
import org.openjdk.jmh.annotations.Benchmark;
2727
import org.openjdk.jmh.annotations.BenchmarkMode;
2828
import org.openjdk.jmh.annotations.Fork;
29+
import org.openjdk.jmh.annotations.Level;
2930
import org.openjdk.jmh.annotations.Measurement;
3031
import org.openjdk.jmh.annotations.Mode;
3132
import org.openjdk.jmh.annotations.OutputTimeUnit;
3233
import org.openjdk.jmh.annotations.Param;
3334
import org.openjdk.jmh.annotations.Scope;
3435
import org.openjdk.jmh.annotations.Setup;
3536
import org.openjdk.jmh.annotations.State;
37+
import org.openjdk.jmh.annotations.TearDown;
3638
import org.openjdk.jmh.annotations.Threads;
3739
import org.openjdk.jmh.annotations.Warmup;
3840
import org.openjdk.jmh.profile.GCProfiler;
@@ -63,6 +65,7 @@
6365
import org.apache.cassandra.transport.Dispatcher;
6466
import org.apache.cassandra.utils.ByteArrayUtil;
6567
import org.apache.cassandra.utils.FBUtilities;
68+
import org.apache.cassandra.utils.TestHelper;
6669

6770
@BenchmarkMode(Mode.Throughput)
6871
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@@ -120,6 +123,12 @@ public void setup() throws Throwable
120123
bqo = BatchQueryOptions.withPerStatementVariables(QueryOptions.DEFAULT, parameters, queryOrIdList);
121124
}
122125

126+
@TearDown(Level.Trial)
127+
public void teardown() throws Exception
128+
{
129+
TestHelper.teardown();
130+
}
131+
123132
@Benchmark
124133
public void bench()
125134
{

test/microbench/org/apache/cassandra/test/microbench/CIDRAuthorizerBench.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.util.List;
2929
import java.util.Map;
3030
import java.util.Random;
31-
import java.util.concurrent.ExecutionException;
3231
import java.util.concurrent.TimeUnit;
3332

3433
import org.openjdk.jmh.annotations.Benchmark;
@@ -50,6 +49,7 @@
5049
import org.apache.cassandra.cql3.CIDR;
5150
import org.apache.cassandra.cql3.CQLTester;
5251
import org.apache.cassandra.exceptions.UnauthorizedException;
52+
import org.apache.cassandra.utils.TestHelper;
5353

5454
/**
5555
* Benchmark CIDR authorizer (enforce mode)
@@ -99,9 +99,9 @@ public void setup() throws IOException
9999
}
100100

101101
@TearDown(Level.Trial)
102-
public void teardown() throws IOException, ExecutionException, InterruptedException
102+
public void teardown() throws Exception
103103
{
104-
CQLTester.cleanup();
104+
TestHelper.teardown();
105105
}
106106

107107
@State(Scope.Thread)

test/microbench/org/apache/cassandra/test/microbench/CacheLoaderBench.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,17 @@
4646
import org.apache.cassandra.config.Config;
4747
import org.apache.cassandra.config.DataStorageSpec;
4848
import org.apache.cassandra.config.DatabaseDescriptor;
49-
import org.apache.cassandra.cql3.CQLTester;
5049
import org.apache.cassandra.cql3.QueryProcessor;
5150
import org.apache.cassandra.db.ColumnFamilyStore;
5251
import org.apache.cassandra.db.Keyspace;
5352
import org.apache.cassandra.db.RowUpdateBuilder;
54-
import org.apache.cassandra.db.commitlog.CommitLog;
5553
import org.apache.cassandra.db.marshal.AsciiType;
5654
import org.apache.cassandra.io.sstable.AbstractRowIndexEntry;
5755
import org.apache.cassandra.io.sstable.format.SSTableReader;
5856
import org.apache.cassandra.schema.ColumnMetadata;
5957
import org.apache.cassandra.service.CacheService;
6058
import org.apache.cassandra.utils.ByteBufferUtil;
59+
import org.apache.cassandra.utils.TestHelper;
6160

6261
@SuppressWarnings("unused")
6362
@BenchmarkMode(Mode.SampleTime)
@@ -151,11 +150,9 @@ public void setupKeyCache()
151150
}
152151

153152
@TearDown(Level.Trial)
154-
public void teardown()
153+
public void teardown() throws Exception
155154
{
156-
CQLTester.tearDownClass();
157-
CommitLog.instance.stopUnsafe(true);
158-
CQLTester.cleanup();
155+
TestHelper.teardown();
159156
}
160157

161158
@Benchmark

test/microbench/org/apache/cassandra/test/microbench/FunctionWithTerminalArgsBench.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import org.apache.cassandra.cql3.UntypedResultSet;
4242
import org.apache.cassandra.db.ColumnFamilyStore;
4343
import org.apache.cassandra.db.Keyspace;
44-
import org.apache.cassandra.db.commitlog.CommitLog;
44+
import org.apache.cassandra.utils.TestHelper;
4545

4646
/**
4747
* Benchmarks the performance of CQL functions calls with terminal arguments.
@@ -101,11 +101,9 @@ public void setup() throws Throwable
101101
}
102102

103103
@TearDown(Level.Trial)
104-
public void teardown() throws InterruptedException
104+
public void teardown() throws Exception
105105
{
106-
CommitLog.instance.shutdownBlocking();
107-
CQLTester.tearDownClass();
108-
CQLTester.cleanup();
106+
TestHelper.teardown();
109107
}
110108

111109
@Benchmark

test/microbench/org/apache/cassandra/test/microbench/MetadataCollectorBench.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@
2727
import org.openjdk.jmh.annotations.Benchmark;
2828
import org.openjdk.jmh.annotations.BenchmarkMode;
2929
import org.openjdk.jmh.annotations.Fork;
30+
import org.openjdk.jmh.annotations.Level;
3031
import org.openjdk.jmh.annotations.Measurement;
3132
import org.openjdk.jmh.annotations.Mode;
3233
import org.openjdk.jmh.annotations.OutputTimeUnit;
3334
import org.openjdk.jmh.annotations.Param;
3435
import org.openjdk.jmh.annotations.Scope;
3536
import org.openjdk.jmh.annotations.Setup;
3637
import org.openjdk.jmh.annotations.State;
38+
import org.openjdk.jmh.annotations.TearDown;
3739
import org.openjdk.jmh.annotations.Warmup;
3840

3941
import org.apache.cassandra.cql3.CQLTester;
@@ -47,6 +49,7 @@
4749
import org.apache.cassandra.io.sstable.metadata.MetadataCollector;
4850
import org.apache.cassandra.schema.ColumnMetadata;
4951
import org.apache.cassandra.schema.TableMetadata;
52+
import org.apache.cassandra.utils.TestHelper;
5053

5154
@BenchmarkMode(Mode.AverageTime)
5255
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@@ -122,6 +125,12 @@ public void setup()
122125
}
123126
}
124127

128+
@TearDown(Level.Trial)
129+
public void teardown() throws Exception
130+
{
131+
TestHelper.teardown();
132+
}
133+
125134
@Benchmark
126135
public void updateCell()
127136
{

test/microbench/org/apache/cassandra/test/microbench/ZstdDictionaryCompressorBenchBase.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import org.apache.cassandra.db.compression.ZstdCompressionDictionary;
4040
import org.apache.cassandra.io.compress.ZstdDictionaryCompressor;
4141

42-
// The bench takes over 20 minutes to finish
42+
// The full bench takes over 20 minutes to finish
4343
@State(Scope.Benchmark)
4444
public abstract class ZstdDictionaryCompressorBenchBase
4545
{
@@ -52,7 +52,8 @@ public abstract class ZstdDictionaryCompressorBenchBase
5252
@Param({"0", "65536"})
5353
protected int dictionarySize;
5454

55-
@Param({"3", "5", "7"})
55+
// @Param({"3", "5", "7"})
56+
@Param({"3"})
5657
protected int compressionLevel;
5758

5859
protected byte[] inputData;

test/microbench/org/apache/cassandra/test/microbench/tries/ComparisonReadBench.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ public class ComparisonReadBench
7777
@Param({"ON_HEAP"})
7878
BufferType bufferType = BufferType.OFF_HEAP;
7979

80-
@Param({"1000", "100000", "10000000"})
80+
// @Param({"1000", "100000", "10000000"})
81+
@Param({"1000", "100000"})
8182
int count = 1000;
8283

83-
@Param({"TREE_MAP", "CSLM", "TRIE"})
84+
// @Param({"TREE_MAP", "CSLM", "TRIE"})
85+
@Param({"CSLM", "TRIE"})
8486
MapOption map = MapOption.TRIE;
8587

8688
@Param({"LONG"})

test/microbench/org/apache/cassandra/test/microbench/tries/InMemoryTrieUnionBench.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ public class InMemoryTrieUnionBench
5656
@Param({"ON_HEAP", "OFF_HEAP"})
5757
BufferType bufferType = BufferType.OFF_HEAP;
5858

59-
@Param({"1000", "100000", "10000000"})
59+
// @Param({"1000", "100000", "10000000"})
60+
@Param({"1000", "100000"})
6061
int count = 1000;
6162

62-
@Param({"2", "3", "8"})
63+
// @Param({"2", "3", "8"})
64+
@Param({"2", "3"})
6365
int sources = 2;
6466

6567
@Param({"false", "true"})

0 commit comments

Comments
 (0)