From 82a40ca10e6df683d5f769702293e94c071f16ac Mon Sep 17 00:00:00 2001 From: Vish Ramachandran Date: Thu, 28 Nov 2024 14:43:56 +0530 Subject: [PATCH] jmh fixes --- .../Base2ExponentialHistogramQueryBenchmark.scala | 13 ++++++++----- .../filodb.memory/format/vectors/Histogram.scala | 3 ++- run_benchmarks.sh | 12 +++++++++--- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/jmh/src/main/scala/filodb.jmh/Base2ExponentialHistogramQueryBenchmark.scala b/jmh/src/main/scala/filodb.jmh/Base2ExponentialHistogramQueryBenchmark.scala index b00038cf07..03a35c745f 100644 --- a/jmh/src/main/scala/filodb.jmh/Base2ExponentialHistogramQueryBenchmark.scala +++ b/jmh/src/main/scala/filodb.jmh/Base2ExponentialHistogramQueryBenchmark.scala @@ -34,7 +34,7 @@ import filodb.timeseries.TestTimeseriesProducer */ @State(Scope.Thread) class Base2ExponentialHistogramQueryBenchmark extends StrictLogging { - org.slf4j.LoggerFactory.getLogger("filodb").asInstanceOf[Logger].setLevel(Level.DEBUG) + org.slf4j.LoggerFactory.getLogger("filodb").asInstanceOf[Logger].setLevel(Level.WARN) import filodb.coordinator._ import client.Client.{actorAsk, asyncAsk} @@ -46,7 +46,7 @@ class Base2ExponentialHistogramQueryBenchmark extends StrictLogging { // TODO: move setup and ingestion to another trait val system = ActorSystem("test", ConfigFactory.load("filodb-defaults.conf") - .withValue("filodb.memstore.ingestion-buffer-mem-size", ConfigValueFactory.fromAnyRef("30MB"))) + .withValue("filodb.memstore.ingestion-buffer-mem-size", ConfigValueFactory.fromAnyRef("300MB"))) private val cluster = FilodbCluster(system) cluster.join() @@ -90,11 +90,12 @@ class Base2ExponentialHistogramQueryBenchmark extends StrictLogging { val (producingFut, containerStream) = TestTimeseriesProducer.metricsToContainerStream(startTime, numShards, numSeries, numMetricNames = 1, numSamplesPerTs * numSeries, dataset, shardMapper, spread, publishIntervalSec = 10, numBuckets = numBuckets, expHist = true) + val endTime = startTime + (numSamplesPerTs * 10000) val ingestTask = containerStream.groupBy(_._1) // Asynchronously subcribe and ingest each shard .mapParallelUnordered(numShards) { groupedStream => val shard = groupedStream.key - println(s"Starting ingest exp histograms on shard $shard...") + println(s"Starting ingest exp histograms on shard $shard from timestamp $startTime to $endTime") val shardStream = groupedStream.zipWithIndex.flatMap { case ((_, bytes), idx) => val data = bytes.map { array => SomeData(RecordContainer(array), idx) } Observable.fromIterable(data) @@ -117,13 +118,15 @@ class Base2ExponentialHistogramQueryBenchmark extends StrictLogging { val histQuantileQuery = """histogram_quantile(0.7, sum(rate(http_request_latency_delta{_ws_="demo", _ns_="App-0"}[5m])))""" val queries = Seq(histQuantileQuery) - val queryTime = startTime + (7 * 60 * 1000) // 5 minutes from start until 60 minutes from start + val queryStartTime = startTime/1000 + (5 * 60) // 5 minutes from start until 60 minutes from start val queryStep = 120 // # of seconds between each query sample "step" - val qParams = TimeStepParams(queryTime/1000, queryStep, (queryTime/1000) + queryIntervalMin*60) + val queryEndTime = queryStartTime + queryIntervalMin*60 + val qParams = TimeStepParams(queryStartTime, queryStep, queryEndTime) val logicalPlans = queries.map { q => Parser.queryRangeToLogicalPlan(q, qParams) } val queryCommands = logicalPlans.map { plan => LogicalPlan2Query(dataset.ref, plan, QueryContext(Some(new StaticSpreadProvider(SpreadChange(0, spread))), 20000)) } + println(s"Querying data from $queryStartTime to $queryEndTime") var queriesSucceeded = 0 var queriesFailed = 0 diff --git a/memory/src/main/scala/filodb.memory/format/vectors/Histogram.scala b/memory/src/main/scala/filodb.memory/format/vectors/Histogram.scala index b24128c123..53a803a0c6 100644 --- a/memory/src/main/scala/filodb.memory/format/vectors/Histogram.scala +++ b/memory/src/main/scala/filodb.memory/format/vectors/Histogram.scala @@ -594,7 +594,8 @@ final case class GeometricBuckets(firstBucket: Double, object Base2ExpHistogramBuckets { // TODO: make maxBuckets default configurable; not straightforward to get handle to global config from here - val maxBuckets = 200 + // see PR for benchmark test results based on which maxBuckets was fixed. Dont increase without analysis. + val maxBuckets = 180 val maxAbsScale = 100 val maxAbsBucketIndex = 500 } diff --git a/run_benchmarks.sh b/run_benchmarks.sh index 458898ca25..2432976a5a 100755 --- a/run_benchmarks.sh +++ b/run_benchmarks.sh @@ -1,6 +1,11 @@ #!/bin/bash -sbt -Drust.optimize=true "jmh/jmh:run -rf json -i 5 -wi 3 -f 1 -jvmArgsAppend -XX:MaxInlineLevel=20 \ - -jvmArgsAppend -Xmx4g -jvmArgsAppend -XX:MaxInlineSize=99 -jvmArgsAppend -Dkamon.enabled=false \ + +sbt -Drust.optimize=true "jmh/jmh:run -rf json -i 2 -wi 2 -f 1 \ + -jvmArgsAppend -Dlogback.configurationFile=../conf/logback-perf.xml + -jvmArgsAppend -XX:MaxInlineLevel=20 \ + -jvmArgsAppend -Xmx4g \ + -jvmArgsAppend -XX:MaxInlineSize=99 \ + -jvmArgsAppend -Dkamon.enabled=false \ filodb.jmh.Base2ExponentialHistogramQueryBenchmark \ filodb.jmh.QueryHiCardInMemoryBenchmark \ filodb.jmh.QueryInMemoryBenchmark \ @@ -11,4 +16,5 @@ sbt -Drust.optimize=true "jmh/jmh:run -rf json -i 5 -wi 3 -f 1 -jvmArgsAppend -X filodb.jmh.PartKeyLuceneIndexBenchmark \ filodb.jmh.PartKeyTantivyIndexBenchmark" -# -prof 'async:libPath=/path/to/async-profiler-3.0-macos/lib/libasyncProfiler.dylib;event=cpu;output=flamegraphdir=./profile-results' \ \ No newline at end of file +# Add below argument to enable profiling +# -prof \"async:libPath=/path/to/async-profiler-3.0-macos/lib/libasyncProfiler.dylib;event=cpu;output=flamegraph;dir=./profile-results\" \