diff --git a/benchmarks/jmh-result.json b/benchmarks/jmh-result.json new file mode 100644 index 0000000000000..bcf87f66aea18 --- /dev/null +++ b/benchmarks/jmh-result.json @@ -0,0 +1,248 @@ +[ + { + "jmhVersion" : "1.37", + "benchmark" : "org.elasticsearch.benchmark.compute.operator.BlockKeepMaskBenchmark.run", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Users/sidosera/.gradle/jdks/oracle_corporation-25-aarch64-os_x.2/jdk-25.0.1.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Des.nativelibs.path=/Users/sidosera/dist/elasticsearch/libs/native/libraries/build/platform/darwin-aarch64", + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "25.0.1", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "25.0.1+8-27", + "warmupIterations" : 5, + "warmupTime" : "10 s", + "warmupBatchSize" : 1, + "measurementIterations" : 7, + "measurementTime" : "10 s", + "measurementBatchSize" : 1, + "params" : { + "dataTypeAndBlockKind" : "BytesRef/array" + }, + "primaryMetric" : { + "score" : 26.97325481453015, + "scoreError" : 0.4114546808275431, + "scoreConfidence" : [ + 26.561800133702608, + 27.384709495357693 + ], + "scorePercentiles" : { + "0.0" : 26.741479950029838, + "50.0" : 26.910885562486275, + "90.0" : 27.248479736757005, + "95.0" : 27.248479736757005, + "99.0" : 27.248479736757005, + "99.9" : 27.248479736757005, + "99.99" : 27.248479736757005, + "99.999" : 27.248479736757005, + "99.9999" : 27.248479736757005, + "100.0" : 27.248479736757005 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 26.840043099344328, + 26.910885562486275, + 26.741479950029838, + 27.044630155366505, + 26.87081878621902, + 27.156446411508085, + 27.248479736757005 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.37", + "benchmark" : "org.elasticsearch.benchmark.compute.operator.BlockKeepMaskBenchmark.run", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Users/sidosera/.gradle/jdks/oracle_corporation-25-aarch64-os_x.2/jdk-25.0.1.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Des.nativelibs.path=/Users/sidosera/dist/elasticsearch/libs/native/libraries/build/platform/darwin-aarch64", + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "25.0.1", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "25.0.1+8-27", + "warmupIterations" : 5, + "warmupTime" : "10 s", + "warmupBatchSize" : 1, + "measurementIterations" : 7, + "measurementTime" : "10 s", + "measurementBatchSize" : 1, + "params" : { + "dataTypeAndBlockKind" : "BytesRef/vector" + }, + "primaryMetric" : { + "score" : 20.604918241968612, + "scoreError" : 0.054875552292492, + "scoreConfidence" : [ + 20.55004268967612, + 20.659793794261105 + ], + "scorePercentiles" : { + "0.0" : 20.571577856064227, + "50.0" : 20.605237591663546, + "90.0" : 20.640481691890116, + "95.0" : 20.640481691890116, + "99.0" : 20.640481691890116, + "99.9" : 20.640481691890116, + "99.99" : 20.640481691890116, + "99.999" : 20.640481691890116, + "99.9999" : 20.640481691890116, + "100.0" : 20.640481691890116 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 20.584394202338096, + 20.629711589403065, + 20.571577856064227, + 20.605237591663546, + 20.593563923938298, + 20.60946083848296, + 20.640481691890116 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.37", + "benchmark" : "org.elasticsearch.benchmark.compute.operator.BlockKeepMaskBenchmark.run", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Users/sidosera/.gradle/jdks/oracle_corporation-25-aarch64-os_x.2/jdk-25.0.1.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Des.nativelibs.path=/Users/sidosera/dist/elasticsearch/libs/native/libraries/build/platform/darwin-aarch64", + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "25.0.1", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "25.0.1+8-27", + "warmupIterations" : 5, + "warmupTime" : "10 s", + "warmupBatchSize" : 1, + "measurementIterations" : 7, + "measurementTime" : "10 s", + "measurementBatchSize" : 1, + "params" : { + "dataTypeAndBlockKind" : "long/array" + }, + "primaryMetric" : { + "score" : 2.0059155361308987, + "scoreError" : 0.020934175129458714, + "scoreConfidence" : [ + 1.98498136100144, + 2.026849711260357 + ], + "scorePercentiles" : { + "0.0" : 1.9970240371928898, + "50.0" : 2.0025414397901105, + "90.0" : 2.024625290264212, + "95.0" : 2.024625290264212, + "99.0" : 2.024625290264212, + "99.9" : 2.024625290264212, + "99.99" : 2.024625290264212, + "99.999" : 2.024625290264212, + "99.9999" : 2.024625290264212, + "100.0" : 2.024625290264212 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 2.0046880743410367, + 2.010852135116885, + 1.9970240371928898, + 2.0013141900186304, + 2.000363586192524, + 2.024625290264212, + 2.0025414397901105 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.37", + "benchmark" : "org.elasticsearch.benchmark.compute.operator.BlockKeepMaskBenchmark.run", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Users/sidosera/.gradle/jdks/oracle_corporation-25-aarch64-os_x.2/jdk-25.0.1.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Des.nativelibs.path=/Users/sidosera/dist/elasticsearch/libs/native/libraries/build/platform/darwin-aarch64", + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "25.0.1", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "25.0.1+8-27", + "warmupIterations" : 5, + "warmupTime" : "10 s", + "warmupBatchSize" : 1, + "measurementIterations" : 7, + "measurementTime" : "10 s", + "measurementBatchSize" : 1, + "params" : { + "dataTypeAndBlockKind" : "long/vector" + }, + "primaryMetric" : { + "score" : 1.6923044146150725, + "scoreError" : 0.024483821555364445, + "scoreConfidence" : [ + 1.667820593059708, + 1.716788236170437 + ], + "scorePercentiles" : { + "0.0" : 1.6773734151767334, + "50.0" : 1.6933926819601168, + "90.0" : 1.709058660899675, + "95.0" : 1.709058660899675, + "99.0" : 1.709058660899675, + "99.9" : 1.709058660899675, + "99.99" : 1.709058660899675, + "99.999" : 1.709058660899675, + "99.9999" : 1.709058660899675, + "100.0" : 1.709058660899675 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 1.6861674532228137, + 1.6933926819601168, + 1.698228760702106, + 1.6989500167364104, + 1.709058660899675, + 1.6829599136076518, + 1.6773734151767334 + ] + ] + }, + "secondaryMetrics" : { + } + } +] + + diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/k8s-timeseries.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/k8s-timeseries.csv-spec index 847148990ec75..0e2a94334dced 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/k8s-timeseries.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/k8s-timeseries.csv-spec @@ -1077,6 +1077,25 @@ max_deriv:double | max_rate:double | time_bucket:date_nanos | cluster:keyword 10.2206 | 6.9807 | 2024-05-10T00:20:00.000Z | prod ; +derivative_of_gauge_metric_promql +required_capability: promql_pre_tech_preview_v7 + +// tag::deriv[] +PROMQL index=k8s step=5m max by (pod) (deriv(network.cost[5m])) +// end::deriv[] +| WHERE pod == "three" +| SORT pod, step +| LIMIT 5 +; + +max by (pod) (deriv(network.cost[5m])):double | step:datetime | pod:keyword +0.1016742317005992 | 2024-05-10T00:00:00.000Z | three +0.04110020549538044 | 2024-05-10T00:05:00.000Z | three +-0.017149432096630335 | 2024-05-10T00:10:00.000Z | three +-0.0011132215149700642 | 2024-05-10T00:15:00.000Z | three +0.019532827926533564 | 2024-05-10T00:20:00.000Z | three +; + DefaultMetricWithFrom required_capability: ts_command_v0 required_capability: aggregate_metric_double_default_metric diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/aggregate/Deriv.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/aggregate/Deriv.java index 67dc6c100b9fd..b22c0f313a322 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/aggregate/Deriv.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/aggregate/Deriv.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.esql.expression.function.aggregate; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.compute.aggregation.AggregatorFunctionSupplier; import org.elasticsearch.compute.aggregation.DerivDoubleAggregatorFunctionSupplier; import org.elasticsearch.compute.aggregation.DerivIntAggregatorFunctionSupplier; @@ -28,6 +29,7 @@ import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; import org.elasticsearch.xpack.esql.planner.ToAggregator; +import java.io.IOException; import java.util.List; import java.util.Objects; @@ -72,7 +74,7 @@ public Deriv(Source source, Expression field, Expression filter, Expression wind this.timestamp = timestamp; } - private Deriv(org.elasticsearch.common.io.stream.StreamInput in) throws java.io.IOException { + private Deriv(StreamInput in) throws IOException { this( Source.readFrom((PlanStreamInput) in), in.readNamedWriteable(Expression.class), diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/promql/function/PromqlFunctionRegistry.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/promql/function/PromqlFunctionRegistry.java index 141165cb40228..e95ebd8128af3 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/promql/function/PromqlFunctionRegistry.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/promql/function/PromqlFunctionRegistry.java @@ -17,6 +17,7 @@ import org.elasticsearch.xpack.esql.expression.function.aggregate.Count; import org.elasticsearch.xpack.esql.expression.function.aggregate.CountOverTime; import org.elasticsearch.xpack.esql.expression.function.aggregate.Delta; +import org.elasticsearch.xpack.esql.expression.function.aggregate.Deriv; import org.elasticsearch.xpack.esql.expression.function.aggregate.FirstOverTime; import org.elasticsearch.xpack.esql.expression.function.aggregate.Idelta; import org.elasticsearch.xpack.esql.expression.function.aggregate.Increase; @@ -67,7 +68,8 @@ private static FunctionDefinition[][] functionDefinitions() { withinSeries("idelta", Idelta::new), withinSeries("increase", Increase::new), withinSeries("irate", Irate::new), - withinSeries("rate", Rate::new) }, + withinSeries("rate", Rate::new), + withinSeries("deriv", Deriv::new) }, // Aggregation range functions new FunctionDefinition[] { withinSeriesOverTimeWithWindow("avg_over_time", AvgOverTime::new), @@ -272,7 +274,6 @@ private void register(FunctionDefinition[][] definitionGroups) { // Range vector functions (not yet implemented) "changes", - "deriv", "holt_winters", "mad_over_time", "predict_linear",