Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
119f582
Add ES94 TSDB doc values format with pipeline-based numeric encoding
salvatore-campagna Jan 27, 2026
ced58db
fix(tsdb): pad zstd blocks
salvatore-campagna Jan 27, 2026
6408782
fix(tsdb): skip patched-pfor on signed values
salvatore-campagna Jan 27, 2026
208c55d
fix(tsdb): reuse numeric decoder in ES94 producer
salvatore-campagna Jan 27, 2026
fcd5670
test(tsdb): add skip assertions for delta/offset/gcd
salvatore-campagna Jan 27, 2026
9bdb8ec
[CI] Auto commit changes from spotless
Jan 27, 2026
ae6f1dd
chore(tsdb): normalize pipeline javadoc
salvatore-campagna Jan 27, 2026
15ac4b8
Merge branch 'feature/tsdb-pipeline-poc' of github.com:salvatore-camp…
salvatore-campagna Jan 27, 2026
86748f2
chore(tsdb): normalize benchmark javadoc
salvatore-campagna Jan 27, 2026
5429f68
Merge branch 'main' into feature/tsdb-pipeline-poc
salvatore-campagna Feb 5, 2026
5416d16
feat(tsdb): add float/date stages, fused quantization, and pipeline i…
salvatore-campagna Feb 11, 2026
a7296a0
Merge branch 'main' into feature/tsdb-pipeline-poc
salvatore-campagna Feb 11, 2026
6346d4e
fix(tsdb): replace forbidden Math.abs(int) with direct comparison in …
salvatore-campagna Feb 11, 2026
fc7d650
fix(tsdb): fix checkstyle violations and NumberFieldType constructor …
salvatore-campagna Feb 11, 2026
4c7cccc
refactor(tsdb): use thread-local buffers for Zstd stages and remove r…
salvatore-campagna Feb 11, 2026
31f66ce
feat(tsdb): add LZ4 payload stage with fast and high compression modes
salvatore-campagna Feb 11, 2026
8239fc2
fix(tsdb): use lazy-sized thread-local buffers for Zstd and LZ4 stages
salvatore-campagna Feb 11, 2026
233b294
refactor(tsdb): remove Closeable from pipeline codec types
salvatore-campagna Feb 11, 2026
82453fe
fix(tsdb): store FPC selector bits instead of full predictions in met…
salvatore-campagna Feb 12, 2026
3fe6bd1
feat(tsdb): add GCD to timestamp pipeline and scale PatchedPFor excep…
salvatore-campagna Feb 12, 2026
f586666
chore(tsdb): remove bench test utilities from tracked files
salvatore-campagna Feb 12, 2026
8fdb709
[CI] Auto commit changes from spotless
Feb 12, 2026
c59a062
fix(tsdb): restore NumericDataGenerators and init logging for benchmarks
salvatore-campagna Feb 12, 2026
5811547
fix: use default pipeline for timestamp field
salvatore-campagna Feb 12, 2026
346dd5c
Merge branch 'main' into feature/tsdb-pipeline-poc
salvatore-campagna Feb 12, 2026
20fde7d
Merge branch 'main' into feature/tsdb-pipeline-poc
salvatore-campagna Feb 12, 2026
2e901ce
optimize for balanced
salvatore-campagna Feb 13, 2026
aeb8035
feat(tsdb): use FPC for double gauges, float gauges, and double counters
salvatore-campagna Feb 13, 2026
d6f1e5f
feat(tsdb): use ALP for gauges and FPC for counters
salvatore-campagna Feb 14, 2026
f3ba092
feat(tsdb): refactor pipeline resolver and set otel template to storage
salvatore-campagna Feb 14, 2026
c71b061
chore: remove command.sh from benchmarks
salvatore-campagna Feb 15, 2026
d97c19f
feat(tsdb): add chimp stages, gorilla-float, and date-aware pipelines
salvatore-campagna Feb 16, 2026
2ec2e5f
fix(tsdb): search full ALP (e,f) space for lossless mode
salvatore-campagna Feb 16, 2026
d8ef902
feat(tsdb): set otel template to balanced for chimp+fpc experiment
salvatore-campagna Feb 16, 2026
494920b
Merge branch 'main' into feature/tsdb-pipeline-poc
salvatore-campagna Feb 16, 2026
ca9be59
[CI] Auto commit changes from spotless
Feb 16, 2026
6856237
refactor(tsdb): extract shared QuantizeUtils from ALP quantize methods
salvatore-campagna Feb 18, 2026
01e013c
feat(tsdb): add quantization support to FPC and wire chimp/fpc maxError
salvatore-campagna Feb 18, 2026
4d21de8
feat(tsdb): enable chimp quantization in balanced mode and simplify F…
salvatore-campagna Feb 18, 2026
5423bc9
feat(tsdb): revise balanced pipeline to lossless ALP gauges and delta…
salvatore-campagna Feb 18, 2026
c54db49
feat(tsdb): deferred pipeline resolution with field context and block…
salvatore-campagna Feb 20, 2026
19ed942
feat(tsdb): adaptive pipeline selection with block profiling
salvatore-campagna Feb 20, 2026
be05dc9
feat(tsdb): add pipeline selection logging and stage display names
salvatore-campagna Feb 20, 2026
267d976
chore(otel): use storage optimize_for hint for otel double metrics
salvatore-campagna Feb 20, 2026
373d02d
fix(tsdb): skip XOR and FPC in noisy float path when they provide no …
salvatore-campagna Feb 20, 2026
15f1701
Merge branch 'main' into feature/tsdb-pipeline-poc
salvatore-campagna Feb 20, 2026
739e627
fix(tsdb): propagate correct DataType in pipeline selector for all paths
salvatore-campagna Feb 20, 2026
6d8cc08
feat(tsdb): use Gorilla for monotonic double counters and ALP with 6-…
salvatore-campagna Feb 21, 2026
6e2da48
feat(tsdb): route _seq_no through adaptive pipeline resolver
salvatore-campagna Feb 21, 2026
48fd798
Merge branch 'main' into feature/tsdb-pipeline-poc
salvatore-campagna Feb 21, 2026
2c6601b
feat(tsdb): add shifted GCD to block profiler for transform-aware pip…
salvatore-campagna Feb 21, 2026
4e79a15
refactor(tsdb): use gorilla for monotonic float counters and restrict…
salvatore-campagna Feb 21, 2026
c728f6e
refactor(tsdb): consolidate FieldContext and eliminate BlockSizeResolver
salvatore-campagna Feb 21, 2026
40a8fcd
refactor(tsdb): gate gorilla and chimp on optimize_for hint in adapti…
salvatore-campagna Feb 21, 2026
99e2101
refactor(tsdb): use IOContext for phase detection and rework double/f…
salvatore-campagna Feb 21, 2026
3ffdd4a
test(tsdb): add encoding size tests for all pipeline paths
salvatore-campagna Feb 22, 2026
2d80dc9
refactor(tsdb): convert chimp and fpc to raw IEEE domain for XOR cons…
salvatore-campagna Feb 22, 2026
117d0f7
Merge branch 'main' into feature/tsdb-pipeline-poc
salvatore-campagna Feb 22, 2026
313b092
fix(tsdb): add cost-benefit gate to PFor to skip patching when overhe…
salvatore-campagna Feb 22, 2026
7f7a87b
Merge branch 'main' into feature/tsdb-pipeline-poc
salvatore-campagna Feb 22, 2026
1c21745
feat(tsdb): add per-field encoding size debug logging to ES94 consumer
salvatore-campagna Feb 22, 2026
ab8f218
fix(tsdb): drop redundant RLE from constant-block pipeline selection
salvatore-campagna Feb 22, 2026
9427922
refactor(tsdb): widen pipeline selection to handle data shape changes…
salvatore-campagna Feb 22, 2026
4a2499b
refactor(tsdb): simplify long pipeline selection to two paths
salvatore-campagna Feb 22, 2026
59aac82
refactor(tsdb): replace fused deltaDelta with composable delta().delt…
salvatore-campagna Feb 22, 2026
bb4b87b
experiment(tsdb): use ES819-equivalent pipeline to measure pure ES94 …
salvatore-campagna Feb 23, 2026
8edd073
Merge branch 'main' into feature/tsdb-pipeline-poc
salvatore-campagna Feb 23, 2026
5f7f632
test(tsdb): add stage isolation resolver and wire double delta varian…
salvatore-campagna Feb 23, 2026
55bff63
fix(tsdb): deprecate RLE stages and remove from pipeline selection
salvatore-campagna Feb 23, 2026
af65d35
fix(tsdb): use rounded bit widths in PFor cost-benefit gate
salvatore-campagna Feb 23, 2026
f3c2995
feat(tsdb): re-enable AdaptivePipelineResolver as the default pipelin…
salvatore-campagna Feb 23, 2026
e9201da
refactor(tsdb): remove defaultConfig sentinel from PipelineConfig
salvatore-campagna Feb 24, 2026
1b130a3
test(tsdb): set optimize_for to speed for lossless rally benchmark
salvatore-campagna Feb 25, 2026
ae303f7
Merge remote-tracking branch 'upstream/main' into feature/tsdb-pipeli…
salvatore-campagna Feb 25, 2026
b53d7a6
feat(tsdb): use bitpacking for binary doc value offsets in ES94
salvatore-campagna Feb 25, 2026
dea9c60
test(tsdb): temporarily revert optimize_for to storage for benchmark …
salvatore-campagna Feb 26, 2026
8026747
Merge remote-tracking branch 'upstream/main' into feature/tsdb-pipeli…
salvatore-campagna Feb 26, 2026
aa7a9fe
fix: pass syntheticId through createFormatSupplier method chain in Pe…
salvatore-campagna Feb 26, 2026
325d13e
Merge branch 'main' into feature/tsdb-pipeline-poc
salvatore-campagna Feb 26, 2026
b183807
feat: add Chimp and Chimp128 payload stages for floating-point compre…
salvatore-campagna Feb 26, 2026
dd41515
refactor: split FPC into double/float stages and remove group-broadca…
salvatore-campagna Feb 27, 2026
cb8e8a9
feat: data-driven PipelineSelector using BlockProfile signals
salvatore-campagna Feb 27, 2026
a98663f
refactor: decouple Chimp128 stages from streaming Chimp shared constants
salvatore-campagna Feb 27, 2026
05c8eaf
feat: select streaming Chimp vs Chimp128 based on xorMaxBits heuristic
salvatore-campagna Feb 27, 2026
88002f0
refactor: rename ChimpPayload to ChimpDoublePayload for naming consis…
salvatore-campagna Feb 27, 2026
82b5297
feat: dynamic ALP exception threshold scaled by compression benefit
salvatore-campagna Feb 27, 2026
1ed1f76
refactor: realign PipelineSelector hint mapping for data integrity
salvatore-campagna Feb 27, 2026
a877fea
Merge branch 'main' into feature/tsdb-pipeline-poc
salvatore-campagna Feb 27, 2026
9f4f523
refactor: encapsulate Chimp128 buffer size inside encoder constructor
salvatore-campagna Feb 27, 2026
63a8e2c
fix: use profile monotonicity instead of metric type annotation for d…
salvatore-campagna Feb 27, 2026
6f0b666
Merge branch 'main' into feature/tsdb-pipeline-poc
salvatore-campagna Feb 27, 2026
3c7533e
feat: speed mode bypasses ALP for XOR-based floating-point compression
salvatore-campagna Feb 28, 2026
8efb2fa
test: optimize_for balanced for rally benchmark comparison
salvatore-campagna Feb 28, 2026
1275db8
feat: speed mode uses xor + integer pipeline instead of Chimp128 chain
salvatore-campagna Feb 28, 2026
ca9f645
test: optimize_for speed for rally benchmark comparison
salvatore-campagna Feb 28, 2026
99037c3
feat: speed mode uses delta pipeline for counters and FPC for gauges
salvatore-campagna Feb 28, 2026
bdc9ec1
fix: never quantize floating-point counters to preserve rate calculat…
salvatore-campagna Feb 28, 2026
e53cc01
test: optimize_for storage for rally benchmark comparison
salvatore-campagna Feb 28, 2026
45592b3
Merge branch 'main' into feature/tsdb-pipeline-poc
salvatore-campagna Feb 28, 2026
72508e8
test: optimize_for balanced for rally benchmark comparison
salvatore-campagna Feb 28, 2026
750dc55
test: remove optimize_for for rally benchmark baseline comparison
salvatore-campagna Feb 28, 2026
dfe0480
test: optimize_for speed for rally benchmark comparison
salvatore-campagna Feb 28, 2026
0f4ef6b
feat: route monotonic doubles through XOR gate instead of uncondition…
salvatore-campagna Mar 1, 2026
daac604
feat: add fused quantization to Gorilla, Chimp and Chimp128 payload s…
salvatore-campagna Mar 1, 2026
58daaab
feat: refine PipelineSelector decision tree for all optimize_for modes
salvatore-campagna Mar 1, 2026
dd69c12
test: optimize_for balanced for rally benchmark comparison
salvatore-campagna Mar 1, 2026
7de83c4
test: remove optimize_for for rally benchmark baseline comparison
salvatore-campagna Mar 1, 2026
e9bf23e
test: optimize_for speed for rally benchmark comparison
salvatore-campagna Mar 1, 2026
87a161d
test: optimize_for storage for rally benchmark comparison
salvatore-campagna Mar 2, 2026
e2d8d21
refactor: align benchmark pipelines with PipelineSelector decision tree
salvatore-campagna Mar 3, 2026
d63fffb
feat: set optimize_for storage for OTel double metrics mappings
salvatore-campagna Mar 3, 2026
2cfe341
fix: update ValuesSourceReaderBenchmark to use BenchContext
salvatore-campagna Mar 3, 2026
5ea0c91
refactor: remove unused isFloat parameter from StageFactory transform…
salvatore-campagna Mar 3, 2026
3c8baf8
refactor: reorder PipelineDescriptor wire format for logical decode o…
salvatore-campagna Mar 4, 2026
667122c
refactor: fix 6 design issues in pipeline framework
salvatore-campagna Mar 4, 2026
0a85e6c
refactor: remove gorilla from pipeline selection logic
salvatore-campagna Mar 4, 2026
6465432
refactor: simplify StaticPipelineResolver to a safe default fallback
salvatore-campagna Mar 4, 2026
2bfa59e
refactor: use zero instead of -1 as maxError sentinel for lossless mode
salvatore-campagna Mar 4, 2026
151752e
fix: add bounds checking to EncodingContext position methods
salvatore-campagna Mar 4, 2026
0693e0a
fix: add bounds checking to DecodingContext.isStageApplied
salvatore-campagna Mar 4, 2026
5f72602
fix: add writeTo bounds assertion and non-negative writeVInt/writeVLo…
salvatore-campagna Mar 4, 2026
7affe03
refactor: convert PipelineConfig from final class to record
salvatore-campagna Mar 4, 2026
7479a53
[CI] Auto commit changes from spotless
Mar 4, 2026
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
15 changes: 14 additions & 1 deletion benchmarks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,24 @@ tasks.named('test').configure {
}
}

