Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-3827 Add performance tests for the Lucene backend
- Loading branch information
Showing
8 changed files
with
308 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Hibernate Search, full-text search for your domain model | ||
~ | ||
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.hibernate.search</groupId> | ||
<artifactId>hibernate-search-integrationtest-performance</artifactId> | ||
<version>6.0.0-SNAPSHOT</version> | ||
<relativePath>../..</relativePath> | ||
</parent> | ||
<artifactId>hibernate-search-integrationtest-performance-backend-lucene</artifactId> | ||
|
||
<name>Hibernate Search Integration Tests - Performance - Backend - Lucene</name> | ||
<description>Performance tests for the Lucene backend</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.hibernate.search</groupId> | ||
<artifactId>hibernate-search-backend-lucene</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.hibernate.search</groupId> | ||
<artifactId>hibernate-search-integrationtest-performance-backend-base</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.hibernate.search</groupId> | ||
<artifactId>hibernate-search-util-internal-integrationtest-common</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>it</id> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.bsc.maven</groupId> | ||
<artifactId>maven-processor-plugin</artifactId> | ||
<executions> | ||
<!-- Run JMH annotation processor on src/main/java sources --> | ||
<execution> | ||
<id>processjmh</id> | ||
<goals> | ||
<goal>process</goal> | ||
</goals> | ||
<phase>generate-sources</phase> | ||
<configuration> | ||
<processors> | ||
<processor>org.openjdk.jmh.generators.BenchmarkProcessor</processor> | ||
</processors> | ||
<!-- Also process the source from the base project --> | ||
<appendSourceArtifacts>true</appendSourceArtifacts> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.openjdk.jmh</groupId> | ||
<artifactId>jmh-generator-annprocess</artifactId> | ||
<version>${version.org.openjdk.jmh}</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<finalName>benchmarks</finalName> | ||
<transformers> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<mainClass>org.openjdk.jmh.Main</mainClass> | ||
</transformer> | ||
<!-- Needed for service entries implementing BeanConfigurer in particular --> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" /> | ||
</transformers> | ||
<filters> | ||
<filter> | ||
<!-- | ||
Shading signed JARs will fail without this. | ||
http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar | ||
--> | ||
<artifact>*:*</artifact> | ||
<excludes> | ||
<exclude>META-INF/*.SF</exclude> | ||
<exclude>META-INF/*.DSA</exclude> | ||
<exclude>META-INF/*.RSA</exclude> | ||
</excludes> | ||
</filter> | ||
</filters> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
36 changes: 36 additions & 0 deletions
36
...te/search/integrationtest/performance/backend/lucene/testsupport/LuceneBackendHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.integrationtest.performance.backend.lucene.testsupport; | ||
|
||
import java.io.IOException; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
import org.hibernate.search.backend.lucene.cfg.LuceneBackendSettings; | ||
import org.hibernate.search.engine.cfg.BackendSettings; | ||
import org.hibernate.search.engine.cfg.spi.ConfigurationPropertySource; | ||
import org.hibernate.search.integrationtest.performance.backend.base.testsupport.filesystem.TemporaryFileHolder; | ||
import org.hibernate.search.integrationtest.performance.backend.base.testsupport.index.AbstractBackendHolder; | ||
|
||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.State; | ||
|
||
@State(Scope.Benchmark) | ||
public class LuceneBackendHolder extends AbstractBackendHolder { | ||
|
||
@Override | ||
protected ConfigurationPropertySource getDefaultBackendProperties(TemporaryFileHolder temporaryFileHolder) | ||
throws IOException { | ||
Map<String, Object> map = new LinkedHashMap<>(); | ||
|
||
map.put( BackendSettings.TYPE, LuceneBackendSettings.TYPE_NAME ); | ||
map.put( LuceneBackendSettings.DIRECTORY_ROOT, temporaryFileHolder.getIndexesDirectory().toAbsolutePath() ); | ||
map.put( LuceneBackendSettings.ANALYSIS_CONFIGURER, LucenePerformanceAnalysisConfigurer.class ); | ||
|
||
return ConfigurationPropertySource.fromMap( map ); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
.../integrationtest/performance/backend/lucene/testsupport/LuceneMassIndexingBenchmarks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.integrationtest.performance.backend.lucene.testsupport; | ||
|
||
import org.hibernate.search.integrationtest.performance.backend.base.AbstractMassIndexingBenchmarks; | ||
import org.hibernate.search.integrationtest.performance.backend.base.testsupport.index.IndexInitializer; | ||
|
||
import org.openjdk.jmh.annotations.Level; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.openjdk.jmh.infra.ThreadParams; | ||
|
||
@State(Scope.Thread) | ||
public class LuceneMassIndexingBenchmarks extends AbstractMassIndexingBenchmarks { | ||
|
||
@Setup(Level.Trial) | ||
public void setupTrial(LuceneBackendHolder backendHolder, IndexInitializer indexInitializer, | ||
ThreadParams threadParams) { | ||
doSetupTrial( backendHolder, indexInitializer, threadParams ); | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...egrationtest/performance/backend/lucene/testsupport/LuceneOnTheFlyIndexingBenchmarks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.integrationtest.performance.backend.lucene.testsupport; | ||
|
||
import org.hibernate.search.engine.backend.work.execution.DocumentCommitStrategy; | ||
import org.hibernate.search.integrationtest.performance.backend.base.AbstractOnTheFlyIndexingBenchmarks; | ||
import org.hibernate.search.integrationtest.performance.backend.base.testsupport.index.IndexInitializer; | ||
|
||
import org.openjdk.jmh.annotations.Level; | ||
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.infra.ThreadParams; | ||
|
||
@State(Scope.Thread) | ||
public class LuceneOnTheFlyIndexingBenchmarks extends AbstractOnTheFlyIndexingBenchmarks { | ||
|
||
@Param({ "NONE", "FORCE" }) | ||
private DocumentCommitStrategy commitStrategy; | ||
|
||
@Setup(Level.Trial) | ||
public void setupTrial(LuceneBackendHolder backendHolder, IndexInitializer indexInitializer, | ||
ThreadParams threadParams) { | ||
doSetupTrial( backendHolder, indexInitializer, threadParams ); | ||
} | ||
|
||
@Override | ||
protected DocumentCommitStrategy getCommitStrategyParam() { | ||
return commitStrategy; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...ationtest/performance/backend/lucene/testsupport/LucenePerformanceAnalysisConfigurer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.integrationtest.performance.backend.lucene.testsupport; | ||
|
||
import org.hibernate.search.backend.lucene.analysis.LuceneAnalysisConfigurationContext; | ||
import org.hibernate.search.backend.lucene.analysis.LuceneAnalysisConfigurer; | ||
import org.hibernate.search.integrationtest.performance.backend.base.testsupport.analysis.Analyzers; | ||
|
||
import org.apache.lucene.analysis.core.LowerCaseFilterFactory; | ||
import org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilterFactory; | ||
import org.apache.lucene.analysis.snowball.SnowballPorterFilterFactory; | ||
import org.apache.lucene.analysis.standard.StandardTokenizerFactory; | ||
|
||
public class LucenePerformanceAnalysisConfigurer implements LuceneAnalysisConfigurer { | ||
|
||
@Override | ||
public void configure(LuceneAnalysisConfigurationContext context) { | ||
context.analyzer( Analyzers.ANALYZER_ENGLISH ).custom() | ||
.tokenizer( StandardTokenizerFactory.class ) | ||
.tokenFilter( LowerCaseFilterFactory.class ) | ||
.tokenFilter( SnowballPorterFilterFactory.class ) | ||
.param( "language", "English" ) | ||
.tokenFilter( ASCIIFoldingFilterFactory.class ); | ||
|
||
context.normalizer( Analyzers.NORMALIZER_ENGLISH ).custom() | ||
.tokenFilter( LowerCaseFilterFactory.class ) | ||
.tokenFilter( ASCIIFoldingFilterFactory.class ); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
integrationtest/performance/backend/lucene/src/main/resources/log4j.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender | ||
log4j.appender.stdout.Target=System.out | ||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L %m%n | ||
|
||
log4j.rootLogger=info, stdout | ||
log4j.logger.org.jboss=info | ||
log4j.logger.org.hibernate=info | ||
log4j.logger.org.hibernate.search=info |
43 changes: 43 additions & 0 deletions
43
...rc/test/java/org/hibernate/search/integrationtest/performance/backend/lucene/SmokeIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.integrationtest.performance.backend.lucene; | ||
|
||
import org.junit.Test; | ||
|
||
import org.openjdk.jmh.runner.Runner; | ||
import org.openjdk.jmh.runner.RunnerException; | ||
import org.openjdk.jmh.runner.options.Options; | ||
import org.openjdk.jmh.runner.options.OptionsBuilder; | ||
import org.openjdk.jmh.runner.options.TimeValue; | ||
|
||
/** | ||
* Test that JMH benchmarks work correctly on a very short run. | ||
* <p> | ||
* This may not work correctly when run from the IDE. | ||
* <p> | ||
* See README to know how to run the benchmark from the command line to obtain more reliable results. | ||
*/ | ||
public class SmokeIT { | ||
|
||
@Test | ||
public void test() throws RunnerException { | ||
Options opts = new OptionsBuilder() | ||
.include( ".*" ) | ||
.warmupIterations( 0 ) | ||
.measurementIterations( 1 ) | ||
.measurementTime( TimeValue.seconds( 1 ) ) | ||
.param( "initialIndexSize", "100" ) | ||
.param( "batchSize", "10" ) | ||
.param( "maxResults", "10" ) | ||
.shouldFailOnError( true ) | ||
.forks( 0 ) // To simplify debugging; Remember this implies JVM parameters via @Fork won't be applied. | ||
.build(); | ||
|
||
new Runner( opts ).run(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters