Skip to content

Commit

Permalink
HSEARCH-3827 Add performance tests for the Lucene backend
Browse files Browse the repository at this point in the history
  • Loading branch information
yrodiere authored and fax4ever committed Feb 17, 2020
1 parent 5b0c5e7 commit 02c8f76
Show file tree
Hide file tree
Showing 8 changed files with 308 additions and 0 deletions.
122 changes: 122 additions & 0 deletions integrationtest/performance/backend/lucene/pom.xml
@@ -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>
@@ -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 );
}
}
@@ -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 );
}

}
@@ -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;
}
}
@@ -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 );
}

}
@@ -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
@@ -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();
}

}
1 change: 1 addition & 0 deletions integrationtest/performance/pom.xml
Expand Up @@ -15,6 +15,7 @@
<modules>
<module>backend/base</module>
<module>backend/elasticsearch</module>
<module>backend/lucene</module>
</modules>

<dependencyManagement>
Expand Down

0 comments on commit 02c8f76

Please sign in to comment.