diff --git a/README.md b/README.md index a2e7a6b..c0b04cf 100644 --- a/README.md +++ b/README.md @@ -122,35 +122,3 @@ $ mvn clean install -Pqulice ``` To avoid build errors use Maven 3.2+. - -## Benchmarking - -To run benchmarks: - 1. Build `rpm-adapter` with `bench` Maven profile enabled: `mvn package -Pbench` - 2. Copy dependencies to `target/` dir: `mvn dependency:copy-dependencies` - 3. Create directory for tests and copy test resources to this directory - 4. Run benchmarks with `env BENCH_DIR=/tmp/rpm-test java -cp "target/benchmarks.jar:target/classes/*:target/dependency/*" org.openjdk.jmh.Main BenchToRun`, where `/tmp/rpm-test` is a directory with test data. - -Available benchmark classes: - -### RpmBench - -This benchmark class creates/updates repository indexes over provided RPM packages, it calls -`com.artipie.rpm.Rpm.batchUpdateIncrementally` and requires the set of the RPMs in the test directory. -There are available bundles: - - https://artipie.s3.amazonaws.com/rpm-test/bundle100.tar.gz - - https://artipie.s3.amazonaws.com/rpm-test/bundle1000.tar.gz - -### RpmMetadataRemoveBench - -This benchmark class removes RPM packages records from the repository index files, it works with -`com.artipie.rpm.RpmMetadata.Remove` class and requires xml (unpacked) indexes in the test directory. -Example repository index xmls can be found -[here](https://artipie.s3.amazonaws.com/rpm-test/centos-7-os-x86_64-repodata.tar.gz). - -### RpmMetadataAppendBench - -`RpmMetadataAppendBench` updates repository metadata with the list of the provided `.rpm` packages, -it works with `com.artipie.rpm.RpmMetadata.Append` class and requires xml (unpacked) indexes and -`.rpm` packages to add in the test directory. Example data set for the benchmark can be found -[here](https://artipie.s3.amazonaws.com/rpm-test/rpm-metadata-append-bench.tar.gz). \ No newline at end of file diff --git a/benchmarks/README.md b/benchmarks/README.md new file mode 100644 index 0000000..f1358b6 --- /dev/null +++ b/benchmarks/README.md @@ -0,0 +1,31 @@ +# RPM adapter benchmarks + +To run benchmarks: + 1. Install snapshot locally of `rpm-adapter`: `mvn install` + 2. Build `rpm-bench` project: `mvn package -f ./benchmarks` + 4. Create directory for tests and copy test resources to this directory + 5. Run benchmarks with `env BENCH_DIR=${test-dir} java -cp "benchmarks/target/benchmarks.jar" org.openjdk.jmh.Main ${bench-name}`, where `${test-dir}` is a directory with test data, and `${bench-name}` is a benchbmark name. + +## Benchmarks + +### RpmBench + +This benchmark class creates/updates repository indexes over provided RPM packages, it calls +`com.artipie.rpm.Rpm.batchUpdateIncrementally` and requires the set of the RPMs in the test directory. +There are available bundles: + - https://artipie.s3.amazonaws.com/rpm-test/bundle100.tar.gz + - https://artipie.s3.amazonaws.com/rpm-test/bundle1000.tar.gz + +### RpmMetadataRemoveBench + +This benchmark class removes RPM packages records from the repository index files, it works with +`com.artipie.rpm.RpmMetadata.Remove` class and requires xml (unpacked) indexes in the test directory. +Example repository index xmls can be found +[here](https://artipie.s3.amazonaws.com/rpm-test/centos-7-os-x86_64-repodata.tar.gz). + +### RpmMetadataAppendBench + +`RpmMetadataAppendBench` updates repository metadata with the list of the provided `.rpm` packages, +it works with `com.artipie.rpm.RpmMetadata.Append` class and requires xml (unpacked) indexes and +`.rpm` packages to add in the test directory. Example data set for the benchmark can be found +[here](https://artipie.s3.amazonaws.com/rpm-test/rpm-metadata-append-bench.tar.gz). diff --git a/benchmarks/pom.xml b/benchmarks/pom.xml new file mode 100644 index 0000000..25bdcb8 --- /dev/null +++ b/benchmarks/pom.xml @@ -0,0 +1,96 @@ + + + + com.artipie + ppom + 0.5.1 + + 4.0.0 + com.artipie + rpm-bench + 1.0-SNAPSHOT + jar + + 1.29 + 1.2.0 + + + + com.artipie + rpm-adapter + 1.0-SNAPSHOT + + + org.openjdk.jmh + jmh-core + ${jmh.version} + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh.version} + + + com.artipie + asto + ${asto.version} + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh.version} + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.0 + + + package + + shade + + + benchmarks + + + org.openjdk.jmh.Main + + + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + + + + diff --git a/src/main/java/com/artipie/rpm/benchmarks/RpmBench.java b/benchmarks/src/main/java/com/artipie/rpm/benchmarks/RpmBench.java similarity index 84% rename from src/main/java/com/artipie/rpm/benchmarks/RpmBench.java rename to benchmarks/src/main/java/com/artipie/rpm/benchmarks/RpmBench.java index 03ba3c7..e73ae74 100644 --- a/src/main/java/com/artipie/rpm/benchmarks/RpmBench.java +++ b/benchmarks/src/main/java/com/artipie/rpm/benchmarks/RpmBench.java @@ -7,8 +7,10 @@ import com.artipie.asto.Key; import com.artipie.asto.Storage; +import com.artipie.asto.blocking.BlockingStorage; import com.artipie.asto.fs.FileStorage; import com.artipie.asto.memory.InMemoryStorage; +import com.artipie.asto.memory.BenchmarkStorage; import com.artipie.asto.rx.RxStorageWrapper; import com.artipie.rpm.Rpm; import hu.akarnokd.rxjava2.interop.CompletableInterop; @@ -16,7 +18,10 @@ import io.reactivex.Observable; import io.reactivex.Single; import java.nio.file.Paths; +import java.util.Collection; +import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Level; @@ -52,32 +57,26 @@ public class RpmBench { private static final String BENCH_DIR = System.getenv("BENCH_DIR"); /** - * Repository storage. + * Repository source storage. */ - private Storage storage; + private InMemoryStorage readonly; @Setup public void setup() { if (RpmBench.BENCH_DIR == null) { throw new IllegalStateException("BENCH_DIR environment variable must be set"); } - this.storage = new InMemoryStorage(); + this.readonly = new InMemoryStorage(); final Storage src = new FileStorage(Paths.get(RpmBench.BENCH_DIR)); - RpmBench.sync(src, this.storage); - } - - @Setup(Level.Iteration) - public void setupIter() { - final RxStorageWrapper rxst = new RxStorageWrapper(this.storage); - rxst.list(new Key.From("repodata")) - .flatMapObservable(Observable::fromIterable) - .flatMapCompletable(key -> rxst.delete(key)) - .to(CompletableInterop.await()).toCompletableFuture().join(); + final BlockingStorage bsto = new BlockingStorage(src); + bsto.list(new Key.From("repodata")).forEach(key -> bsto.delete(key)); + RpmBench.sync(src, this.readonly); } @Benchmark public void run(final Blackhole bhl) { - new Rpm(this.storage).batchUpdateIncrementally(Key.ROOT) + new Rpm(new BenchmarkStorage(this.readonly)) + .batchUpdateIncrementally(Key.ROOT) .to(CompletableInterop.await()) .toCompletableFuture().join(); } diff --git a/src/main/java/com/artipie/rpm/benchmarks/RpmMetadataAppendBench.java b/benchmarks/src/main/java/com/artipie/rpm/benchmarks/RpmMetadataAppendBench.java similarity index 100% rename from src/main/java/com/artipie/rpm/benchmarks/RpmMetadataAppendBench.java rename to benchmarks/src/main/java/com/artipie/rpm/benchmarks/RpmMetadataAppendBench.java diff --git a/src/main/java/com/artipie/rpm/benchmarks/RpmMetadataRemoveBench.java b/benchmarks/src/main/java/com/artipie/rpm/benchmarks/RpmMetadataRemoveBench.java similarity index 100% rename from src/main/java/com/artipie/rpm/benchmarks/RpmMetadataRemoveBench.java rename to benchmarks/src/main/java/com/artipie/rpm/benchmarks/RpmMetadataRemoveBench.java diff --git a/src/main/java/com/artipie/rpm/benchmarks/package-info.java b/benchmarks/src/main/java/com/artipie/rpm/benchmarks/package-info.java similarity index 100% rename from src/main/java/com/artipie/rpm/benchmarks/package-info.java rename to benchmarks/src/main/java/com/artipie/rpm/benchmarks/package-info.java diff --git a/pom.xml b/pom.xml index 4f6e76d..9c91a5f 100644 --- a/pom.xml +++ b/pom.xml @@ -31,12 +31,11 @@ SOFTWARE. rpm-adapter 1.0-SNAPSHOT - rpm-files + rpm-adapter Turns your files/objects into RPM artifacts https://github.com/artipie/rpm-adapter 2019 - 1.29 ${project.basedir}/LICENSE.header @@ -221,16 +220,6 @@ SOFTWARE. 1.7.30 test - - org.openjdk.jmh - jmh-core - ${jmh.version} - - - org.openjdk.jmh - jmh-generator-annprocess - ${jmh.version} - com.jcabi jcabi-aspects @@ -424,64 +413,5 @@ SOFTWARE. - - bench - - - - org.apache.maven.plugins - maven-shade-plugin - 3.2.0 - - - package - - shade - - - benchmarks - - - org.openjdk.jmh.Main - - - - - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - package - - copy-dependencies - - - - - runtime - - - - -