markrmiller commented on a change in pull request #214:
URL: https://github.com/apache/solr/pull/214#discussion_r672485138



##########
File path: solr/test-framework/build.gradle
##########
@@ -19,10 +19,131 @@ apply plugin: 'java-library'
 
 description = 'Solr Test Framework'
 
+sourceSets {
+  // Note that just declaring this sourceset creates two configurations.
+  jmh {
+    java.srcDirs = ['src/jmh']
+  }
+}
+
+compileJmhJava {
+  doFirst {
+    options.compilerArgs.remove("-Werror")
+    options.compilerArgs.remove("-proc:none")
+  }
+}
+
+forbiddenApisJmh {
+  bundledSignatures += [
+          'jdk-unsafe',
+          'jdk-deprecated',
+          'jdk-non-portable',
+  ]
+
+  suppressAnnotations += [
+          "**.SuppressForbidden"
+  ]
+}
+
+
+task jmh(type: JavaExec) {
+  dependsOn("jmhClasses")
+  group = "benchmark"
+  main = "org.openjdk.jmh.Main"
+  classpath = sourceSets.jmh.compileClasspath + sourceSets.jmh.runtimeClasspath
+
+  standardOutput(System.out)
+  errorOutput(System.err)
+
+  def include = project.properties.get('include');
+  def exclude = project.properties.get('exclude');
+  def format = project.properties.get('format', 'json');
+  def profilers = project.properties.get('profilers');
+  def jvmArgs = project.properties.get('jvmArgs')
+  def verify = project.properties.get('verify');
+
+  def resultFile = file("build/reports/jmh/result.${format}")
+
+  if (include) {
+    args include
+  }
+  if (exclude) {
+    args '-e', exclude
+  }
+  if (verify != null) {
+    // execute benchmarks with the minimum amount of execution (only to check 
if they are working)
+    println "≥≥ Running in verify mode"
+    args '-f', 1
+    args '-wi', 1
+    args '-i', 1
+  }
+  args '-foe', 'true'   //fail-on-error
+  args '-v', 'NORMAL'   //verbosity [SILENT, NORMAL, EXTRA]
+  if (profilers) {
+    profilers.split(',').each {
+      args '-prof', it
+    }
+  }
+
+  args '-jvmArgsPrepend', '-Xms4g'
+  args '-jvmArgsPrepend', '-Djmh.separateClassLoader=true'
+  args '-jvmArgsPrepend', '-Dlog4j2.is.webapp=false'
+  args '-jvmArgsPrepend', '-Dlog4j2.garbagefreeThreadContextMap=true'
+  args '-jvmArgsPrepend', '-Dlog4j2.enableDirectEncoders=true'
+  args '-jvmArgsPrepend', '-Dlog4j2.enable.threadlocals=true'
+//  args '-jvmArgsPrepend', '-XX:ConcGCThreads=2'
+//  args '-jvmArgsPrepend', '-XX:ParallelGCThreads=3'
+//  args '-jvmArgsPrepend', '-XX:+UseG1GC'
+  args '-jvmArgsPrepend', '-Djetty.insecurerandom=1'
+  args '-jvmArgsPrepend', '-Djava.security.egd=file:/dev/./urandom'
+  args '-jvmArgsPrepend', '-XX:-UseBiasedLocking'
+  args '-jvmArgsPrepend', '-XX:+PerfDisableSharedMem'
+  args '-jvmArgsPrepend', '-XX:+ParallelRefProcEnabled'
+//  args '-jvmArgsPrepend', '-XX:MaxGCPauseMillis=250'
+  args '-jvmArgsPrepend', '-Dsolr.log.dir='
+
+  if (jvmArgs) {
+    for (jvmArg in jvmArgs.split(' ')) {
+      args '-jvmArgsPrepend', jvmArg
+    }
+  }
+
+  args '-rf', format
+  args '-rff', resultFile
+
+  doFirst {
+    // println "\nClasspath:" + jmh.classpath.toList()
+    println "\nExecuting JMH with: $args \n"
+
+    args '-jvmArgsPrepend', '-Djava.class.path='+ toPath(getClasspath().files)
+    resultFile.parentFile.mkdirs()
+  }
+
+  doLast {
+    // jvmArgs "java.class.path", toPath(jmh.classpath)
+  }
+
+}
+
+
+private String toPath(Set<File> classpathUnderTest) {

Review comment:
       I still need to work out if this is still needed. It was needed because 
when running via gradle and using jmh's fork option, the classpath was not 
propagated. I have sense simplified the integration (realizing I was jumping 
hoops because our build was putting in -proc:none for all java compile tasks) 
and I have to double check to make sure this is still necessary.




-- 
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-unsubscr...@solr.apache.org

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



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

Reply via email to