-
Notifications
You must be signed in to change notification settings - Fork 711
Drive JMH benchmarks via Apache Zeppelin. #335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
markrmiller
wants to merge
1
commit into
apache:main
Choose a base branch
from
markrmiller:jmh-zeppelin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.idea | ||
.run | ||
.gradle | ||
build | ||
.classpath | ||
.project | ||
.settings/ | ||
.DS_Store | ||
out | ||
logs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# zeppelin-jmh-interpreter | ||
JMH interpreter for Apache Zeppelin. | ||
|
||
|
||
## Build | ||
|
||
```sh | ||
./gradlew build | ||
``` | ||
|
||
## Deployment | ||
|
||
* Update `$ZEPPELIN_HOME/conf/zeppeln-site.xml` | ||
```xml | ||
<property>' | ||
<name>zeppelin.interpreters</name> | ||
<value>...,org.apache.jmh.JMHInterpreter</value> | ||
</property> | ||
``` | ||
* Create `$ZEPPELIN_HOME/interpreter/jmh` | ||
* Copy interpreter jar in `$ZEPPELIN_HOME/interpreter/jmh` | ||
|
||
|
||
## Configuration | ||
|
||
TODO | ||
<table> | ||
<tr><th>Parameter</th><th>Default value</th><th>Description</th></tr> | ||
</table> | ||
|
||
## How to use | ||
|
||
In Zeppelin, use `%jmh` in a paragraph. | ||
|
||
|
||
Examples: | ||
```javascript | ||
%jmh | ||
|
||
// Display a table | ||
db.zipcodes.find({ "city":"CHICAGO", "state": "IL" }).table() | ||
``` | ||
|
||
## Examples | ||
|
||
|
||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* This file was generated by the Gradle 'init' task. | ||
*/ | ||
|
||
plugins { | ||
id 'java' | ||
id 'maven-publish' | ||
id 'com.github.johnrengelman.shadow' version '6.1.0' | ||
id 'net.nemerosa.versioning' version '2.6.1' | ||
} | ||
|
||
apply plugin: 'com.github.johnrengelman.shadow' | ||
|
||
configurations.all { | ||
resolutionStrategy { | ||
cacheChangingModulesFor 0, 'seconds' | ||
} | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
maven { | ||
url = uri('http://repository.apache.org/snapshots') | ||
} | ||
|
||
maven { | ||
url = uri('https://repo.maven.apache.org/maven2/') | ||
} | ||
maven { | ||
url 'https://repo.maven.apache.org/maven2' | ||
name 'Maven Central' | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation ('org.slf4j:slf4j-api:1.7.32') | ||
implementation 'org.apache.commons:commons-exec:1.3' | ||
implementation 'org.apache.commons:commons-lang3:3.12.0' | ||
implementation 'commons-io:commons-io:2.5' | ||
implementation 'commons-cli:commons-cli:20040117.000000' | ||
implementation 'org.jline:jline-reader:3.20.0' | ||
implementation 'org.apache.commons:commons-csv:1.8' | ||
implementation 'net.openhft:chronicle-map:3.21ea82' // TODO: remove | ||
implementation (group: 'org.apache.solr', name: 'solr-solrj', version: '8.9.0', { | ||
exclude group: "io.netty", module: "*" | ||
exclude group: "org.slf4j", module: "*" | ||
exclude group: "org.eclipse.jetty", module: "*" | ||
}) | ||
implementation ('org.eclipse.jetty:jetty-server:11.0.6' | ||
, { | ||
exclude group: "org.slf4j", module: "*" | ||
}) | ||
implementation ('org.eclipse.jetty:jetty-servlet:11.0.6' | ||
, { | ||
exclude group: "org.slf4j", module: "*" | ||
}) | ||
implementation ('org.eclipse.jetty:jetty-http:11.0.6' | ||
, { | ||
exclude group: "org.slf4j", module: "*" | ||
}) | ||
implementation ('org.eclipse.jetty.http2:http2-common:11.0.6' | ||
, { | ||
exclude group: "org.slf4j", module: "*" | ||
}) | ||
|
||
// compileOnly 'javax.servlet:javax.servlet-api:3.1.0' | ||
|
||
testImplementation 'junit:junit:4.13.2' | ||
compileOnly 'org.apache.zeppelin:zeppelin-interpreter:0.10.1-SNAPSHOT' | ||
testImplementation 'org.apache.zeppelin:zeppelin-interpreter:0.10.1-SNAPSHOT' | ||
testImplementation 'org.apache.zeppelin:zeppelin-common:0.10.1-SNAPSHOT' | ||
testRuntime 'log4j:log4j:1.2.17' | ||
} | ||
|
||
|
||
group = 'jmh' | ||
version = '0.1.0' | ||
description = 'Zeppelin: JMH interpreter' | ||
java.targetCompatibility = JavaVersion.VERSION_11 | ||
|
||
jar { | ||
manifest { | ||
attributes( | ||
'Built-By' : System.properties['user.name'], | ||
'Build-Timestamp': new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()), | ||
'Build-Revision' : versioning.info.commit, | ||
'Created-By' : "Gradle ${gradle.gradleVersion}", | ||
'Build-Jdk' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})", | ||
'Build-OS' : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}" | ||
) | ||
} | ||
} | ||
|
||
shadowJar { | ||
outputs.upToDateWhen { false } | ||
archiveBaseName = 'jmh' | ||
relocate 'org.eclipse.jetty', 'shadow.jetty' | ||
} | ||
|
||
tasks.withType(JavaCompile) { | ||
options.encoding = 'UTF-8' | ||
} |
129 changes: 129 additions & 0 deletions
129
...in-jmh-interpreter/buildSrc/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/* | ||
* 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.lucene.gradle; | ||
|
||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.nio.channels.Channels; | ||
import java.nio.channels.FileChannel; | ||
import java.nio.channels.ReadableByteChannel; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.security.MessageDigest; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.util.EnumSet; | ||
import java.util.Locale; | ||
|
||
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; | ||
import static java.nio.file.StandardOpenOption.APPEND; | ||
|
||
/** | ||
* Standalone class that can be used to download a gradle-wrapper.jar | ||
* <p> | ||
* Has no dependencies outside of standard java libraries | ||
*/ | ||
public class WrapperDownloader { | ||
public static void main(String[] args) { | ||
if (args.length != 1) { | ||
System.err.println("Usage: java WrapperDownloader.java <destination>"); | ||
System.exit(1); | ||
} | ||
|
||
try { | ||
new WrapperDownloader().run(Paths.get(args[0])); | ||
} catch (Exception e) { | ||
System.err.println("ERROR: " + e.getMessage()); | ||
System.exit(1); | ||
} | ||
} | ||
|
||
public void run(Path destination) throws IOException, NoSuchAlgorithmException { | ||
Path checksumPath = destination.resolveSibling(destination.getFileName().toString() + ".sha256"); | ||
if (!Files.exists(checksumPath)) { | ||
throw new IOException("Checksum file not found: " + checksumPath); | ||
} | ||
String expectedChecksum = Files.readString(checksumPath, StandardCharsets.UTF_8).trim(); | ||
|
||
Path versionPath = destination.resolveSibling(destination.getFileName().toString() + ".version"); | ||
if (!Files.exists(versionPath)) { | ||
throw new IOException("Wrapper version file not found: " + versionPath); | ||
} | ||
String wrapperVersion = Files.readString(versionPath, StandardCharsets.UTF_8).trim(); | ||
|
||
MessageDigest digest = MessageDigest.getInstance("SHA-256"); | ||
|
||
if (Files.exists(destination)) { | ||
if (checksum(digest, destination).equalsIgnoreCase(expectedChecksum)) { | ||
// File exists, checksum matches, good to go! | ||
return; | ||
} else { | ||
System.err.println("Checksum mismatch, will attempt to re-download gradle-wrapper.jar"); | ||
System.out.println(destination); | ||
Files.delete(destination); | ||
} | ||
} | ||
|
||
URL url = new URL("https://github.com/gradle/gradle/raw/v" + wrapperVersion + "/gradle/wrapper/gradle-wrapper.jar"); | ||
System.err.println("Downloading gradle-wrapper.jar from " + url); | ||
|
||
// As of v6.0.1 the wrapper is approximately 60K | ||
// Can increase this if gradle wrapper ever goes beyond 500K, but keep a safety check | ||
final int maxSize = 512 * 1024; | ||
|
||
// Zero-copy save the jar to a temp file | ||
Path temp = Files.createTempFile(destination.getParent(), ".gradle-wrapper", ".tmp"); | ||
try { | ||
try (ReadableByteChannel in = Channels.newChannel(url.openStream()); | ||
FileChannel out = FileChannel.open(temp, EnumSet.of(APPEND))) { | ||
out.transferFrom(in, 0, maxSize); | ||
} catch (IOException e) { | ||
throw new IOException("Could not download gradle-wrapper.jar (" + e.getMessage() + ")."); | ||
} | ||
|
||
String checksum = checksum(digest, temp); | ||
if (!checksum.equalsIgnoreCase(expectedChecksum)) { | ||
throw new IOException(String.format(Locale.ROOT, | ||
"Checksum mismatch on downloaded gradle-wrapper.jar (was: %s, expected: %s).", | ||
checksum, | ||
expectedChecksum)); | ||
} | ||
|
||
Files.move(temp, destination, REPLACE_EXISTING); | ||
temp = null; | ||
} finally { | ||
if (temp != null) { | ||
Files.deleteIfExists(temp); | ||
} | ||
} | ||
} | ||
|
||
private String checksum(MessageDigest messageDigest, Path path) throws IOException { | ||
try { | ||
char[] hex = "0123456789abcdef".toCharArray(); | ||
byte[] digest = messageDigest.digest(Files.readAllBytes(path)); | ||
StringBuilder sb = new StringBuilder(); | ||
for (byte b : digest) { | ||
sb.append(hex[(b >> 4) & 0xf]).append(hex[b & 0xf]); | ||
} | ||
return sb.toString(); | ||
} catch (IOException e) { | ||
throw new IOException("Could not compute digest of file: " + path + " (" + e.getMessage() + ")"); | ||
} | ||
} | ||
} |
Binary file not shown.
1 change: 1 addition & 0 deletions
1
zeppelin-jmh-interpreter/gradle/wrapper/gradle-wrapper.jar.sha256
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
e996d452d2645e70c01c11143ca2d3742734a28da2bf61f25c82bdc288c9e637 |
1 change: 1 addition & 0 deletions
1
zeppelin-jmh-interpreter/gradle/wrapper/gradle-wrapper.jar.version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6.8.3 |
5 changes: 5 additions & 0 deletions
5
zeppelin-jmh-interpreter/gradle/wrapper/gradle-wrapper.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Severe OSS Vulnerability:
pkg:maven/org.apache.solr/solr-solrj@8.9.0
0 Critical, 1 Severe, 0 Moderate, 0 Unknown vulnerabilities have been found across 1 dependencies
Components
pkg:maven/org.apache.httpcomponents/httpclient@4.5.12
SEVERE Vulnerabilities (1)