Skip to content

Commit 5745bf1

Browse files
Include microbenchmark for ES87TSDBDocValues (#92934)
Benchmarks: include microbenchmark for ES87TSDBDocValues Here we include a microbenchmark for the encoding and decoding of numeric values introduced by the new doc values format. The benchmark runs for different values of the 'bitsPerValue' parameter and exercises the encoding and encoding logic using different block of numbers including both integer and floating point values. We also rollback a few changes meant to make the doc values format work with different block sizes other than 128.
1 parent a4f6782 commit 5745bf1

24 files changed

+843
-144
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
package org.elasticsearch.benchmark.index.codec.tsdb;
10+
11+
import org.elasticsearch.benchmark.index.codec.tsdb.internal.AbstractDocValuesForUtilBenchmark;
12+
import org.elasticsearch.benchmark.index.codec.tsdb.internal.ConstantIntegerSupplier;
13+
import org.elasticsearch.benchmark.index.codec.tsdb.internal.DecodeBenchmark;
14+
import org.openjdk.jmh.annotations.Benchmark;
15+
import org.openjdk.jmh.annotations.BenchmarkMode;
16+
import org.openjdk.jmh.annotations.Fork;
17+
import org.openjdk.jmh.annotations.Level;
18+
import org.openjdk.jmh.annotations.Measurement;
19+
import org.openjdk.jmh.annotations.Mode;
20+
import org.openjdk.jmh.annotations.OutputTimeUnit;
21+
import org.openjdk.jmh.annotations.Param;
22+
import org.openjdk.jmh.annotations.Scope;
23+
import org.openjdk.jmh.annotations.Setup;
24+
import org.openjdk.jmh.annotations.State;
25+
import org.openjdk.jmh.annotations.Warmup;
26+
import org.openjdk.jmh.infra.Blackhole;
27+
28+
import java.io.IOException;
29+
import java.util.concurrent.TimeUnit;
30+
31+
@Fork(value = 1)
32+
@Warmup(iterations = 3)
33+
@Measurement(iterations = 10)
34+
@BenchmarkMode(value = Mode.AverageTime)
35+
@OutputTimeUnit(value = TimeUnit.NANOSECONDS)
36+
@State(value = Scope.Benchmark)
37+
public class DecodeConstantIntegerBenchmark {
38+
private static final int SEED = 17;
39+
private static final int BLOCK_SIZE = 128;
40+
@Param({ "15" })
41+
private int bitsPerValue;
42+
43+
private final AbstractDocValuesForUtilBenchmark decode;
44+
45+
public DecodeConstantIntegerBenchmark() {
46+
this.decode = new DecodeBenchmark();
47+
}
48+
49+
@Setup(Level.Invocation)
50+
public void setupInvocation() throws IOException {
51+
decode.setupInvocation(bitsPerValue);
52+
}
53+
54+
@Setup(Level.Iteration)
55+
public void setupIteration() throws IOException {
56+
decode.setupIteration(bitsPerValue, new ConstantIntegerSupplier(SEED, bitsPerValue, BLOCK_SIZE));
57+
}
58+
59+
@Benchmark
60+
public void benchmark(Blackhole bh) throws IOException {
61+
decode.benchmark(bitsPerValue, bh);
62+
}
63+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
package org.elasticsearch.benchmark.index.codec.tsdb;
10+
11+
import org.elasticsearch.benchmark.index.codec.tsdb.internal.AbstractDocValuesForUtilBenchmark;
12+
import org.elasticsearch.benchmark.index.codec.tsdb.internal.DecodeBenchmark;
13+
import org.elasticsearch.benchmark.index.codec.tsdb.internal.DecreasingIntegerSupplier;
14+
import org.openjdk.jmh.annotations.Benchmark;
15+
import org.openjdk.jmh.annotations.BenchmarkMode;
16+
import org.openjdk.jmh.annotations.Fork;
17+
import org.openjdk.jmh.annotations.Level;
18+
import org.openjdk.jmh.annotations.Measurement;
19+
import org.openjdk.jmh.annotations.Mode;
20+
import org.openjdk.jmh.annotations.OutputTimeUnit;
21+
import org.openjdk.jmh.annotations.Param;
22+
import org.openjdk.jmh.annotations.Scope;
23+
import org.openjdk.jmh.annotations.Setup;
24+
import org.openjdk.jmh.annotations.State;
25+
import org.openjdk.jmh.annotations.Warmup;
26+
import org.openjdk.jmh.infra.Blackhole;
27+
28+
import java.io.IOException;
29+
import java.util.concurrent.TimeUnit;
30+
31+
@Fork(value = 1)
32+
@Warmup(iterations = 3)
33+
@Measurement(iterations = 10)
34+
@BenchmarkMode(value = Mode.AverageTime)
35+
@OutputTimeUnit(value = TimeUnit.NANOSECONDS)
36+
@State(value = Scope.Benchmark)
37+
public class DecodeDecreasingIntegerBenchmark {
38+
private static final int SEED = 17;
39+
private static final int BLOCK_SIZE = 128;
40+
@Param({ "4", "8", "12", "16", "24", "28", "32", "36", "40", "44", "48", "52", "56", "64" })
41+
private int bitsPerValue;
42+
43+
private final AbstractDocValuesForUtilBenchmark decode;
44+
45+
public DecodeDecreasingIntegerBenchmark() {
46+
this.decode = new DecodeBenchmark();
47+
}
48+
49+
@Setup(Level.Invocation)
50+
public void setupInvocation() throws IOException {
51+
decode.setupInvocation(bitsPerValue);
52+
}
53+
54+
@Setup(Level.Iteration)
55+
public void setupIteration() throws IOException {
56+
decode.setupIteration(bitsPerValue, new DecreasingIntegerSupplier(SEED, bitsPerValue, BLOCK_SIZE));
57+
}
58+
59+
@Benchmark
60+
public void benchmark(Blackhole bh) throws IOException {
61+
decode.benchmark(bitsPerValue, bh);
62+
}
63+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
package org.elasticsearch.benchmark.index.codec.tsdb;
10+
11+
import org.elasticsearch.benchmark.index.codec.tsdb.internal.AbstractDocValuesForUtilBenchmark;
12+
import org.elasticsearch.benchmark.index.codec.tsdb.internal.DecodeBenchmark;
13+
import org.elasticsearch.benchmark.index.codec.tsdb.internal.IncreasingIntegerSupplier;
14+
import org.openjdk.jmh.annotations.Benchmark;
15+
import org.openjdk.jmh.annotations.BenchmarkMode;
16+
import org.openjdk.jmh.annotations.Fork;
17+
import org.openjdk.jmh.annotations.Level;
18+
import org.openjdk.jmh.annotations.Measurement;
19+
import org.openjdk.jmh.annotations.Mode;
20+
import org.openjdk.jmh.annotations.OutputTimeUnit;
21+
import org.openjdk.jmh.annotations.Param;
22+
import org.openjdk.jmh.annotations.Scope;
23+
import org.openjdk.jmh.annotations.Setup;
24+
import org.openjdk.jmh.annotations.State;
25+
import org.openjdk.jmh.annotations.Warmup;
26+
import org.openjdk.jmh.infra.Blackhole;
27+
28+
import java.io.IOException;
29+
import java.util.concurrent.TimeUnit;
30+
31+
@Fork(value = 1)
32+
@Warmup(iterations = 3)
33+
@Measurement(iterations = 10)
34+
@BenchmarkMode(value = Mode.AverageTime)
35+
@OutputTimeUnit(value = TimeUnit.NANOSECONDS)
36+
@State(value = Scope.Benchmark)
37+
public class DecodeIncreasingIntegerBenchmark {
38+
private static final int SEED = 17;
39+
private static final int BLOCK_SIZE = 128;
40+
@Param({ "4", "8", "12", "16", "24", "28", "32", "36", "40", "44", "48", "52", "56", "64" })
41+
private int bitsPerValue;
42+
43+
private final AbstractDocValuesForUtilBenchmark decode;
44+
45+
public DecodeIncreasingIntegerBenchmark() {
46+
this.decode = new DecodeBenchmark();
47+
48+
}
49+
50+
@Setup(Level.Invocation)
51+
public void setupInvocation() throws IOException {
52+
decode.setupInvocation(bitsPerValue);
53+
}
54+
55+
@Setup(Level.Iteration)
56+
public void setupIteration() throws IOException {
57+
decode.setupIteration(bitsPerValue, new IncreasingIntegerSupplier(SEED, bitsPerValue, BLOCK_SIZE));
58+
}
59+
60+
@Benchmark
61+
public void benchmark(Blackhole bh) throws IOException {
62+
decode.benchmark(bitsPerValue, bh);
63+
64+
}
65+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
package org.elasticsearch.benchmark.index.codec.tsdb;
10+
11+
import org.elasticsearch.benchmark.index.codec.tsdb.internal.AbstractDocValuesForUtilBenchmark;
12+
import org.elasticsearch.benchmark.index.codec.tsdb.internal.DecodeBenchmark;
13+
import org.elasticsearch.benchmark.index.codec.tsdb.internal.NonSortedIntegerSupplier;
14+
import org.openjdk.jmh.annotations.Benchmark;
15+
import org.openjdk.jmh.annotations.BenchmarkMode;
16+
import org.openjdk.jmh.annotations.Fork;
17+
import org.openjdk.jmh.annotations.Level;
18+
import org.openjdk.jmh.annotations.Measurement;
19+
import org.openjdk.jmh.annotations.Mode;
20+
import org.openjdk.jmh.annotations.OutputTimeUnit;
21+
import org.openjdk.jmh.annotations.Param;
22+
import org.openjdk.jmh.annotations.Scope;
23+
import org.openjdk.jmh.annotations.Setup;
24+
import org.openjdk.jmh.annotations.State;
25+
import org.openjdk.jmh.annotations.Warmup;
26+
import org.openjdk.jmh.infra.Blackhole;
27+
28+
import java.io.IOException;
29+
import java.util.concurrent.TimeUnit;
30+
31+
@Fork(value = 1)
32+
@Warmup(iterations = 3)
33+
@Measurement(iterations = 10)
34+
@BenchmarkMode(value = Mode.AverageTime)
35+
@OutputTimeUnit(value = TimeUnit.NANOSECONDS)
36+
@State(value = Scope.Benchmark)
37+
public class DecodeNonSortedIntegerBenchmark {
38+
private static final int SEED = 17;
39+
private static final int BLOCK_SIZE = 128;
40+
@Param({ "4", "8", "12", "16", "24", "28", "32", "36", "40", "44", "48", "52", "56", "64" })
41+
private int bitsPerValue;
42+
43+
private final AbstractDocValuesForUtilBenchmark decode;
44+
45+
public DecodeNonSortedIntegerBenchmark() {
46+
this.decode = new DecodeBenchmark();
47+
48+
}
49+
50+
@Setup(Level.Invocation)
51+
public void setupInvocation() throws IOException {
52+
decode.setupInvocation(bitsPerValue);
53+
}
54+
55+
@Setup(Level.Iteration)
56+
public void setupIteration() throws IOException {
57+
decode.setupIteration(bitsPerValue, new NonSortedIntegerSupplier(SEED, bitsPerValue, BLOCK_SIZE));
58+
}
59+
60+
@Benchmark
61+
public void benchmark(Blackhole bh) throws IOException {
62+
decode.benchmark(bitsPerValue, bh);
63+
}
64+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
package org.elasticsearch.benchmark.index.codec.tsdb;
10+
11+
import org.elasticsearch.benchmark.index.codec.tsdb.internal.AbstractDocValuesForUtilBenchmark;
12+
import org.elasticsearch.benchmark.index.codec.tsdb.internal.ConstantIntegerSupplier;
13+
import org.elasticsearch.benchmark.index.codec.tsdb.internal.EncodeBenchmark;
14+
import org.openjdk.jmh.annotations.Benchmark;
15+
import org.openjdk.jmh.annotations.BenchmarkMode;
16+
import org.openjdk.jmh.annotations.Fork;
17+
import org.openjdk.jmh.annotations.Level;
18+
import org.openjdk.jmh.annotations.Measurement;
19+
import org.openjdk.jmh.annotations.Mode;
20+
import org.openjdk.jmh.annotations.OutputTimeUnit;
21+
import org.openjdk.jmh.annotations.Param;
22+
import org.openjdk.jmh.annotations.Scope;
23+
import org.openjdk.jmh.annotations.Setup;
24+
import org.openjdk.jmh.annotations.State;
25+
import org.openjdk.jmh.annotations.Warmup;
26+
import org.openjdk.jmh.infra.Blackhole;
27+
28+
import java.io.IOException;
29+
import java.util.concurrent.TimeUnit;
30+
31+
@Fork(value = 1)
32+
@Warmup(iterations = 3)
33+
@Measurement(iterations = 10)
34+
@BenchmarkMode(value = Mode.AverageTime)
35+
@OutputTimeUnit(value = TimeUnit.NANOSECONDS)
36+
@State(value = Scope.Benchmark)
37+
public class EncodeConstantIntegerBenchmark {
38+
private static final int SEED = 17;
39+
private static final int BLOCK_SIZE = 128;
40+
@Param({ "15" })
41+
private int bitsPerValue;
42+
43+
private final AbstractDocValuesForUtilBenchmark encode;
44+
45+
public EncodeConstantIntegerBenchmark() {
46+
this.encode = new EncodeBenchmark();
47+
48+
}
49+
50+
@Setup(Level.Invocation)
51+
public void setupInvocation() throws IOException {
52+
encode.setupInvocation(bitsPerValue);
53+
}
54+
55+
@Setup(Level.Iteration)
56+
public void setupIteration() throws IOException {
57+
encode.setupIteration(bitsPerValue, new ConstantIntegerSupplier(SEED, bitsPerValue, BLOCK_SIZE));
58+
}
59+
60+
@Benchmark
61+
public void benchmark(Blackhole bh) throws IOException {
62+
encode.benchmark(bitsPerValue, bh);
63+
}
64+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
package org.elasticsearch.benchmark.index.codec.tsdb;
10+
11+
import org.elasticsearch.benchmark.index.codec.tsdb.internal.AbstractDocValuesForUtilBenchmark;
12+
import org.elasticsearch.benchmark.index.codec.tsdb.internal.DecreasingIntegerSupplier;
13+
import org.elasticsearch.benchmark.index.codec.tsdb.internal.EncodeBenchmark;
14+
import org.openjdk.jmh.annotations.Benchmark;
15+
import org.openjdk.jmh.annotations.BenchmarkMode;
16+
import org.openjdk.jmh.annotations.Fork;
17+
import org.openjdk.jmh.annotations.Level;
18+
import org.openjdk.jmh.annotations.Measurement;
19+
import org.openjdk.jmh.annotations.Mode;
20+
import org.openjdk.jmh.annotations.OutputTimeUnit;
21+
import org.openjdk.jmh.annotations.Param;
22+
import org.openjdk.jmh.annotations.Scope;
23+
import org.openjdk.jmh.annotations.Setup;
24+
import org.openjdk.jmh.annotations.State;
25+
import org.openjdk.jmh.annotations.Warmup;
26+
import org.openjdk.jmh.infra.Blackhole;
27+
28+
import java.io.IOException;
29+
import java.util.concurrent.TimeUnit;
30+
31+
@Fork(value = 1)
32+
@Warmup(iterations = 3)
33+
@Measurement(iterations = 10)
34+
@BenchmarkMode(value = Mode.AverageTime)
35+
@OutputTimeUnit(value = TimeUnit.NANOSECONDS)
36+
@State(value = Scope.Benchmark)
37+
public class EncodeDecreasingIntegerBenchmark {
38+
private static final int SEED = 17;
39+
private static final int BLOCK_SIZE = 128;
40+
@Param({ "4", "8", "12", "16", "24", "28", "32", "36", "40", "44", "48", "52", "56", "64" })
41+
private int bitsPerValue;
42+
43+
private final AbstractDocValuesForUtilBenchmark encode;
44+
45+
public EncodeDecreasingIntegerBenchmark() {
46+
this.encode = new EncodeBenchmark();
47+
}
48+
49+
@Setup(Level.Invocation)
50+
public void setupInvocation() throws IOException {
51+
encode.setupInvocation(bitsPerValue);
52+
}
53+
54+
@Setup(Level.Iteration)
55+
public void setupIteration() throws IOException {
56+
encode.setupIteration(bitsPerValue, new DecreasingIntegerSupplier(SEED, bitsPerValue, BLOCK_SIZE));
57+
}
58+
59+
@Benchmark
60+
public void benchmark(Blackhole bh) throws IOException {
61+
encode.benchmark(bitsPerValue, bh);
62+
}
63+
}

0 commit comments

Comments
 (0)