[GitHub] geode pull request #450: GEODE-2632: create ClientCachePutBench
Github user kirklund closed the pull request at: https://github.com/apache/geode/pull/450 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] geode pull request #450: GEODE-2632: create ClientCachePutBench
Github user kirklund commented on a diff in the pull request: https://github.com/apache/geode/pull/450#discussion_r112522440 --- Diff: geode-core/src/jmh/java/org/apache/geode/internal/cache/tier/sockets/command/ClientCachePutBench.java --- @@ -0,0 +1,233 @@ +/* + * 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. + */ +package org.apache.geode.internal.cache.tier.sockets.command; + +import static java.lang.System.*; +import static java.util.concurrent.TimeUnit.*; +import static org.apache.commons.io.FileUtils.*; +import static org.apache.commons.lang.StringUtils.*; +import static org.apache.geode.cache.client.ClientRegionShortcut.*; +import static org.apache.geode.distributed.AbstractLauncher.Status.*; +import static org.apache.geode.distributed.ConfigurationProperties.*; +import static org.apache.geode.distributed.internal.DistributionConfig.*; +import static org.apache.geode.internal.AvailablePort.*; +import static org.apache.geode.test.dunit.NetworkUtils.*; +import static org.assertj.core.api.Assertions.*; +import static org.awaitility.Awaitility.*; + +import org.apache.geode.cache.Region; +import org.apache.geode.cache.client.ClientCache; +import org.apache.geode.cache.client.ClientCacheFactory; +import org.apache.geode.distributed.ServerLauncher; +import org.apache.geode.internal.process.ProcessStreamReader; +import org.junit.rules.TemporaryFolder; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Warmup; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +/** + * Benchmark that measures throughput of single-threaded client performing puts to a loner server. + * + * 100 random keys and values are generated during setup and the client reuses these in order, + * looping back around after 100 puts. + */ +@Measurement(iterations = 3, time = 2, timeUnit = MINUTES) +@Warmup(iterations = 1, time = 1, timeUnit = MINUTES) +@Fork(3) +@BenchmarkMode(Mode.Throughput) +@OutputTimeUnit(TimeUnit.SECONDS) +@State(Scope.Thread) +@SuppressWarnings("unused") +public class ClientCachePutBench { + + static final String CLASS_NAME = ClientCachePutBench.class.getSimpleName(); + static final String PACKAGE_NAME = + replace(ClientCachePutBench.class.getPackage().getName(), ".", "/"); + static final String REGION_NAME = CLASS_NAME + "-region"; + static final String SERVER_XML_NAME = "/" + PACKAGE_NAME + "/" + CLASS_NAME + "-server.xml"; + static final long PROCESS_READER_TIMEOUT = 60 * 1000; + static final int NUMBER_OF_KEYS = 100; + static final int NUMBER_OF_VALUES = 100; + + @State(Scope.Benchmark) + public static class ClientState { + +Regionregion; + +String[] keys; +String[] values; + +private int keyIndex = -1; +private int valueIndex = -1; + +private Process process; +private volatile ProcessStreamReader processOutReader; +private volatile ProcessStreamReader processErrReader; + +private int serverPort; +private ServerLauncher launcher; +private File serverDirectory; +private ClientCache clientCache; + +private TemporaryFolder temporaryFolder = new TemporaryFolder(); + +@Setup(Level.Trial) +public void startServer() throws Exception { +
[GitHub] geode pull request #450: GEODE-2632: create ClientCachePutBench
Github user galen-pivotal commented on a diff in the pull request: https://github.com/apache/geode/pull/450#discussion_r112004128 --- Diff: geode-core/src/jmh/java/org/apache/geode/internal/cache/tier/sockets/command/ClientCachePutBench.java --- @@ -0,0 +1,233 @@ +/* + * 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. + */ +package org.apache.geode.internal.cache.tier.sockets.command; + +import static java.lang.System.*; +import static java.util.concurrent.TimeUnit.*; +import static org.apache.commons.io.FileUtils.*; +import static org.apache.commons.lang.StringUtils.*; +import static org.apache.geode.cache.client.ClientRegionShortcut.*; +import static org.apache.geode.distributed.AbstractLauncher.Status.*; +import static org.apache.geode.distributed.ConfigurationProperties.*; +import static org.apache.geode.distributed.internal.DistributionConfig.*; +import static org.apache.geode.internal.AvailablePort.*; +import static org.apache.geode.test.dunit.NetworkUtils.*; +import static org.assertj.core.api.Assertions.*; +import static org.awaitility.Awaitility.*; + +import org.apache.geode.cache.Region; +import org.apache.geode.cache.client.ClientCache; +import org.apache.geode.cache.client.ClientCacheFactory; +import org.apache.geode.distributed.ServerLauncher; +import org.apache.geode.internal.process.ProcessStreamReader; +import org.junit.rules.TemporaryFolder; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Warmup; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +/** + * Benchmark that measures throughput of single-threaded client performing puts to a loner server. + * + * 100 random keys and values are generated during setup and the client reuses these in order, + * looping back around after 100 puts. + */ +@Measurement(iterations = 3, time = 2, timeUnit = MINUTES) +@Warmup(iterations = 1, time = 1, timeUnit = MINUTES) +@Fork(3) +@BenchmarkMode(Mode.Throughput) +@OutputTimeUnit(TimeUnit.SECONDS) +@State(Scope.Thread) --- End diff -- Does `ClientCachePutBench` need to be `State` when it's only got statics? --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] geode pull request #450: GEODE-2632: create ClientCachePutBench
Github user galen-pivotal commented on a diff in the pull request: https://github.com/apache/geode/pull/450#discussion_r112005541 --- Diff: geode-core/src/jmh/java/org/apache/geode/internal/cache/tier/sockets/command/ClientCachePutBench.java --- @@ -0,0 +1,233 @@ +/* + * 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. + */ +package org.apache.geode.internal.cache.tier.sockets.command; + +import static java.lang.System.*; +import static java.util.concurrent.TimeUnit.*; +import static org.apache.commons.io.FileUtils.*; +import static org.apache.commons.lang.StringUtils.*; +import static org.apache.geode.cache.client.ClientRegionShortcut.*; +import static org.apache.geode.distributed.AbstractLauncher.Status.*; +import static org.apache.geode.distributed.ConfigurationProperties.*; +import static org.apache.geode.distributed.internal.DistributionConfig.*; +import static org.apache.geode.internal.AvailablePort.*; +import static org.apache.geode.test.dunit.NetworkUtils.*; +import static org.assertj.core.api.Assertions.*; +import static org.awaitility.Awaitility.*; + +import org.apache.geode.cache.Region; +import org.apache.geode.cache.client.ClientCache; +import org.apache.geode.cache.client.ClientCacheFactory; +import org.apache.geode.distributed.ServerLauncher; +import org.apache.geode.internal.process.ProcessStreamReader; +import org.junit.rules.TemporaryFolder; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Warmup; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +/** + * Benchmark that measures throughput of single-threaded client performing puts to a loner server. + * + * 100 random keys and values are generated during setup and the client reuses these in order, + * looping back around after 100 puts. + */ +@Measurement(iterations = 3, time = 2, timeUnit = MINUTES) +@Warmup(iterations = 1, time = 1, timeUnit = MINUTES) +@Fork(3) +@BenchmarkMode(Mode.Throughput) +@OutputTimeUnit(TimeUnit.SECONDS) +@State(Scope.Thread) +@SuppressWarnings("unused") +public class ClientCachePutBench { + + static final String CLASS_NAME = ClientCachePutBench.class.getSimpleName(); + static final String PACKAGE_NAME = + replace(ClientCachePutBench.class.getPackage().getName(), ".", "/"); + static final String REGION_NAME = CLASS_NAME + "-region"; + static final String SERVER_XML_NAME = "/" + PACKAGE_NAME + "/" + CLASS_NAME + "-server.xml"; + static final long PROCESS_READER_TIMEOUT = 60 * 1000; + static final int NUMBER_OF_KEYS = 100; + static final int NUMBER_OF_VALUES = 100; + + @State(Scope.Benchmark) + public static class ClientState { + +Regionregion; + +String[] keys; +String[] values; + +private int keyIndex = -1; +private int valueIndex = -1; + +private Process process; +private volatile ProcessStreamReader processOutReader; +private volatile ProcessStreamReader processErrReader; + +private int serverPort; +private ServerLauncher launcher; +private File serverDirectory; +private ClientCache clientCache; + +private TemporaryFolder temporaryFolder = new TemporaryFolder(); + +@Setup(Level.Trial) +public void startServer() throws Exception {
[GitHub] geode pull request #450: GEODE-2632: create ClientCachePutBench
Github user galen-pivotal commented on a diff in the pull request: https://github.com/apache/geode/pull/450#discussion_r112005377 --- Diff: geode-core/src/jmh/java/org/apache/geode/internal/cache/tier/sockets/command/ClientCachePutBench.java --- @@ -0,0 +1,233 @@ +/* + * 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. + */ +package org.apache.geode.internal.cache.tier.sockets.command; + +import static java.lang.System.*; +import static java.util.concurrent.TimeUnit.*; +import static org.apache.commons.io.FileUtils.*; +import static org.apache.commons.lang.StringUtils.*; +import static org.apache.geode.cache.client.ClientRegionShortcut.*; +import static org.apache.geode.distributed.AbstractLauncher.Status.*; +import static org.apache.geode.distributed.ConfigurationProperties.*; +import static org.apache.geode.distributed.internal.DistributionConfig.*; +import static org.apache.geode.internal.AvailablePort.*; +import static org.apache.geode.test.dunit.NetworkUtils.*; +import static org.assertj.core.api.Assertions.*; +import static org.awaitility.Awaitility.*; + +import org.apache.geode.cache.Region; +import org.apache.geode.cache.client.ClientCache; +import org.apache.geode.cache.client.ClientCacheFactory; +import org.apache.geode.distributed.ServerLauncher; +import org.apache.geode.internal.process.ProcessStreamReader; +import org.junit.rules.TemporaryFolder; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Warmup; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +/** + * Benchmark that measures throughput of single-threaded client performing puts to a loner server. + * + * 100 random keys and values are generated during setup and the client reuses these in order, + * looping back around after 100 puts. + */ +@Measurement(iterations = 3, time = 2, timeUnit = MINUTES) +@Warmup(iterations = 1, time = 1, timeUnit = MINUTES) +@Fork(3) +@BenchmarkMode(Mode.Throughput) --- End diff -- Any reason not to use `Mode.All`? --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] geode pull request #450: GEODE-2632: create ClientCachePutBench
Github user kirklund commented on a diff in the pull request: https://github.com/apache/geode/pull/450#discussion_r111505951 --- Diff: geode-core/src/jmh/java/org/apache/geode/internal/cache/tier/sockets/command/ClientCachePutBench.java --- @@ -0,0 +1,199 @@ +/* + * 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. + */ +package org.apache.geode.internal.cache.tier.sockets.command; + +import static java.lang.System.*; +import static java.util.concurrent.TimeUnit.*; +import static org.apache.commons.io.FileUtils.*; +import static org.apache.commons.lang.StringUtils.*; +import static org.apache.geode.cache.client.ClientRegionShortcut.*; +import static org.apache.geode.distributed.AbstractLauncher.Status.*; +import static org.apache.geode.distributed.ConfigurationProperties.*; +import static org.apache.geode.distributed.internal.DistributionConfig.*; +import static org.apache.geode.internal.AvailablePort.*; +import static org.apache.geode.test.dunit.NetworkUtils.*; +import static org.assertj.core.api.Assertions.*; +import static org.awaitility.Awaitility.*; + +import org.apache.geode.cache.Region; +import org.apache.geode.cache.client.ClientCache; +import org.apache.geode.cache.client.ClientCacheFactory; +import org.apache.geode.distributed.ServerLauncher; +import org.apache.geode.internal.process.ProcessStreamReader; +import org.junit.rules.TemporaryFolder; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Warmup; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +/** + * Benchmark that measures throughput of client performing puts to a loner server. + */ +@Measurement(iterations = 3, time = 3, timeUnit = MINUTES) +@Warmup(iterations = 3, time = 1, timeUnit = MINUTES) +@Fork(3) +@BenchmarkMode(Mode.Throughput) +@OutputTimeUnit(TimeUnit.SECONDS) +@State(Scope.Thread) +@SuppressWarnings("unused") +public class ClientCachePutBench { + + static final long PROCESS_READER_TIMEOUT = 60 * 1000; + static final String CLASS_NAME = ClientCachePutBench.class.getSimpleName(); + static final String PACKAGE_NAME = + replace(ClientCachePutBench.class.getPackage().getName(), ".", "/"); + static final String REGION_NAME = CLASS_NAME + "-region"; + static final String SERVER_XML_NAME = "/" + PACKAGE_NAME + "/" + CLASS_NAME + "-server.xml"; + + @State(Scope.Benchmark) + public static class ClientState { + +Random random; +Regionregion; + +private Process process; +private volatile ProcessStreamReader processOutReader; +private volatile ProcessStreamReader processErrReader; + +private int serverPort; +private ServerLauncher launcher; +private File serverDirectory; +private ClientCache clientCache; + +private TemporaryFolder temporaryFolder = new TemporaryFolder(); + +@Setup(Level.Trial) +public void startServer() throws Exception { + System.out.println("\n" + "[ClientCachePutBench] startServer"); + + this.random = new Random(nanoTime()); + + this.temporaryFolder.create(); + this.serverDirectory = this.temporaryFolder.getRoot(); + + startServerProcess(); + + try { +startProcessReaders(); + +ServerLauncher
[GitHub] geode pull request #450: GEODE-2632: create ClientCachePutBench
Github user kirklund commented on a diff in the pull request: https://github.com/apache/geode/pull/450#discussion_r111432477 --- Diff: geode-core/src/jmh/java/org/apache/geode/internal/cache/tier/sockets/command/ClientCachePutBench.java --- @@ -0,0 +1,199 @@ +/* + * 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. + */ +package org.apache.geode.internal.cache.tier.sockets.command; + +import static java.lang.System.*; +import static java.util.concurrent.TimeUnit.*; +import static org.apache.commons.io.FileUtils.*; +import static org.apache.commons.lang.StringUtils.*; +import static org.apache.geode.cache.client.ClientRegionShortcut.*; +import static org.apache.geode.distributed.AbstractLauncher.Status.*; +import static org.apache.geode.distributed.ConfigurationProperties.*; +import static org.apache.geode.distributed.internal.DistributionConfig.*; +import static org.apache.geode.internal.AvailablePort.*; +import static org.apache.geode.test.dunit.NetworkUtils.*; +import static org.assertj.core.api.Assertions.*; +import static org.awaitility.Awaitility.*; + +import org.apache.geode.cache.Region; +import org.apache.geode.cache.client.ClientCache; +import org.apache.geode.cache.client.ClientCacheFactory; +import org.apache.geode.distributed.ServerLauncher; +import org.apache.geode.internal.process.ProcessStreamReader; +import org.junit.rules.TemporaryFolder; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Warmup; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +/** + * Benchmark that measures throughput of client performing puts to a loner server. + */ +@Measurement(iterations = 3, time = 3, timeUnit = MINUTES) +@Warmup(iterations = 3, time = 1, timeUnit = MINUTES) +@Fork(3) +@BenchmarkMode(Mode.Throughput) +@OutputTimeUnit(TimeUnit.SECONDS) +@State(Scope.Thread) +@SuppressWarnings("unused") +public class ClientCachePutBench { + + static final long PROCESS_READER_TIMEOUT = 60 * 1000; + static final String CLASS_NAME = ClientCachePutBench.class.getSimpleName(); + static final String PACKAGE_NAME = + replace(ClientCachePutBench.class.getPackage().getName(), ".", "/"); + static final String REGION_NAME = CLASS_NAME + "-region"; + static final String SERVER_XML_NAME = "/" + PACKAGE_NAME + "/" + CLASS_NAME + "-server.xml"; + + @State(Scope.Benchmark) + public static class ClientState { + +Random random; +Regionregion; + +private Process process; +private volatile ProcessStreamReader processOutReader; +private volatile ProcessStreamReader processErrReader; + +private int serverPort; +private ServerLauncher launcher; +private File serverDirectory; +private ClientCache clientCache; + +private TemporaryFolder temporaryFolder = new TemporaryFolder(); + +@Setup(Level.Trial) +public void startServer() throws Exception { + System.out.println("\n" + "[ClientCachePutBench] startServer"); + + this.random = new Random(nanoTime()); + + this.temporaryFolder.create(); + this.serverDirectory = this.temporaryFolder.getRoot(); + + startServerProcess(); + + try { +startProcessReaders(); + +ServerLauncher
[GitHub] geode pull request #450: GEODE-2632: create ClientCachePutBench
Github user kohlmu-pivotal commented on a diff in the pull request: https://github.com/apache/geode/pull/450#discussion_r111093862 --- Diff: geode-core/src/jmh/java/org/apache/geode/internal/cache/tier/sockets/command/ClientCachePutBench.java --- @@ -0,0 +1,199 @@ +/* + * 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. + */ +package org.apache.geode.internal.cache.tier.sockets.command; + +import static java.lang.System.*; +import static java.util.concurrent.TimeUnit.*; +import static org.apache.commons.io.FileUtils.*; +import static org.apache.commons.lang.StringUtils.*; +import static org.apache.geode.cache.client.ClientRegionShortcut.*; +import static org.apache.geode.distributed.AbstractLauncher.Status.*; +import static org.apache.geode.distributed.ConfigurationProperties.*; +import static org.apache.geode.distributed.internal.DistributionConfig.*; +import static org.apache.geode.internal.AvailablePort.*; +import static org.apache.geode.test.dunit.NetworkUtils.*; +import static org.assertj.core.api.Assertions.*; +import static org.awaitility.Awaitility.*; + +import org.apache.geode.cache.Region; +import org.apache.geode.cache.client.ClientCache; +import org.apache.geode.cache.client.ClientCacheFactory; +import org.apache.geode.distributed.ServerLauncher; +import org.apache.geode.internal.process.ProcessStreamReader; +import org.junit.rules.TemporaryFolder; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Warmup; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +/** + * Benchmark that measures throughput of client performing puts to a loner server. + */ +@Measurement(iterations = 3, time = 3, timeUnit = MINUTES) +@Warmup(iterations = 3, time = 1, timeUnit = MINUTES) +@Fork(3) +@BenchmarkMode(Mode.Throughput) +@OutputTimeUnit(TimeUnit.SECONDS) +@State(Scope.Thread) +@SuppressWarnings("unused") +public class ClientCachePutBench { + + static final long PROCESS_READER_TIMEOUT = 60 * 1000; + static final String CLASS_NAME = ClientCachePutBench.class.getSimpleName(); + static final String PACKAGE_NAME = + replace(ClientCachePutBench.class.getPackage().getName(), ".", "/"); + static final String REGION_NAME = CLASS_NAME + "-region"; + static final String SERVER_XML_NAME = "/" + PACKAGE_NAME + "/" + CLASS_NAME + "-server.xml"; + + @State(Scope.Benchmark) + public static class ClientState { + +Random random; +Regionregion; + +private Process process; +private volatile ProcessStreamReader processOutReader; +private volatile ProcessStreamReader processErrReader; + +private int serverPort; +private ServerLauncher launcher; +private File serverDirectory; +private ClientCache clientCache; + +private TemporaryFolder temporaryFolder = new TemporaryFolder(); + +@Setup(Level.Trial) +public void startServer() throws Exception { + System.out.println("\n" + "[ClientCachePutBench] startServer"); + + this.random = new Random(nanoTime()); + + this.temporaryFolder.create(); + this.serverDirectory = this.temporaryFolder.getRoot(); + + startServerProcess(); + + try { +startProcessReaders(); + +ServerLauncher
[GitHub] geode pull request #450: GEODE-2632: create ClientCachePutBench
GitHub user kirklund opened a pull request: https://github.com/apache/geode/pull/450 GEODE-2632: create ClientCachePutBench * add jmh to geode-core * prevent dunit launching due to static Rule * define ClientCachePutBench to measure throughput of puts from a cache client to a loner server Notes: this is a macro benchmark which uses a Client (in the JMH JVM) and a Server JVM. The intention of this benchmark is to verify that the later changes I make for GEODE-2632 (including refactoring of classes in org.apache.geode.internal.cache.tier.sockets) do not adversely affect performance. Following this commit will be changes to the constructors of some cache client classes and introduction a micro benchmark that directly measures Put65 for improving performance involving its interaction with SecurityService. I added jmh to geode-core because I want to introduce creation of micro benchmarks in the same module and same package(s) as the class(es) being measured. The change to LocatorServerStartupRule.java was necessary because locators and servers scan the org.apache.geode.management.internal.cli.commands package for Spring Shell commands at start-up which forces static initialization of every class in that package. There is at least one dunit test in that same package with a static instance of LocatorServerStartupRule. Because jmh creates its own jar and puts all of the geode-core classes, including tests, in that jar, the constructor of LocatorServerStartupRule will currently cause dunit to launch. Jared is working on an additional change to prevent test classes from being class loaded as potential command classes. I'd like to have this PR reviewed by @bschuchardt @galen-pivotal @kohlmu-pivotal @hiteshk25 @metatype. You can merge this pull request into a Git repository by running: $ git pull https://github.com/kirklund/geode feature/GEODE-2632-ClientCachePutBench Alternatively you can review and apply these changes as the patch at: https://github.com/apache/geode/pull/450.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #450 commit c80daa9aef14503ba10ebacb730e2cd334947c31 Author: Kirk LundDate: 2017-04-11T22:58:26Z GEODE-2632: create ClientCachePutBench * add jmh to geode-core * prevent dunit launching due to static Rule --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---