You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "gerlowskija (via GitHub)" <gi...@apache.org> on 2023/02/22 19:28:35 UTC

[GitHub] [solr] gerlowskija opened a new pull request, #1377: SOLR-16680: Add JMH benchmark for Solr startup

gerlowskija opened a new pull request, #1377:
URL: https://github.com/apache/solr/pull/1377

   https://issues.apache.org/jira/browse/SOLR-16680
   
   # Description
   
   Solr has a benchmarking module built around an integration with JMH.  But it doesn't have a ton of benchmarks to run quite yet.
   
   # Solution
   
   This PR adds a JMH benchmark that attempts to measure Solr Startup, by using the JettySolrRunner test-framework class.
   
   # Tests
   
   N/A
   
   # Checklist
   
   Please review the following and check all that apply:
   
   - [x] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/solr/HowToContribute) and my code conforms to the standards described there to the best of my ability.
   - [x] I have created a Jira issue and added the issue ID to my pull request title.
   - [x] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended)
   - [x] I have developed this patch against the `main` branch.
   - [ ] I have run `./gradlew check`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] risdenk commented on a diff in pull request #1377: SOLR-16680: Add JMH benchmark for Solr startup

Posted by "risdenk (via GitHub)" <gi...@apache.org>.
risdenk commented on code in PR #1377:
URL: https://github.com/apache/solr/pull/1377#discussion_r1114861555


