maedhroz commented on code in PR #2540: URL: https://github.com/apache/cassandra/pull/2540#discussion_r1283569313
########## test/microbench/org/apache/cassandra/test/microbench/sai/SortedTermsBench.java: ########## @@ -0,0 +1,193 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.cassandra.test.microbench.sai; + +import java.nio.ByteBuffer; +import java.nio.file.Files; +import java.util.Arrays; +import java.util.concurrent.TimeUnit; + +import org.apache.cassandra.Util; +import org.apache.cassandra.config.CassandraRelevantProperties; +import org.apache.cassandra.config.DatabaseDescriptor; +import org.apache.cassandra.db.Clustering; +import org.apache.cassandra.db.DecoratedKey; +import org.apache.cassandra.db.marshal.CompositeType; +import org.apache.cassandra.db.marshal.LongType; +import org.apache.cassandra.db.marshal.UTF8Type; +import org.apache.cassandra.dht.Murmur3Partitioner; +import org.apache.cassandra.index.sai.disk.PrimaryKeyMap; +import org.apache.cassandra.index.sai.disk.format.IndexDescriptor; +import org.apache.cassandra.index.sai.disk.v1.SSTableComponentsWriter; +import org.apache.cassandra.index.sai.disk.v1.WideRowAwarePrimaryKeyMap; +import org.apache.cassandra.index.sai.utils.PrimaryKey; +import org.apache.cassandra.index.sai.utils.TypeUtil; +import org.apache.cassandra.io.sstable.Descriptor; +import org.apache.cassandra.io.sstable.format.SSTableReader; +import org.apache.cassandra.io.util.File; +import org.apache.cassandra.schema.TableMetadata; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Threads; +import org.openjdk.jmh.annotations.Warmup; + +import static org.apache.cassandra.index.sai.SAITester.getRandom; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +@BenchmarkMode({Mode.Throughput}) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Warmup(iterations = 5, time = 1) +@Measurement(iterations = 5, time = 10) +@Fork(value = 1, jvmArgsAppend = "-Xmx512M") +@Threads(1) +@State(Scope.Benchmark) +public class SortedTermsBench Review Comment: My results look something like this... ``` Benchmark (blockShift) (partitionSize) Mode Cnt Score Error Units SortedTermsBench.advanceToTerm 3 10 thrpt 5 971.451 ± 21.372 ops/ms SortedTermsBench.advanceToTerm 3 100 thrpt 5 889.358 ± 30.618 ops/ms SortedTermsBench.advanceToTerm 3 1000 thrpt 5 705.471 ± 8.090 ops/ms SortedTermsBench.advanceToTerm 3 10000 thrpt 5 710.408 ± 9.807 ops/ms SortedTermsBench.advanceToTerm 4 10 thrpt 5 975.907 ± 28.423 ops/ms SortedTermsBench.advanceToTerm 4 100 thrpt 5 916.109 ± 9.445 ops/ms SortedTermsBench.advanceToTerm 4 1000 thrpt 5 831.456 ± 3.727 ops/ms SortedTermsBench.advanceToTerm 4 10000 thrpt 5 728.207 ± 10.269 ops/ms SortedTermsBench.advanceToTerm 5 10 thrpt 5 652.437 ± 20.507 ops/ms SortedTermsBench.advanceToTerm 5 100 thrpt 5 868.473 ± 8.995 ops/ms SortedTermsBench.advanceToTerm 5 1000 thrpt 5 756.048 ± 60.404 ops/ms SortedTermsBench.advanceToTerm 5 10000 thrpt 5 786.428 ± 8.536 ops/ms SortedTermsBench.advanceToTerm 6 10 thrpt 5 675.240 ± 16.895 ops/ms SortedTermsBench.advanceToTerm 6 100 thrpt 5 631.230 ± 10.666 ops/ms SortedTermsBench.advanceToTerm 6 1000 thrpt 5 594.402 ± 4.730 ops/ms SortedTermsBench.advanceToTerm 6 10000 thrpt 5 529.220 ± 11.949 ops/ms ``` I haven't looked deeply at the methodology, but 4 seems like the clear winner? ########## test/microbench/org/apache/cassandra/test/microbench/sai/SortedTermsBench.java: ########## @@ -0,0 +1,193 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.cassandra.test.microbench.sai; + +import java.nio.ByteBuffer; +import java.nio.file.Files; +import java.util.Arrays; +import java.util.concurrent.TimeUnit; + +import org.apache.cassandra.Util; +import org.apache.cassandra.config.CassandraRelevantProperties; +import org.apache.cassandra.config.DatabaseDescriptor; +import org.apache.cassandra.db.Clustering; +import org.apache.cassandra.db.DecoratedKey; +import org.apache.cassandra.db.marshal.CompositeType; +import org.apache.cassandra.db.marshal.LongType; +import org.apache.cassandra.db.marshal.UTF8Type; +import org.apache.cassandra.dht.Murmur3Partitioner; +import org.apache.cassandra.index.sai.disk.PrimaryKeyMap; +import org.apache.cassandra.index.sai.disk.format.IndexDescriptor; +import org.apache.cassandra.index.sai.disk.v1.SSTableComponentsWriter; +import org.apache.cassandra.index.sai.disk.v1.WideRowAwarePrimaryKeyMap; +import org.apache.cassandra.index.sai.utils.PrimaryKey; +import org.apache.cassandra.index.sai.utils.TypeUtil; +import org.apache.cassandra.io.sstable.Descriptor; +import org.apache.cassandra.io.sstable.format.SSTableReader; +import org.apache.cassandra.io.util.File; +import org.apache.cassandra.schema.TableMetadata; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Threads; +import org.openjdk.jmh.annotations.Warmup; + +import static org.apache.cassandra.index.sai.SAITester.getRandom; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +@BenchmarkMode({Mode.Throughput}) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Warmup(iterations = 5, time = 1) +@Measurement(iterations = 5, time = 10) +@Fork(value = 1, jvmArgsAppend = "-Xmx512M") +@Threads(1) +@State(Scope.Benchmark) +public class SortedTermsBench Review Comment: My results look something like this... ``` Benchmark (blockShift) (partitionSize) Mode Cnt Score Error Units SortedTermsBench.advanceToTerm 3 10 thrpt 5 971.451 ± 21.372 ops/ms SortedTermsBench.advanceToTerm 3 100 thrpt 5 889.358 ± 30.618 ops/ms SortedTermsBench.advanceToTerm 3 1000 thrpt 5 705.471 ± 8.090 ops/ms SortedTermsBench.advanceToTerm 3 10000 thrpt 5 710.408 ± 9.807 ops/ms SortedTermsBench.advanceToTerm 4 10 thrpt 5 975.907 ± 28.423 ops/ms SortedTermsBench.advanceToTerm 4 100 thrpt 5 916.109 ± 9.445 ops/ms SortedTermsBench.advanceToTerm 4 1000 thrpt 5 831.456 ± 3.727 ops/ms SortedTermsBench.advanceToTerm 4 10000 thrpt 5 728.207 ± 10.269 ops/ms SortedTermsBench.advanceToTerm 5 10 thrpt 5 652.437 ± 20.507 ops/ms SortedTermsBench.advanceToTerm 5 100 thrpt 5 868.473 ± 8.995 ops/ms SortedTermsBench.advanceToTerm 5 1000 thrpt 5 756.048 ± 60.404 ops/ms SortedTermsBench.advanceToTerm 5 10000 thrpt 5 786.428 ± 8.536 ops/ms SortedTermsBench.advanceToTerm 6 10 thrpt 5 675.240 ± 16.895 ops/ms SortedTermsBench.advanceToTerm 6 100 thrpt 5 631.230 ± 10.666 ops/ms SortedTermsBench.advanceToTerm 6 1000 thrpt 5 594.402 ± 4.730 ops/ms SortedTermsBench.advanceToTerm 6 10000 thrpt 5 529.220 ± 11.949 ops/ms ``` I haven't looked deeply at the methodology, but 4 seems like the clear winner? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

