Add no-op benchmark variants for BlockingQueue implementations of AsyncAppender
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/4514fe72 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/4514fe72 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/4514fe72 Branch: refs/heads/master Commit: 4514fe72186ef61cc524544e0c9472150b724020 Parents: 604306c Author: Matt Sicker <boa...@gmail.com> Authored: Fri Jun 17 22:38:12 2016 -0500 Committer: Matt Sicker <boa...@gmail.com> Committed: Fri Jun 17 22:38:12 2016 -0500 ---------------------------------------------------------------------- .../perf/jmh/AsyncAppenderLog4j2Benchmark.java | 40 ++++++++++++++++++-- .../perf5AsyncApndDsrptrNoLoc-noOpAppender.xml | 32 ++++++++++++++++ .../perf5AsyncApndNoLoc-noOpAppender.xml | 1 + .../perf5AsyncApndXferQNoLoc-noOpAppender.xml | 32 ++++++++++++++++ 4 files changed, 102 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4514fe72/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/AsyncAppenderLog4j2Benchmark.java ---------------------------------------------------------------------- diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/AsyncAppenderLog4j2Benchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/AsyncAppenderLog4j2Benchmark.java index 732f7a2..74483f2 100644 --- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/AsyncAppenderLog4j2Benchmark.java +++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/AsyncAppenderLog4j2Benchmark.java @@ -33,7 +33,17 @@ import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; -import static org.apache.logging.log4j.perf.util.BenchmarkMessageParams.*; +import static org.apache.logging.log4j.perf.util.BenchmarkMessageParams.eight; +import static org.apache.logging.log4j.perf.util.BenchmarkMessageParams.eleven; +import static org.apache.logging.log4j.perf.util.BenchmarkMessageParams.five; +import static org.apache.logging.log4j.perf.util.BenchmarkMessageParams.four; +import static org.apache.logging.log4j.perf.util.BenchmarkMessageParams.nine; +import static org.apache.logging.log4j.perf.util.BenchmarkMessageParams.one; +import static org.apache.logging.log4j.perf.util.BenchmarkMessageParams.seven; +import static org.apache.logging.log4j.perf.util.BenchmarkMessageParams.six; +import static org.apache.logging.log4j.perf.util.BenchmarkMessageParams.ten; +import static org.apache.logging.log4j.perf.util.BenchmarkMessageParams.three; +import static org.apache.logging.log4j.perf.util.BenchmarkMessageParams.two; /** * Tests Log4j2 Async Appender performance. @@ -50,12 +60,36 @@ import static org.apache.logging.log4j.perf.util.BenchmarkMessageParams.*; // java -jar log4j-perf/target/benchmarks.jar -help // @State(Scope.Benchmark) -public class AsyncAppenderLog4j2Benchmark { +public abstract class AsyncAppenderLog4j2Benchmark { Logger logger; + abstract String getConfigFileName(); + + public static class ArrayBlockingQueue extends AsyncAppenderLog4j2Benchmark { + @Override + String getConfigFileName() { + return "perf5AsyncApndNoLoc-noOpAppender.xml"; + } + } + + public static class DisruptorBlockingQueue extends AsyncAppenderLog4j2Benchmark { + @Override + String getConfigFileName() { + return "perf5AsyncApndDsrptrNoLoc-noOpAppender.xml"; + } + } + + public static class LinkedTransferQueue extends AsyncAppenderLog4j2Benchmark { + + @Override + String getConfigFileName() { + return "perf5AsyncApndXferQNoLoc-noOpAppender.xml"; + } + } + @Setup(Level.Trial) public void up() { - System.setProperty("log4j.configurationFile", "perf5AsyncApndNoLoc-noOpAppender.xml"); + System.setProperty("log4j.configurationFile", getConfigFileName()); logger = LogManager.getLogger(getClass()); } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4514fe72/log4j-perf/src/main/resources/perf5AsyncApndDsrptrNoLoc-noOpAppender.xml ---------------------------------------------------------------------- diff --git a/log4j-perf/src/main/resources/perf5AsyncApndDsrptrNoLoc-noOpAppender.xml b/log4j-perf/src/main/resources/perf5AsyncApndDsrptrNoLoc-noOpAppender.xml new file mode 100644 index 0000000..cc8d450 --- /dev/null +++ b/log4j-perf/src/main/resources/perf5AsyncApndDsrptrNoLoc-noOpAppender.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache license, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the license for the specific language governing permissions and + limitations under the license. + --> +<Configuration status="OFF"> + <Appenders> + <CountingNoOp name="NoOp"> + </CountingNoOp> + <Async name="Async" blocking="true" bufferSize="262144"> + <appender-ref ref="NoOp"/> + <DisruptorBlockingQueue/> + </Async> + </Appenders> + <Loggers> + <Root level="info" includeLocation="false"> + <appender-ref ref="Async"/> + </Root> + </Loggers> +</Configuration> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4514fe72/log4j-perf/src/main/resources/perf5AsyncApndNoLoc-noOpAppender.xml ---------------------------------------------------------------------- diff --git a/log4j-perf/src/main/resources/perf5AsyncApndNoLoc-noOpAppender.xml b/log4j-perf/src/main/resources/perf5AsyncApndNoLoc-noOpAppender.xml index a183691..0d062b1 100644 --- a/log4j-perf/src/main/resources/perf5AsyncApndNoLoc-noOpAppender.xml +++ b/log4j-perf/src/main/resources/perf5AsyncApndNoLoc-noOpAppender.xml @@ -21,6 +21,7 @@ </CountingNoOp> <Async name="Async" blocking="true" bufferSize="262144"> <appender-ref ref="NoOp"/> + <ArrayBlockingQueue/> </Async> </Appenders> <Loggers> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4514fe72/log4j-perf/src/main/resources/perf5AsyncApndXferQNoLoc-noOpAppender.xml ---------------------------------------------------------------------- diff --git a/log4j-perf/src/main/resources/perf5AsyncApndXferQNoLoc-noOpAppender.xml b/log4j-perf/src/main/resources/perf5AsyncApndXferQNoLoc-noOpAppender.xml new file mode 100644 index 0000000..e1c7639 --- /dev/null +++ b/log4j-perf/src/main/resources/perf5AsyncApndXferQNoLoc-noOpAppender.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache license, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the license for the specific language governing permissions and + limitations under the license. + --> +<Configuration status="OFF"> + <Appenders> + <CountingNoOp name="NoOp"> + </CountingNoOp> + <Async name="Async" blocking="true" bufferSize="262144"> + <appender-ref ref="NoOp"/> + <LinkedTransferQueue/> + </Async> + </Appenders> + <Loggers> + <Root level="info" includeLocation="false"> + <appender-ref ref="Async"/> + </Root> + </Loggers> +</Configuration>