##########
solr/benchmark/src/java/org/apache/solr/bench/lifecycle/SolrStartup.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.solr.bench.lifecycle;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.io.FileUtils;
+import org.apache.lucene.util.IOUtils;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.request.CoreAdminRequest;
+import org.apache.solr.client.solrj.response.CoreAdminResponse;
+import org.apache.solr.embedded.JettyConfig;
+import org.apache.solr.embedded.JettySolrRunner;
+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.Threads;
+
+/**
+ * A simple JMH benchmark that attempts to measure approximate Solr startup behavior by measuring
+ * {@link JettySolrRunner#start()}
+ */
+@BenchmarkMode(Mode.Throughput)
+@OutputTimeUnit(TimeUnit.SECONDS)
+@Measurement(time = 60, iterations = 10)
+@Threads(3)
+@Fork(value = 1)
+public class SolrStartup {
+
+  @Benchmark
+  public void startSolr(PerThreadState threadState) throws Exception {
+    threadState.solrRunner.start(
+        false); // 'false' tells Jetty to not go out of its way to reuse any previous ports

Review Comment:
   nit: move the comment to line above to fix line break



##########
solr/benchmark/src/java/org/apache/solr/bench/lifecycle/SolrStartup.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.solr.bench.lifecycle;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.io.FileUtils;
+import org.apache.lucene.util.IOUtils;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.request.CoreAdminRequest;
+import org.apache.solr.client.solrj.response.CoreAdminResponse;
+import org.apache.solr.embedded.JettyConfig;
+import org.apache.solr.embedded.JettySolrRunner;
+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.Threads;
+
+/**
+ * A simple JMH benchmark that attempts to measure approximate Solr startup behavior by measuring
+ * {@link JettySolrRunner#start()}
+ */
+@BenchmarkMode(Mode.Throughput)
+@OutputTimeUnit(TimeUnit.SECONDS)
+@Measurement(time = 60, iterations = 10)
+@Threads(3)
+@Fork(value = 1)
+public class SolrStartup {
+
+  @Benchmark
+  public void startSolr(PerThreadState threadState) throws Exception {
+    threadState.solrRunner.start(
+        false); // 'false' tells Jetty to not go out of its way to reuse any previous ports
+  }
+
+  @State(Scope.Thread)
+  public static class PerThreadState {
+
+    private static final int NUM_CORES = 10;
+
+    public File tmpSolrHome;

Review Comment:
   I think it simplifies things to leave `tmpSolrHome` as a `Path` and not convert it to a file?
   
   There are things like `PathUtils` in commons-io if needed 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] gerlowskija commented on a diff in pull request #1377: SOLR-16680: Add JMH benchmark for Solr startup

Posted by "gerlowskija (via GitHub)" <gi...@apache.org>.
gerlowskija commented on code in PR #1377:
URL: https://github.com/apache/solr/pull/1377#discussion_r1114897492


##########
solr/benchmark/src/java/org/apache/solr/bench/lifecycle/SolrStartup.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.solr.bench.lifecycle;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.io.FileUtils;
+import org.apache.lucene.util.IOUtils;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.request.CoreAdminRequest;
+import org.apache.solr.client.solrj.response.CoreAdminResponse;
+import org.apache.solr.embedded.JettyConfig;
+import org.apache.solr.embedded.JettySolrRunner;
+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.Threads;
+
+/**
+ * A simple JMH benchmark that attempts to measure approximate Solr startup behavior by measuring
+ * {@link JettySolrRunner#start()}
+ */
+@BenchmarkMode(Mode.Throughput)
+@OutputTimeUnit(TimeUnit.SECONDS)
+@Measurement(time = 60, iterations = 10)
+@Threads(3)
+@Fork(value = 1)
+public class SolrStartup {
+
+  @Benchmark
+  public void startSolr(PerThreadState threadState) throws Exception {
+    threadState.solrRunner.start(
+        false); // 'false' tells Jetty to not go out of its way to reuse any previous ports
+  }
+
+  @State(Scope.Thread)
+  public static class PerThreadState {
+
+    private static final int NUM_CORES = 10;
+
+    public File tmpSolrHome;

Review Comment:
   IMO it's a bit of a wash either way.  JettySolrRunner and other objects have ctors and methods that require a string or File, so even with the change there's an ugly amount of object conversion.  Boy, I just hate working with files in Java.
   
   But, "done".



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] risdenk commented on a diff in pull request #1377: SOLR-16680: Add JMH benchmark for Solr startup

Posted by "risdenk (via GitHub)" <gi...@apache.org>.
risdenk commented on code in PR #1377:
URL: https://github.com/apache/solr/pull/1377#discussion_r1114900274


##########
solr/benchmark/src/java/org/apache/solr/bench/lifecycle/SolrStartup.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.solr.bench.lifecycle;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.io.FileUtils;
+import org.apache.lucene.util.IOUtils;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.request.CoreAdminRequest;
+import org.apache.solr.client.solrj.response.CoreAdminResponse;
+import org.apache.solr.embedded.JettyConfig;
+import org.apache.solr.embedded.JettySolrRunner;
+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.Threads;
+
+/**
+ * A simple JMH benchmark that attempts to measure approximate Solr startup behavior by measuring
+ * {@link JettySolrRunner#start()}
+ */
+@BenchmarkMode(Mode.Throughput)
+@OutputTimeUnit(TimeUnit.SECONDS)
+@Measurement(time = 60, iterations = 10)
+@Threads(3)
+@Fork(value = 1)
+public class SolrStartup {
+
+  @Benchmark
+  public void startSolr(PerThreadState threadState) throws Exception {
+    threadState.solrRunner.start(
+        false); // 'false' tells Jetty to not go out of its way to reuse any previous ports
+  }
+
+  @State(Scope.Thread)
+  public static class PerThreadState {
+
+    private static final int NUM_CORES = 10;
+
+    public File tmpSolrHome;

Review Comment:
   @madrob had made quite a bit of progress converting from File -> Path. One example is https://issues.apache.org/jira/browse/SOLR-15919 so trying not to go backwards. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] gerlowskija commented on pull request #1377: SOLR-16680: Add JMH benchmark for Solr startup

Posted by "gerlowskija (via GitHub)" <gi...@apache.org>.
gerlowskija commented on PR #1377:
URL: https://github.com/apache/solr/pull/1377#issuecomment-1440732740

   FYI @noblepaul , I know you'd expressed interest in this following the last virtual meetup.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] risdenk commented on a diff in pull request #1377: SOLR-16680: Add JMH benchmark for Solr startup

Posted by "risdenk (via GitHub)" <gi...@apache.org>.
risdenk commented on code in PR #1377:
URL: https://github.com/apache/solr/pull/1377#discussion_r1114901342


##########
solr/benchmark/src/java/org/apache/solr/bench/lifecycle/SolrStartup.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.solr.bench.lifecycle;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.io.file.PathUtils;
+import org.apache.lucene.util.IOUtils;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.request.CoreAdminRequest;
+import org.apache.solr.client.solrj.response.CoreAdminResponse;
+import org.apache.solr.embedded.JettyConfig;
+import org.apache.solr.embedded.JettySolrRunner;
+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.Threads;
+
+/**
+ * A simple JMH benchmark that attempts to measure approximate Solr startup behavior by measuring
+ * {@link JettySolrRunner#start()}
+ */
+@BenchmarkMode(Mode.Throughput)
+@OutputTimeUnit(TimeUnit.SECONDS)
+@Measurement(time = 60, iterations = 10)
+@Threads(3)
+@Fork(value = 1)
+public class SolrStartup {
+
+  @Benchmark
+  public void startSolr(PerThreadState threadState) throws Exception {
+    // 'false' tells Jetty to not go out of its way to reuse any previous ports
+    threadState.solrRunner.start(false);
+  }
+
+  @State(Scope.Thread)
+  public static class PerThreadState {
+
+    private static final int NUM_CORES = 10;
+
+    public Path tmpSolrHome;
+    public JettySolrRunner solrRunner;
+
+    @Setup(Level.Trial)
+    public void bootstrapJettyServer() throws Exception {
+      tmpSolrHome = Files.createTempDirectory("solrstartup-perthreadstate-jsr").toAbsolutePath();
+
+      final Path configsetsDir = Path.of(tmpSolrHome.toString(), "configsets");
+      final Path defaultConfigsetDir = Path.of(configsetsDir.toString(), "defaultConfigSet");
+      Files.createDirectories(defaultConfigsetDir);
+      PathUtils.copyDirectory(
+          Path.of("src/resources/configs/minimal/conf"),
+          Path.of(defaultConfigsetDir.toString(), "/conf"));

Review Comment:
   ```suggestion
             defaultConfigsetDir.resolve("conf"));
   ```



##########
solr/benchmark/src/java/org/apache/solr/bench/lifecycle/SolrStartup.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.solr.bench.lifecycle;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.io.file.PathUtils;
+import org.apache.lucene.util.IOUtils;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.request.CoreAdminRequest;
+import org.apache.solr.client.solrj.response.CoreAdminResponse;
+import org.apache.solr.embedded.JettyConfig;
+import org.apache.solr.embedded.JettySolrRunner;
+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.Threads;
+
+/**
+ * A simple JMH benchmark that attempts to measure approximate Solr startup behavior by measuring
+ * {@link JettySolrRunner#start()}
+ */
+@BenchmarkMode(Mode.Throughput)
+@OutputTimeUnit(TimeUnit.SECONDS)
+@Measurement(time = 60, iterations = 10)
+@Threads(3)
+@Fork(value = 1)
+public class SolrStartup {
+
+  @Benchmark
+  public void startSolr(PerThreadState threadState) throws Exception {
+    // 'false' tells Jetty to not go out of its way to reuse any previous ports
+    threadState.solrRunner.start(false);
+  }
+
+  @State(Scope.Thread)
+  public static class PerThreadState {
+
+    private static final int NUM_CORES = 10;
+
+    public Path tmpSolrHome;
+    public JettySolrRunner solrRunner;
+
+    @Setup(Level.Trial)
+    public void bootstrapJettyServer() throws Exception {
+      tmpSolrHome = Files.createTempDirectory("solrstartup-perthreadstate-jsr").toAbsolutePath();
+
+      final Path configsetsDir = Path.of(tmpSolrHome.toString(), "configsets");
+      final Path defaultConfigsetDir = Path.of(configsetsDir.toString(), "defaultConfigSet");

Review Comment:
   ```suggestion
         final Path defaultConfigsetDir = configsetsDir.resolve("defaultConfigSet");
   ```



##########
solr/benchmark/src/java/org/apache/solr/bench/lifecycle/SolrStartup.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.solr.bench.lifecycle;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.io.file.PathUtils;
+import org.apache.lucene.util.IOUtils;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.request.CoreAdminRequest;
+import org.apache.solr.client.solrj.response.CoreAdminResponse;
+import org.apache.solr.embedded.JettyConfig;
+import org.apache.solr.embedded.JettySolrRunner;
+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.Threads;
+
+/**
+ * A simple JMH benchmark that attempts to measure approximate Solr startup behavior by measuring
+ * {@link JettySolrRunner#start()}
+ */
+@BenchmarkMode(Mode.Throughput)
+@OutputTimeUnit(TimeUnit.SECONDS)
+@Measurement(time = 60, iterations = 10)
+@Threads(3)
+@Fork(value = 1)
+public class SolrStartup {
+
+  @Benchmark
+  public void startSolr(PerThreadState threadState) throws Exception {
+    // 'false' tells Jetty to not go out of its way to reuse any previous ports
+    threadState.solrRunner.start(false);
+  }
+
+  @State(Scope.Thread)
+  public static class PerThreadState {
+
+    private static final int NUM_CORES = 10;
+
+    public Path tmpSolrHome;
+    public JettySolrRunner solrRunner;
+
+    @Setup(Level.Trial)
+    public void bootstrapJettyServer() throws Exception {
+      tmpSolrHome = Files.createTempDirectory("solrstartup-perthreadstate-jsr").toAbsolutePath();
+
+      final Path configsetsDir = Path.of(tmpSolrHome.toString(), "configsets");

Review Comment:
   ```suggestion
         final Path configsetsDir = tmpSolrHome.resolve("configsets");
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] gerlowskija merged pull request #1377: SOLR-16680: Add JMH benchmark for Solr startup

Posted by "gerlowskija (via GitHub)" <gi...@apache.org>.
gerlowskija merged PR #1377:
URL: https://github.com/apache/solr/pull/1377


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org