Skip to content

Commit 4b06089

Browse files
committed
Refactor code
* Move all benchmark relative code into a new benchmark module * Add hadoop style shell scripts for benchmark
1 parent 9c3c87a commit 4b06089

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+659
-165
lines changed

bin/client/clientcommon.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

bin/client/nettyrpc.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

bin/client/nettysimple.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

bin/server/nettyserver.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

bin/server/servercommon.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,16 @@ project(':lightningrpc-common') {
4848

4949
}
5050

51-
5251
project(':lightningrpc-netty') {
5352
dependencies {
5453
compile project(':lightningrpc-common')
5554
compile 'io.netty:netty-all:4.0.29.Final'
5655
}
5756
}
5857

58+
project(':lightningrpc-benchmark') {
59+
dependencies {
60+
compile project(':lightningrpc-netty')
61+
}
62+
}
63+

gradle/convention.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def docTasks = [:]
8989
}
9090

9191
githubPages {
92-
repoUri = "[email protected]:TangoMe/${rootProject.githubProjectName}.git"
92+
repoUri = "[email protected]:coderplay/${rootProject.githubProjectName}.git"
9393
pages {
9494
docTasks.each { shortName, docTask ->
9595
from(docTask.outputs.files) {
@@ -110,12 +110,12 @@ task releaseTarGz(type: Tar, dependsOn: subprojects.assemble) {
110110
into "${baseName}"
111111
compression = Compression.GZIP
112112
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
113-
from(project.file("bin")) { into "bin/" }
114-
from(project.file("conf")) { into "conf/" }
115-
from(project.file("logs")) { into "logs/" }
116113
from 'LICENSE'
117114
from 'README.md'
118115
subprojects.each { child ->
116+
from(child.file("bin")) { into "bin/" }
117+
from(child.file("conf")) { into "conf/" }
118+
from(child.file("logs")) { into "logs/" }
119119
from(child.jar.archivePath)
120120
from(child.configurations.runtime) { into("lib/") }
121121
}

gradle/maven.gradle

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ task uploadMavenCentral(type:Upload, dependsOn: signArchives) {
3939
// Closure to configure all the POM with extra info, common to all projects
4040
pom.project {
4141
name "${project.name}"
42-
description "${project.name} developed by TangoMe"
42+
description "${project.name} developed by Min Zhou"
4343
developers {
4444
developer {
45-
id 'tangogithub'
46-
name 'TangoMe Open Source Development'
47-
45+
id 'mzhou'
46+
name 'Min Zhou Open Source Development'
47+
4848
}
4949
}
5050
licenses {
@@ -54,15 +54,15 @@ task uploadMavenCentral(type:Upload, dependsOn: signArchives) {
5454
distribution 'repo'
5555
}
5656
}
57-
url "https://github.com/TangoMe/${rootProject.githubProjectName}"
57+
url "https://github.com/coderplay/${rootProject.githubProjectName}"
5858
scm {
59-
connection "scm:git:[email protected]:TangoMe/${rootProject.githubProjectName}.git"
60-
url "scm:git:[email protected]:TangoMe/${rootProject.githubProjectName}.git"
61-
developerConnection "scm:git:[email protected]:TangoMe/${rootProject.githubProjectName}.git"
59+
connection "scm:git:[email protected]:coderplay/${rootProject.githubProjectName}.git"
60+
url "scm:git:[email protected]:coderplay/${rootProject.githubProjectName}.git"
61+
developerConnection "scm:git:[email protected]:coderplay/${rootProject.githubProjectName}.git"
6262
}
6363
issueManagement {
6464
system 'github'
65-
url "https://github.com/TangoMe/${rootProject.githubProjectName}/issues"
65+
url "https://github.com/coderplay/${rootProject.githubProjectName}/issues"
6666
}
6767
}
6868
}

gradle/minzhou-oss.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
apply from: 'http://artifacts.minzhou.info/gradle-minzhou-local/artifactory.gradle'

gradle/release.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ apply plugin: 'release'
77
doFirst {
88
startParameter.projectProperties = [status: project.status, preferredStatus: project.status]
99
}
10-
startParameter.addInitScript( file('gradle/tango-oss.gradle') )
10+
startParameter.addInitScript( file('gradle/mzhou-oss.gradle') )
1111
startParameter.getExcludedTaskNames().add('check')
1212
tasks = [ 'build', value ]
1313
}

gradle/tango-oss.gradle

Lines changed: 0 additions & 1 deletion
This file was deleted.

lightningrpc-benchmark/bin/benchmark

Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
#!/usr/bin/env bash
2+
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
19+
20+
# The Benchmark command script
21+
#
22+
# Environment Variables
23+
#
24+
# JAVA_HOME The java implementation to use. Overrides JAVA_HOME.
25+
#
26+
# BENCHMARK_CLASSPATH Extra Java CLASSPATH entries.
27+
#
28+
# BENCHMARK_USER_CLASSPATH_FIRST When defined, the BENCHMARK_CLASSPATH is
29+
# added in the beginning of the global
30+
# classpath. Can be defined, for example,
31+
# by doing
32+
# export BENCHMARK_USER_CLASSPATH_FIRST=true
33+
#
34+
# BENCHMARK_SERVER_HEAPSIZE The maximum amount of heap to use, in MB.
35+
# Default is 1000.
36+
#
37+
# BENCHMARK_CLIENT_HEAPSIZE The maximum amount of heap to use, in MB.
38+
# Default is 1000.
39+
#
40+
# BENCHMARK_OPTS Extra Java runtime options.
41+
#
42+
# BENCHMARK_CONF_DIR Alternate conf dir. Default is ${BENCHMARK_HOME}/conf.
43+
#
44+
#
45+
46+
bin=`dirname "$0"`
47+
bin=`cd "$bin"; pwd`
48+
49+
. "$bin"/benchmark-config.sh
50+
51+
cygwin=false
52+
case "`uname`" in
53+
CYGWIN*) cygwin=true;;
54+
esac
55+
56+
function print_usage() {
57+
echo "Usage: benchmark [--config confdir] COMMAND"
58+
echo "where COMMAND is one of:"
59+
echo " server run the benchmark server"
60+
echo " client run the benchmark rpc client"
61+
echo " simple-client run the benchmark simple client"
62+
echo " classpath prints the class path needed to get the"
63+
echo " Benchmark jar and the required libraries"
64+
echo " or"
65+
echo " CLASSNAME run the class named CLASSNAME"
66+
echo "Most commands print help when invoked w/o parameters."
67+
}
68+
69+
# if no args specified, show usage
70+
if [ $# = 0 ]; then
71+
print_usage
72+
exit 1
73+
fi
74+
75+
# get arguments
76+
COMMAND=$1
77+
shift
78+
79+
if [ "$COMMAND" == "--help" ] || [ "$COMMAND" == "-help" ] || [ "$COMMAND" == "-h" ] ; then
80+
print_usage
81+
exit
82+
fi
83+
84+
if [ -f "${BENCHMARK_CONF_DIR}/benchmark-env.sh" ]; then
85+
. "${BENCHMARK_CONF_DIR}/benchmark-env.sh"
86+
fi
87+
88+
# some Java parameters
89+
if [ "$JAVA_HOME" != "" ]; then
90+
#echo "run java in $JAVA_HOME"
91+
JAVA_HOME=$JAVA_HOME
92+
fi
93+
94+
if [ "$JAVA_HOME" = "" ]; then
95+
echo "Error: JAVA_HOME is not set."
96+
exit 1
97+
fi
98+
99+
JAVA=$JAVA_HOME/bin/java
100+
JAVA_BENCHMARK_SERVER_HEAP_MAX=-Xmx1024m
101+
JAVA_ICF_SERVER_HEAP_MAX=-Xmx1024m
102+
JAVA_CONN_SERVER_HEAP_MAX=-Xmx1024m
103+
104+
# check envvars which might override default args
105+
if [ "$BENCHMARK_SERVER_HEAPSIZE" != "" ]; then
106+
#echo "run with heapsize $BENCHMARK_SERVER_HEAPSIZE"
107+
JAVA_BENCHMARK_SERVER_HEAP_MAX="-Xmx""$BENCHMARK_SERVER_HEAPSIZE""m"
108+
#echo $JAVA_SERVER_HEAP_MAX
109+
fi
110+
if [ "$BENCHMARK_ICF_SERVER_HEAPSIZE" != "" ]; then
111+
#echo "run with heapsize $BENCHMARK_ICF_SERVER_HEAPSIZE"
112+
JAVA_ICF_SERVER_HEAP_MAX="-Xmx""$BENCHMARK_ICF_SERVER_HEAPSIZE""m"
113+
#echo JAVA_ICF_SERVER_HEAP_MAX
114+
fi
115+
if [ "$BENCHMARK_CONN_SERVER_HEAPSIZE" != "" ]; then
116+
#echo "run with heapsize $BENCHMARK_CONN_SERVER_HEAPSIZE"
117+
JAVA_CONN_SERVER_HEAP_MAX="-Xmx""$BENCHMARK_CONN_SERVER_HEAPSIZE""m"
118+
#echo JAVA_CONN_SERVER_HEAP_MAX
119+
fi
120+
121+
##############################################################################
122+
# Find and Set Benchmark CLASSPATH
123+
##############################################################################
124+
125+
# BENCHMARK_BASE_CLASSPATH initially contains $BENCHMARK_CONF_DIR
126+
BENCHMARK_BASE_CLASSPATH="${BENCHMARK_CONF_DIR}"
127+
128+
# for developers, add Benchmark classes to BENCHMARK_BASE_CLASSPATH
129+
if [ -d "$BENCHMARK_HOME/target/classes" ]; then
130+
BENCHMARK_BASE_CLASSPATH=${BENCHMARK_BASE_CLASSPATH}:$BENCHMARK_HOME/target/classes
131+
fi
132+
if [ -d "$BENCHMARK_HOME/target/test/classes" ]; then
133+
BENCHMARK_BASE_CLASSPATH=${BENCHMARK_BASE_CLASSPATH}:$BENCHMARK_HOME/target/test/classes
134+
fi
135+
136+
# so that filenames w/ spaces are handled correctly in loops below
137+
IFS=$'\n'
138+
139+
# Benchmark Jar Directory
140+
BENCHMARK_JAR_DIRS="$BENCHMARK_HOME
141+
${BENCHMARK_HOME}/lib"
142+
143+
for d in $BENCHMARK_JAR_DIRS; do
144+
for j in `find $d/*.jar ! -name "*test*"`; do
145+
BENCHMARK_BASE_CLASSPATH=$BENCHMARK_BASE_CLASSPATH:$j
146+
done
147+
done
148+
149+
# add user-specified CLASSPATH last
150+
if [ "$BENCHMARK_CLASSPATH" != "" ]; then
151+
if [ "$BENCHMARK_USER_CLASSPATH_FIRST" != "" ]; then
152+
BENCHMARK_BASE_CLASSPATH=${BENCHMARK_CLASSPATH}:${BENCHMARK_BASE_CLASSPATH}
153+
else
154+
BENCHMARK_BASE_CLASSPATH=${BENCHMARK_BASE_CLASSPATH}:${BENCHMARK_CLASSPATH}
155+
fi
156+
fi
157+
158+
export BENCHMARK_BASE_CLASSPATH
159+
160+
CLASSPATH="${BENCHMARK_BASE_CLASSPATH}:${CLASSPATH}"
161+
162+
##############################################################################
163+
# Benchmark Home Configuration End
164+
##############################################################################
165+
166+
# restore ordinary behaviour
167+
unset IFS
168+
169+
# default log directory & file
170+
if [ "$BENCHMARK_LOG_DIR" = "" ]; then
171+
BENCHMARK_LOG_DIR="$BENCHMARK_HOME/logs"
172+
fi
173+
if [ "$BENCHMARK_LOGFILE" = "" ]; then
174+
BENCHMARK_LOGFILE='benchmark.log'
175+
fi
176+
177+
# default policy file for service-level authorization
178+
if [ "$BENCHMARK_POLICYFILE" = "" ]; then
179+
BENCHMARK_POLICYFILE="benchmark-policy.xml"
180+
fi
181+
182+
# Disable IPv6 Support for network performance
183+
BENCHMARK_OPTS="$BENCHMARK_OPTS -Djava.net.preferIPv4Stack=true"
184+
185+
# figure out which class to run
186+
if [ "$COMMAND" = "classpath" ] ; then
187+
if $cygwin; then
188+
CLASSPATH=`cygpath -p -w "$CLASSPATH"`
189+
fi
190+
echo $CLASSPATH
191+
exit
192+
elif [ "$COMMAND" = "server" ] ; then
193+
CLASS='info.minzhou.lightning.rpc.netty.benchmark.NettyBenchmarkServer"
194+
BENCHMARK_OPTS="$BENCHMARK_OPTS $JAVA_BENCHMARK_SERVER_HEAP_MAX $BENCHMARK_SERVER_OPTS"
195+
elif [ "$COMMAND" = "client" ] ; then
196+
CLASS="info.minzhou.lightning.rpc.netty.benchmark.NettyRPCBenchmarkClient"
197+
BENCHMARK_OPTS="$BENCHMARK_OPTS $JAVA_CLIENT_HEAP_MAX $BENCHMARK_CLIENT_OPTS"
198+
elif [ "$COMMAND" = "simple-client" ] ; then
199+
CLASS="info.minzhou.lightning.rpc.netty.benchmark.NettySimpleBenchmarkClient"
200+
BENCHMARK_OPTS="$BENCHMARK_OPTS $JAVA_CLIENT_HEAP_MAX $BENCHMARK_CLIENT_OPTS"
201+
elif [ "$COMMAND" = "version" ] ; then
202+
CLASS='info.minzhou.lightning.rpc.VersionInfo'
203+
BENCHMARK_ROOT_LOGGER_APPENDER="${BENCHMARK_ROOT_LOGGER_APPENDER:-NullAppender}"
204+
BENCHMARK_OPTS="$BENCHMARK_OPTS $BENCHMARK_CLI_OPTS"
205+
else
206+
CLASS=$COMMAND
207+
fi
208+
209+
# cygwin path translation
210+
if $cygwin; then
211+
CLASSPATH=`cygpath -p -w "$CLASSPATH"`
212+
BENCHMARK_HOME=`cygpath -w "$BENCHMARK_HOME"`
213+
BENCHMARK_LOG_DIR=`cygpath -w "$BENCHMARK_LOG_DIR"`
214+
TOOL_PATH=`cygpath -p -w "$TOOL_PATH"`
215+
fi
216+
# setup 'java.library.path' for native-benchmark code if necessary
217+
JAVA_LIBRARY_PATH=''
218+
if [ -d "${BENCHMARK_HOME}/build/native" -o -d "${BENCHMARK_HOME}/lib/native" ]; then
219+
JAVA_PLATFORM=`CLASSPATH=${CLASSPATH} ${JAVA} -Xmx32m ${BENCHMARK_JAVA_PLATFORM_OPTS} org.apache.benchmark.util.PlatformName | sed -e "s/ /_/g"`
220+
221+
if [ -d "$BENCHMARK_HOME/build/native" ]; then
222+
JAVA_LIBRARY_PATH=${BENCHMARK_HOME}/build/native/${JAVA_PLATFORM}/lib
223+
fi
224+
225+
if [ -d "${BENCHMARK_HOME}/lib/native" ]; then
226+
if [ "x$JAVA_LIBRARY_PATH" != "x" ]; then
227+
JAVA_LIBRARY_PATH=${JAVA_LIBRARY_PATH}:${BENCHMARK_HOME}/lib/native/${JAVA_PLATFORM}
228+
else
229+
JAVA_LIBRARY_PATH=${BENCHMARK_HOME}/lib/native/${JAVA_PLATFORM}
230+
fi
231+
fi
232+
fi
233+
234+
if [ "x$JAVA_LIBRARY_PATH" != "x" ]; then
235+
JAVA_LIBRARY_PATH=${JAVA_LIBRARY_PATH}:${HDFS_LIBRARY_PATH}
236+
else
237+
JAVA_LIBRARY_PATH=${HDFS_LIBRARY_PATH}
238+
fi
239+
240+
# cygwin path translation
241+
if $cygwin; then
242+
JAVA_LIBRARY_PATH=`cygpath -p "$JAVA_LIBRARY_PATH"`
243+
fi
244+
245+
BENCHMARK_OPTS="$BENCHMARK_OPTS -Dbenchmark.log.dir=$BENCHMARK_LOG_DIR"
246+
BENCHMARK_OPTS="$BENCHMARK_OPTS -Dbenchmark.log.file=$BENCHMARK_LOGFILE"
247+
BENCHMARK_OPTS="$BENCHMARK_OPTS -Dbenchmark.home.dir=$BENCHMARK_HOME"
248+
BENCHMARK_OPTS="$BENCHMARK_OPTS -Dbenchmark.id.str=$BENCHMARK_IDENT_STRING"
249+
BENCHMARK_OPTS="$BENCHMARK_OPTS -Dbenchmark.root.logger.appender=${BENCHMARK_ROOT_LOGGER_APPENDER:-console}"
250+
if [ "x$BENCHMARK_ROOT_LOGGER_LEVEL" != "x" ]; then
251+
BENCHMARK_OPTS="$BENCHMARK_OPTS -Dbenchmark.root.logger.level=${BENCHMARK_ROOT_LOGGER_LEVEL}"
252+
fi
253+
254+
if [ "x$JAVA_LIBRARY_PATH" != "x" ]; then
255+
BENCHMARK_OPTS="$BENCHMARK_OPTS -Djava.library.path=$JAVA_LIBRARY_PATH"
256+
fi
257+
BENCHMARK_OPTS="$BENCHMARK_OPTS -Dbenchmark.policy.file=$BENCHMARK_POLICYFILE"
258+
259+
# run it
260+
export CLASSPATH=$CLASSPATH
261+
exec "$JAVA" -Dproc_$COMMAND $BENCHMARK_OPTS $CLASS $BENCHMARK_DAEMON_MODE "$@"

0 commit comments

Comments
 (0)