From 6fde983192a039cbea7476511b32ee9e513cb9d2 Mon Sep 17 00:00:00 2001 From: MishaDemianenko Date: Mon, 13 Mar 2017 17:18:03 +0100 Subject: [PATCH] Introduce KernelStatisticProvider to separate cypher from new store dependencies. And ProfileKernelStatisticProvider as it de facto implementation that will provide execution statistic. --- .../v3_2/spi/DelegatingQueryContext.scala | 3 +- .../v3_2/spi/KernelStatisticProvider.scala | 41 +++++++++++++++++++ .../compiler/v3_2/spi/QueryContext.scala | 3 +- .../builders/EntityProducerFactoryTest.scala | 7 ++-- .../v3_2/pipes/ProcedureCallPipeTest.scala | 5 +-- .../ExceptionTranslatingQueryContext.scala | 3 +- .../v3_2/ProfileKernelStatisticProvider.scala | 34 +++++++++++++++ .../v3_2/TransactionBoundQueryContext.scala | 6 +-- .../TransactionBoundQueryContextTest.scala | 8 ++-- .../cypher-compiled-runtime-3.2/pom.xml | 8 +++- .../codegen/profiling/ProfilingTracer.java | 24 +++++------ .../v3_2/BuildCompiledExecutionPlan.scala | 2 +- .../v3_2/ExecutionPlanBuilder.scala | 2 +- .../profiling/ProfilingTracerTest.scala | 16 ++++---- .../codegen/ir/CompiledProfilingTest.scala | 5 ++- 15 files changed, 122 insertions(+), 45 deletions(-) create mode 100644 community/cypher/cypher-compiler-3.2/src/main/scala/org/neo4j/cypher/internal/compiler/v3_2/spi/KernelStatisticProvider.scala create mode 100644 community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_2/ProfileKernelStatisticProvider.scala diff --git a/community/cypher/cypher-compiler-3.2/src/main/scala/org/neo4j/cypher/internal/compiler/v3_2/spi/DelegatingQueryContext.scala b/community/cypher/cypher-compiler-3.2/src/main/scala/org/neo4j/cypher/internal/compiler/v3_2/spi/DelegatingQueryContext.scala index d8297cb2ad922..29544317679e3 100644 --- a/community/cypher/cypher-compiler-3.2/src/main/scala/org/neo4j/cypher/internal/compiler/v3_2/spi/DelegatingQueryContext.scala +++ b/community/cypher/cypher-compiler-3.2/src/main/scala/org/neo4j/cypher/internal/compiler/v3_2/spi/DelegatingQueryContext.scala @@ -26,7 +26,6 @@ import org.neo4j.cypher.internal.compiler.v3_2.commands.expressions.{Expander, K import org.neo4j.cypher.internal.compiler.v3_2.pipes.matching.PatternNode import org.neo4j.cypher.internal.frontend.v3_2.SemanticDirection import org.neo4j.graphdb.{Node, Path, PropertyContainer, Relationship} -import org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer import scala.collection.Iterator @@ -212,7 +211,7 @@ class DelegatingQueryContext(val inner: QueryContext) extends QueryContext { override def assertSchemaWritesAllowed(): Unit = inner.assertSchemaWritesAllowed() - override def pageCursorTracer(): PageCursorTracer = inner.pageCursorTracer() + override def kernelStatisticProvider(): KernelStatisticProvider = inner.kernelStatisticProvider() } class DelegatingOperations[T <: PropertyContainer](protected val inner: Operations[T]) extends Operations[T] { diff --git a/community/cypher/cypher-compiler-3.2/src/main/scala/org/neo4j/cypher/internal/compiler/v3_2/spi/KernelStatisticProvider.scala b/community/cypher/cypher-compiler-3.2/src/main/scala/org/neo4j/cypher/internal/compiler/v3_2/spi/KernelStatisticProvider.scala new file mode 100644 index 0000000000000..b76350b1e7398 --- /dev/null +++ b/community/cypher/cypher-compiler-3.2/src/main/scala/org/neo4j/cypher/internal/compiler/v3_2/spi/KernelStatisticProvider.scala @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2002-2017 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.com] + * + * This file is part of Neo4j. + * + * Neo4j is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.neo4j.cypher.internal.compiler.v3_2.spi + +/** + * Expose various query execution kernel statistics + */ +trait KernelStatisticProvider { + /** + * @return observed page cache hits that was caused by particular query execution + */ + def getPageCacheHits: Long + + /** + * @return observer page cache misses that was caused by particular query execution + */ + def getPageCacheMisses: Long +} + +object EmptyKernelStatisticProvider extends KernelStatisticProvider { + override def getPageCacheHits: Long = 0 + + override def getPageCacheMisses: Long = 0 +} diff --git a/community/cypher/cypher-compiler-3.2/src/main/scala/org/neo4j/cypher/internal/compiler/v3_2/spi/QueryContext.scala b/community/cypher/cypher-compiler-3.2/src/main/scala/org/neo4j/cypher/internal/compiler/v3_2/spi/QueryContext.scala index 4a74080ef3941..de0d780705861 100644 --- a/community/cypher/cypher-compiler-3.2/src/main/scala/org/neo4j/cypher/internal/compiler/v3_2/spi/QueryContext.scala +++ b/community/cypher/cypher-compiler-3.2/src/main/scala/org/neo4j/cypher/internal/compiler/v3_2/spi/QueryContext.scala @@ -26,7 +26,6 @@ import org.neo4j.cypher.internal.compiler.v3_2.pipes.matching.PatternNode import org.neo4j.cypher.internal.compiler.v3_2.{IndexDescriptor, InternalQueryStatistics} import org.neo4j.cypher.internal.frontend.v3_2.SemanticDirection import org.neo4j.graphdb.{Node, Path, PropertyContainer, Relationship} -import org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer import scala.collection.Iterator @@ -180,7 +179,7 @@ trait QueryContext extends TokenContext { def assertSchemaWritesAllowed(): Unit - def pageCursorTracer() : PageCursorTracer + def kernelStatisticProvider() : KernelStatisticProvider } trait Operations[T <: PropertyContainer] { diff --git a/community/cypher/cypher-compiler-3.2/src/test/scala/org/neo4j/cypher/internal/compiler/v3_2/executionplan/builders/EntityProducerFactoryTest.scala b/community/cypher/cypher-compiler-3.2/src/test/scala/org/neo4j/cypher/internal/compiler/v3_2/executionplan/builders/EntityProducerFactoryTest.scala index 20546ffb137df..3baf5f22f4757 100644 --- a/community/cypher/cypher-compiler-3.2/src/test/scala/org/neo4j/cypher/internal/compiler/v3_2/executionplan/builders/EntityProducerFactoryTest.scala +++ b/community/cypher/cypher-compiler-3.2/src/test/scala/org/neo4j/cypher/internal/compiler/v3_2/executionplan/builders/EntityProducerFactoryTest.scala @@ -25,12 +25,11 @@ import org.mockito.Mockito._ import org.neo4j.cypher.internal.compiler.v3_2.commands._ import org.neo4j.cypher.internal.compiler.v3_2.commands.expressions.Literal import org.neo4j.cypher.internal.compiler.v3_2.pipes.QueryStateHelper -import org.neo4j.cypher.internal.compiler.v3_2.spi.{PlanContext, QueryContext, QueryContextAdaptation} +import org.neo4j.cypher.internal.compiler.v3_2.spi._ import org.neo4j.cypher.internal.compiler.v3_2.{ExecutionContext, IndexDescriptor} import org.neo4j.cypher.internal.frontend.v3_2.IndexHintException import org.neo4j.cypher.internal.frontend.v3_2.test_helpers.CypherFunSuite import org.neo4j.graphdb.Node -import org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer class EntityProducerFactoryTest extends CypherFunSuite { var planContext: PlanContext = null @@ -87,8 +86,8 @@ class EntityProducerFactoryTest extends CypherFunSuite { Iterator.empty } - override def pageCursorTracer(): PageCursorTracer = { - PageCursorTracer.NULL + override def kernelStatisticProvider(): KernelStatisticProvider = { + EmptyKernelStatisticProvider } } val state = QueryStateHelper.emptyWith(query = queryContext) diff --git a/community/cypher/cypher-compiler-3.2/src/test/scala/org/neo4j/cypher/internal/compiler/v3_2/pipes/ProcedureCallPipeTest.scala b/community/cypher/cypher-compiler-3.2/src/test/scala/org/neo4j/cypher/internal/compiler/v3_2/pipes/ProcedureCallPipeTest.scala index 5eb793fda0ace..873cdec6431d8 100644 --- a/community/cypher/cypher-compiler-3.2/src/test/scala/org/neo4j/cypher/internal/compiler/v3_2/pipes/ProcedureCallPipeTest.scala +++ b/community/cypher/cypher-compiler-3.2/src/test/scala/org/neo4j/cypher/internal/compiler/v3_2/pipes/ProcedureCallPipeTest.scala @@ -26,7 +26,6 @@ import org.neo4j.cypher.internal.compiler.v3_2.spi._ import org.neo4j.cypher.internal.frontend.v3_2.ast.AstConstructionTestSupport import org.neo4j.cypher.internal.frontend.v3_2.symbols._ import org.neo4j.cypher.internal.frontend.v3_2.test_helpers.CypherFunSuite -import org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer class ProcedureCallPipeTest extends CypherFunSuite @@ -131,8 +130,8 @@ class ProcedureCallPipeTest result(args) } - override def pageCursorTracer(): PageCursorTracer = { - PageCursorTracer.NULL + override def kernelStatisticProvider(): KernelStatisticProvider = { + EmptyKernelStatisticProvider } } } diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_2/ExceptionTranslatingQueryContext.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_2/ExceptionTranslatingQueryContext.scala index b57a1a5b10d31..699fb89bd0b3f 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_2/ExceptionTranslatingQueryContext.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_2/ExceptionTranslatingQueryContext.scala @@ -28,7 +28,6 @@ import org.neo4j.cypher.internal.compiler.v3_2.spi.{QualifiedName, _} import org.neo4j.cypher.internal.frontend.v3_2.SemanticDirection import org.neo4j.cypher.internal.spi.v3_2.ExceptionTranslationSupport import org.neo4j.graphdb.{Node, Path, PropertyContainer, Relationship} -import org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer import scala.collection.Iterator @@ -236,7 +235,7 @@ class ExceptionTranslatingQueryContext(val inner: QueryContext) extends QueryCon override def assertSchemaWritesAllowed(): Unit = translateException(inner.assertSchemaWritesAllowed()) - override def pageCursorTracer(): PageCursorTracer = translateException(inner.pageCursorTracer()) + override def kernelStatisticProvider(): KernelStatisticProvider = translateException(inner.kernelStatisticProvider()) class ExceptionTranslatingOperations[T <: PropertyContainer](inner: Operations[T]) extends DelegatingOperations[T](inner) { diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_2/ProfileKernelStatisticProvider.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_2/ProfileKernelStatisticProvider.scala new file mode 100644 index 0000000000000..03f5f7f8920d7 --- /dev/null +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_2/ProfileKernelStatisticProvider.scala @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2002-2017 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.com] + * + * This file is part of Neo4j. + * + * Neo4j is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.neo4j.cypher.internal.compatibility.v3_2 + +import org.neo4j.cypher.internal.compiler.v3_2.spi.KernelStatisticProvider +import org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer + +class ProfileKernelStatisticProvider(pageCursorTracer: PageCursorTracer) extends KernelStatisticProvider { + + override def getPageCacheHits: Long = { + pageCursorTracer.hits() + } + + override def getPageCacheMisses: Long = { + pageCursorTracer.faults() + } +} diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundQueryContext.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundQueryContext.scala index f28681404f6d6..ca317b364c8dc 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundQueryContext.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundQueryContext.scala @@ -25,6 +25,7 @@ import java.util.function.Predicate import org.neo4j.collection.RawIterator import org.neo4j.collection.primitive.PrimitiveLongIterator import org.neo4j.collection.primitive.base.Empty.EMPTY_PRIMITIVE_LONG_COLLECTION +import org.neo4j.cypher.internal.compatibility.v3_2.ProfileKernelStatisticProvider import org.neo4j.cypher.internal.compiler.v3_2.MinMaxOrdering.{BY_NUMBER, BY_STRING, BY_VALUE} import org.neo4j.cypher.internal.compiler.v3_2._ import org.neo4j.cypher.internal.compiler.v3_2.ast.convert.commands.DirectionConverter.toGraphDb @@ -45,7 +46,6 @@ import org.neo4j.graphdb.RelationshipType._ import org.neo4j.graphdb._ import org.neo4j.graphdb.security.URLAccessValidationError import org.neo4j.graphdb.traversal.{Evaluators, TraversalDescription, Uniqueness} -import org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer import org.neo4j.kernel.GraphDatabaseQueryService import org.neo4j.kernel.api._ import org.neo4j.kernel.api.exceptions.ProcedureException @@ -740,8 +740,8 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional override def assertSchemaWritesAllowed(): Unit = transactionalContext.statement.schemaWriteOperations() - override def pageCursorTracer(): PageCursorTracer = { - transactionalContext.statement.asInstanceOf[KernelStatement].getPageCursorTracer + override def kernelStatisticProvider(): KernelStatisticProvider = { + new ProfileKernelStatisticProvider(transactionalContext.statement.asInstanceOf[KernelStatement].getPageCursorTracer) } } diff --git a/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundQueryContextTest.scala b/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundQueryContextTest.scala index 892c9dd2785cf..cc791427e2219 100644 --- a/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundQueryContextTest.scala +++ b/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/spi/v3_2/TransactionBoundQueryContextTest.scala @@ -177,14 +177,12 @@ class TransactionBoundQueryContextTest extends CypherFunSuite { val transactionalContext = TransactionalContextWrapper(createTransactionContext(graph, tx)) val context = new TransactionBoundQueryContext(transactionalContext)(indexSearchMonitor) - val tracer = context.pageCursorTracer() - tracer.hits() should equal(0) - tracer.pins() should equal(0) + val tracer = context.kernelStatisticProvider() + tracer.getPageCacheHits should equal(0) graph.getNodeById(2) graph.getNodeById(1) - tracer.hits() should equal(2) - tracer.pins() should equal(2) + tracer.getPageCacheHits should equal(2) tx.close() } diff --git a/enterprise/cypher/cypher-compiled-runtime-3.2/pom.xml b/enterprise/cypher/cypher-compiled-runtime-3.2/pom.xml index 1d42175d04aca..0f33d1b067baf 100644 --- a/enterprise/cypher/cypher-compiled-runtime-3.2/pom.xml +++ b/enterprise/cypher/cypher-compiled-runtime-3.2/pom.xml @@ -162,7 +162,13 @@ ${project.version} test-jar test - + + + org.neo4j + neo4j-cypher + ${project.version} + test + diff --git a/enterprise/cypher/cypher-compiled-runtime-3.2/src/main/java/org/neo4j/cypher/internal/compiled_runtime/v3_2/codegen/profiling/ProfilingTracer.java b/enterprise/cypher/cypher-compiled-runtime-3.2/src/main/java/org/neo4j/cypher/internal/compiled_runtime/v3_2/codegen/profiling/ProfilingTracer.java index 5b2517babe225..6389bc6e1de68 100644 --- a/enterprise/cypher/cypher-compiled-runtime-3.2/src/main/java/org/neo4j/cypher/internal/compiled_runtime/v3_2/codegen/profiling/ProfilingTracer.java +++ b/enterprise/cypher/cypher-compiled-runtime-3.2/src/main/java/org/neo4j/cypher/internal/compiled_runtime/v3_2/codegen/profiling/ProfilingTracer.java @@ -25,7 +25,7 @@ import org.neo4j.cypher.internal.compiled_runtime.v3_2.codegen.QueryExecutionEvent; import org.neo4j.cypher.internal.compiled_runtime.v3_2.codegen.QueryExecutionTracer; import org.neo4j.cypher.internal.compiler.v3_2.planDescription.Id; -import org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer; +import org.neo4j.cypher.internal.compiler.v3_2.spi.KernelStatisticProvider; public class ProfilingTracer implements QueryExecutionTracer { @@ -48,18 +48,18 @@ public interface Clock private static final Data ZERO = new Data(); private final Clock clock; - private final PageCursorTracer pageCursorTracer; + private final KernelStatisticProvider statisticProvider; private final Map data = new HashMap<>(); - public ProfilingTracer( PageCursorTracer pageCursorTracer ) + public ProfilingTracer( KernelStatisticProvider statisticProvider ) { - this( Clock.SYSTEM_TIMER, pageCursorTracer ); + this( Clock.SYSTEM_TIMER, statisticProvider ); } - ProfilingTracer( Clock clock, PageCursorTracer pageCursorTracer ) + ProfilingTracer( Clock clock, KernelStatisticProvider statisticProvider ) { this.clock = clock; - this.pageCursorTracer = pageCursorTracer; + this.statisticProvider = statisticProvider; } public ProfilingInformation get( Id query ) @@ -91,22 +91,22 @@ public QueryExecutionEvent executeOperator( Id queryId ) { this.data.put( queryId, data = new Data() ); } - return new ExecutionEvent( clock, pageCursorTracer, data ); + return new ExecutionEvent( clock, statisticProvider, data ); } private static class ExecutionEvent implements QueryExecutionEvent { private final long start; private final Clock clock; - private final PageCursorTracer pageCursorTracer; + private final KernelStatisticProvider statisticProvider; private final Data data; private long hitCount; private long rowCount; - ExecutionEvent( Clock clock, PageCursorTracer pageCursorTracer, Data data ) + ExecutionEvent( Clock clock, KernelStatisticProvider statisticProvider, Data data ) { this.clock = clock; - this.pageCursorTracer = pageCursorTracer; + this.statisticProvider = statisticProvider; this.data = data; this.start = clock.nanoTime(); } @@ -115,8 +115,8 @@ private static class ExecutionEvent implements QueryExecutionEvent public void close() { long executionTime = clock.nanoTime() - start; - long pageCacheHits = pageCursorTracer.hits(); - long pageCacheFaults = pageCursorTracer.faults(); + long pageCacheHits = statisticProvider.getPageCacheHits(); + long pageCacheFaults = statisticProvider.getPageCacheMisses(); if ( data != null ) { data.update( executionTime, hitCount, rowCount, pageCacheHits, pageCacheFaults ); diff --git a/enterprise/cypher/cypher-compiled-runtime-3.2/src/main/scala/org/neo4j/cypher/internal/compiled_runtime/v3_2/BuildCompiledExecutionPlan.scala b/enterprise/cypher/cypher-compiled-runtime-3.2/src/main/scala/org/neo4j/cypher/internal/compiled_runtime/v3_2/BuildCompiledExecutionPlan.scala index ab0694362cf8c..60ebdd7fd3c67 100644 --- a/enterprise/cypher/cypher-compiled-runtime-3.2/src/main/scala/org/neo4j/cypher/internal/compiled_runtime/v3_2/BuildCompiledExecutionPlan.scala +++ b/enterprise/cypher/cypher-compiled-runtime-3.2/src/main/scala/org/neo4j/cypher/internal/compiled_runtime/v3_2/BuildCompiledExecutionPlan.scala @@ -94,7 +94,7 @@ object BuildCompiledExecutionPlan extends Phase[CompiledRuntimeContext, Compilat private def createTracer(mode: ExecutionMode, queryContext: QueryContext): DescriptionProvider = mode match { case ProfileMode => - val tracer = new ProfilingTracer(queryContext.pageCursorTracer()) + val tracer = new ProfilingTracer(queryContext.kernelStatisticProvider()) (description: InternalPlanDescription) => (new Provider[InternalPlanDescription] { diff --git a/enterprise/cypher/cypher-compiled-runtime-3.2/src/main/scala/org/neo4j/cypher/internal/compiled_runtime/v3_2/ExecutionPlanBuilder.scala b/enterprise/cypher/cypher-compiled-runtime-3.2/src/main/scala/org/neo4j/cypher/internal/compiled_runtime/v3_2/ExecutionPlanBuilder.scala index e6fa9819d18f5..ddab1b64cc78a 100644 --- a/enterprise/cypher/cypher-compiled-runtime-3.2/src/main/scala/org/neo4j/cypher/internal/compiled_runtime/v3_2/ExecutionPlanBuilder.scala +++ b/enterprise/cypher/cypher-compiled-runtime-3.2/src/main/scala/org/neo4j/cypher/internal/compiled_runtime/v3_2/ExecutionPlanBuilder.scala @@ -35,7 +35,7 @@ object ExecutionPlanBuilder { def tracer(mode: ExecutionMode, queryContext: QueryContext): DescriptionProvider = mode match { case ProfileMode => - val tracer = new ProfilingTracer(queryContext.pageCursorTracer()) + val tracer = new ProfilingTracer(queryContext.kernelStatisticProvider()) (description: InternalPlanDescription) => (new Provider[InternalPlanDescription] { diff --git a/enterprise/cypher/cypher-compiled-runtime-3.2/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_2/codegen/profiling/ProfilingTracerTest.scala b/enterprise/cypher/cypher-compiled-runtime-3.2/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_2/codegen/profiling/ProfilingTracerTest.scala index 345993d68829d..f25768a437d01 100644 --- a/enterprise/cypher/cypher-compiled-runtime-3.2/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_2/codegen/profiling/ProfilingTracerTest.scala +++ b/enterprise/cypher/cypher-compiled-runtime-3.2/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_2/codegen/profiling/ProfilingTracerTest.scala @@ -19,9 +19,11 @@ */ package org.neo4j.cypher.internal.compiled_runtime.v3_2.codegen.profiling +import org.neo4j.cypher.internal.compatibility.v3_2.ProfileKernelStatisticProvider import org.neo4j.cypher.internal.compiler.v3_2.planDescription.Id +import org.neo4j.cypher.internal.compiler.v3_2.spi.EmptyKernelStatisticProvider import org.neo4j.cypher.internal.frontend.v3_2.test_helpers.CypherFunSuite -import org.neo4j.io.pagecache.tracing.cursor.{DefaultPageCursorTracer, PageCursorTracer} +import org.neo4j.io.pagecache.tracing.cursor.DefaultPageCursorTracer class ProfilingTracerTest extends CypherFunSuite { @@ -38,7 +40,7 @@ class ProfilingTracerTest extends CypherFunSuite { // given val clock = new Clock val operatorId = new Id - val tracer = new ProfilingTracer(clock, PageCursorTracer.NULL) + val tracer = new ProfilingTracer(clock, EmptyKernelStatisticProvider) val event = tracer.executeOperator(operatorId) // when @@ -53,7 +55,7 @@ class ProfilingTracerTest extends CypherFunSuite { // given val clock = new Clock val operatorId = new Id - val tracer = new ProfilingTracer(clock, PageCursorTracer.NULL) + val tracer = new ProfilingTracer(clock, EmptyKernelStatisticProvider) // when val event1 = tracer.executeOperator(operatorId) @@ -71,7 +73,7 @@ class ProfilingTracerTest extends CypherFunSuite { test("shouldReportDbHitsOfQueryExecution") { // given val operatorId = new Id - val tracer = new ProfilingTracer(PageCursorTracer.NULL) + val tracer = new ProfilingTracer(EmptyKernelStatisticProvider) val event = tracer.executeOperator(operatorId) // when @@ -88,7 +90,7 @@ class ProfilingTracerTest extends CypherFunSuite { test("shouldReportRowsOfQueryExecution") { // given val operatorId = new Id - val tracer = new ProfilingTracer(PageCursorTracer.NULL) + val tracer = new ProfilingTracer(EmptyKernelStatisticProvider) val event = tracer.executeOperator(operatorId) // when @@ -106,7 +108,7 @@ class ProfilingTracerTest extends CypherFunSuite { test("report page cache hits as part of profiling statistics") { val operatorId = new Id val cursorTracer = new DefaultPageCursorTracer - var tracer = new ProfilingTracer(cursorTracer) + var tracer = new ProfilingTracer(new ProfileKernelStatisticProvider(cursorTracer)) val event = tracer.executeOperator(operatorId) 1 to 100 foreach { _ => { @@ -125,7 +127,7 @@ class ProfilingTracerTest extends CypherFunSuite { test("report page cache misses as part of profiling statistics") { val operatorId = new Id val cursorTracer = new DefaultPageCursorTracer - var tracer = new ProfilingTracer(cursorTracer) + var tracer = new ProfilingTracer(new ProfileKernelStatisticProvider(cursorTracer)) val event = tracer.executeOperator(operatorId) 1 to 17 foreach { _ => { diff --git a/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_2/codegen/ir/CompiledProfilingTest.scala b/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_2/codegen/ir/CompiledProfilingTest.scala index 4efa6f35af8aa..273201d3825ce 100644 --- a/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_2/codegen/ir/CompiledProfilingTest.scala +++ b/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_2/codegen/ir/CompiledProfilingTest.scala @@ -22,6 +22,7 @@ package org.neo4j.cypher.internal.compiled_runtime.v3_2.codegen.ir import org.mockito.Matchers._ import org.mockito.Mockito._ import org.neo4j.collection.primitive.PrimitiveLongIterator +import org.neo4j.cypher.internal.compatibility.v3_2.ProfileKernelStatisticProvider import org.neo4j.cypher.internal.compiled_runtime.v3_2.codegen.Variable import org.neo4j.cypher.internal.compiled_runtime.v3_2.codegen.ir.expressions.CodeGenType import org.neo4j.cypher.internal.compiled_runtime.v3_2.codegen.profiling.ProfilingTracer @@ -61,7 +62,7 @@ class CompiledProfilingTest extends CypherFunSuite with CodeGenSugar { val queryContext = mock[QueryContext] val transactionalContext = mock[TransactionalContextWrapper] when(queryContext.transactionalContext).thenReturn(transactionalContext.asInstanceOf[QueryTransactionalContext]) - when(queryContext.pageCursorTracer()).thenReturn(new DefaultPageCursorTracer) + when(queryContext.kernelStatisticProvider()).thenReturn(new ProfileKernelStatisticProvider(new DefaultPageCursorTracer)) when(transactionalContext.readOperations).thenReturn(readOps) when(entityAccessor.newNodeProxyById(anyLong())).thenReturn(mock[NodeProxy]) when(queryContext.entityAccessor).thenReturn(entityAccessor.asInstanceOf[queryContext.EntityAccessor]) @@ -82,7 +83,7 @@ class CompiledProfilingTest extends CypherFunSuite with CodeGenSugar { } // when - val tracer = new ProfilingTracer(queryContext.pageCursorTracer()) + val tracer = new ProfilingTracer(queryContext.kernelStatisticProvider()) newInstance(compiled, queryContext = queryContext, provider = provider, queryExecutionTracer = tracer).size // then