// NOTE: Copy NumericDataGenerators from server test sources so benchmarks can reuse
// the same data patterns without adding a testFixtures dependency.
def numericDataGenSource = "${project(':server').projectDir}/src/test/java/org/elasticsearch/index/codec/tsdb/pipeline/NumericDataGenerators.java"
def numericDataGenDir = layout.buildDirectory.dir("generated/sources/numericDataGenerators")
def copyNumericDataGenerators = tasks.register('copyNumericDataGenerators', Copy) {
inputs.file(numericDataGenSource)
from numericDataGenSource
into numericDataGenDir.map { it.dir("org/elasticsearch/index/codec/tsdb/pipeline") }
outputs.dir(numericDataGenDir)
}
sourceSets.main.java.srcDir numericDataGenDir
tasks.named('compileJava').configure { dependsOn(copyNumericDataGenerators) }

spotless {
java {
// IDEs can sometimes run annotation processors that leave files in
// here, causing Spotless to complain. Even though this path ought not
// to exist, exclude it anyway in order to avoid spurious failures.
targetExclude 'src/main/generated/**/*.java'
targetExclude 'src/main/generated/**/*.java', 'build/generated/**/*.java'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ private static BlockLoader numericBlockLoader(WhereAndBaseName w, NumberFieldMap
false,
null,
null,
false
false,
null
).blockLoader(new BenchContext());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

package org.elasticsearch.benchmark.index.codec.tsdb;

import org.elasticsearch.benchmark.index.codec.tsdb.internal.AbstractTSDBCodecBenchmark;
import org.elasticsearch.benchmark.index.codec.tsdb.internal.AllStagesSupplier;
import org.elasticsearch.benchmark.index.codec.tsdb.internal.DecodeBenchmark;
import org.elasticsearch.benchmark.index.codec.tsdb.internal.ThroughputMetrics;
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.Warmup;
import org.openjdk.jmh.infra.Blackhole;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

/**
* Benchmark for decoding data that triggers all encoding stages (Delta -> Offset -> GCD -> FOR).
*/
@Fork(value = 1)
@Warmup(iterations = 3)
@Measurement(iterations = 5)
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Benchmark)
public class DecodeAllStagesBenchmark {
private static final int SEED = 17;

@Param({ "10" })
private int blocksPerInvocation;

private final AbstractTSDBCodecBenchmark decode;

public DecodeAllStagesBenchmark() {
this.decode = new DecodeBenchmark();
}

@Setup(Level.Trial)
public void setupTrial() throws IOException {
AllStagesSupplier supplier = AllStagesSupplier.builder(SEED, decode.getBlockSize()).build();
decode.setupTrial(supplier);
decode.setBlocksPerInvocation(blocksPerInvocation);
decode.run();
}

@Benchmark
public void throughput(Blackhole bh, ThroughputMetrics metrics) throws IOException {
decode.benchmark(bh);
metrics.recordOperation(decode.getBlockSize() * blocksPerInvocation, decode.getEncodedSize() * blocksPerInvocation);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

package org.elasticsearch.benchmark.index.codec.tsdb;

import org.elasticsearch.benchmark.index.codec.tsdb.internal.DecodeBenchmark;
import org.elasticsearch.benchmark.index.codec.tsdb.internal.NumericDataSupplierRegistry;
import org.elasticsearch.benchmark.index.codec.tsdb.internal.ThroughputMetrics;
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.Warmup;
import org.openjdk.jmh.infra.Blackhole;

import java.io.IOException;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;

// NOTE: Decoding benchmark using NumericDataGenerators double data sources.
@Fork(value = 1)
@Warmup(iterations = 3)
@Measurement(iterations = 5)
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Benchmark)
public class DecodeDoubleGeneratorsBenchmark {

@Param(
{
"constant-double",
"percentage-double",
"monotonic-double",
"gauge-double",
"realistic-gauge-double",
"sparse-gauge-double",
"random-double",
"stable-sensor-double",
"tiny-increment-double",
"steady-counter-double",
"burst-spike-double",
"zero-crossing-oscillation-double",
"step-with-spikes-double",
"counter-with-resets-double",
"quantized-double",
"sensor-2dp-double",
"temperature-1dp-double",
"financial-2dp-double",
"percentage-rounded-1dp-double",
"mixed-sign-double",
"step-hold-double",
"timestamp-as-double",
"counter-as-double",
"gauge-as-double",
"gcd-as-double",
"constant-as-double",
"random-as-double",
"decreasing-timestamp-as-double",
"small-as-double",
"timestamp-with-jitter-as-double" }
)
private String datasetName;

@Param({ "42" })
private String seed;

@Param({ "10" })
private int blocksPerInvocation;

private final DecodeBenchmark decode = new DecodeBenchmark();

@Setup(Level.Trial)
public void setupTrial() throws IOException {
final Map<String, Supplier<long[]>> registry = NumericDataSupplierRegistry.toMap(
NumericDataSupplierRegistry.doubleSuppliers(decode.getBlockSize(), Long.parseLong(seed))
);
if (registry.size() != 30) {
throw new IllegalStateException(
"Expected 30 double datasets but found " + registry.size() + ". Update @Param list. Available: " + registry.keySet()
);
}
final Supplier<long[]> supplier = registry.get(datasetName);
if (supplier == null) {
throw new IllegalArgumentException("Unknown double dataset: [" + datasetName + "]. Available: " + registry.keySet());
}
decode.setupTrial(supplier);
decode.setBlocksPerInvocation(blocksPerInvocation);
}

@Benchmark
public void throughput(Blackhole bh, ThroughputMetrics metrics) throws IOException {
decode.benchmark(bh);
metrics.recordOperation(decode.getBlockSize() * blocksPerInvocation, decode.getEncodedSize() * blocksPerInvocation);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

package org.elasticsearch.benchmark.index.codec.tsdb;

import org.elasticsearch.benchmark.index.codec.tsdb.internal.DecodeBenchmark;
import org.elasticsearch.benchmark.index.codec.tsdb.internal.NumericDataSupplierRegistry;
import org.elasticsearch.benchmark.index.codec.tsdb.internal.ThroughputMetrics;
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.Warmup;
import org.openjdk.jmh.infra.Blackhole;

import java.io.IOException;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;

// NOTE: Decoding benchmark using NumericDataGenerators long data sources.
@Fork(value = 1)
@Warmup(iterations = 3)
@Measurement(iterations = 5)
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Benchmark)
public class DecodeLongGeneratorsBenchmark {

@Param(
{
"timestamp",
"counter",
"gauge",
"gcd",
"constant",
"random",
"decreasing-timestamp",
"boundary",
"small",
"timestamp-with-jitter" }
)
private String datasetName;

@Param({ "42" })
private String seed;

@Param({ "10" })
private int blocksPerInvocation;

private final DecodeBenchmark decode = new DecodeBenchmark();

@Setup(Level.Trial)
public void setupTrial() throws IOException {
final Map<String, Supplier<long[]>> registry = NumericDataSupplierRegistry.toMap(
NumericDataSupplierRegistry.longSuppliers(decode.getBlockSize(), Long.parseLong(seed))
);
final Supplier<long[]> supplier = registry.get(datasetName);
if (supplier == null) {
throw new IllegalArgumentException("Unknown long dataset: [" + datasetName + "]. Available: " + registry.keySet());
}
decode.setupTrial(supplier);
decode.setBlocksPerInvocation(blocksPerInvocation);
}

@Benchmark
public void throughput(Blackhole bh, ThroughputMetrics metrics) throws IOException {
decode.benchmark(bh);
metrics.recordOperation(decode.getBlockSize() * blocksPerInvocation, decode.getEncodedSize() * blocksPerInvocation);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

package org.elasticsearch.benchmark.index.codec.tsdb;

import org.elasticsearch.benchmark.index.codec.tsdb.internal.AbstractTSDBCodecBenchmark;
import org.elasticsearch.benchmark.index.codec.tsdb.internal.AllStagesSupplier;
import org.elasticsearch.benchmark.index.codec.tsdb.internal.CompressionMetrics;
import org.elasticsearch.benchmark.index.codec.tsdb.internal.EncodeBenchmark;
import org.elasticsearch.benchmark.index.codec.tsdb.internal.ThroughputMetrics;
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.Warmup;
import org.openjdk.jmh.infra.Blackhole;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

/**
* Benchmark for encoding data that triggers all encoding stages (Delta -> Offset -> GCD -> FOR).
*/
@Fork(value = 1)
@Warmup(iterations = 3)
@Measurement(iterations = 5)
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Benchmark)
public class EncodeAllStagesBenchmark {
private static final int SEED = 17;

@Param({ "10" })
private int blocksPerInvocation;

private final AbstractTSDBCodecBenchmark encode;

public EncodeAllStagesBenchmark() {
this.encode = new EncodeBenchmark();
}

@Setup(Level.Trial)
public void setupTrial() throws IOException {
AllStagesSupplier supplier = AllStagesSupplier.builder(SEED, encode.getBlockSize()).build();
encode.setupTrial(supplier);
encode.setBlocksPerInvocation(blocksPerInvocation);
encode.run();
}

@Benchmark
public void throughput(Blackhole bh, ThroughputMetrics metrics) throws IOException {
encode.benchmark(bh);
metrics.recordOperation(encode.getBlockSize() * blocksPerInvocation, encode.getEncodedSize() * blocksPerInvocation);
}

@Benchmark
@Warmup(iterations = 0)
@Measurement(iterations = 1)
@BenchmarkMode(Mode.SingleShotTime)
public void compression(Blackhole bh, CompressionMetrics metrics) throws IOException {
encode.benchmark(bh);
metrics.recordOperation(encode.getBlockSize(), encode.getEncodedSize(), 0);
}
}
Loading