-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the perf-tools wiki!
This is a simple tool to generate btrace script to profile all public method of a specific class . With btrace, we can profile a class method with the following code: ` @TLS private static long startTime;
@OnMethod(clazz = "org.apache.hadoop.mapred.JobTracker", method = "getInfoPort")
public static void onCall_getInfoPort() {
startTime = timeMillis();
}
@OnMethod(clazz = "org.apache.hadoop.mapred.JobTracker", method = "getInfoPort", location = @Location(Kind.RETURN))
public static void onReturn_getInfoPort() {
print(strcat(str(timeMillis()),
" org.apache.hadoop.mapred.JobTracker#getInfoPort"));
println(strcat(":(ms) ", str(timeMillis() - startTime)));
}
`
What if there's dozens of methods of the class? Can this tiring job done by another tool? Yes, the perf-tool is what you'r looking for. With the full class name you want to profile and the jar file location or the class file location, the tool will generate the script for you .
check out the source code and execute sh install_local.sh (make sure the maven is installed and the BTRACE_HOME is set.)
execute sh $BTRACE_HOME/bin/generate_perf_script.sh to see the help information.
execute btrace $PID $your_generated_script_location to see the profiled result. #example Here's an example to profile the hadoop jobtracker using this tool.
hadoop@arch-server:~$ generate_perf_script.sh org.apache.hadoop.mapred.JobTracker hadoop/hadoop-0.20.2-core.jar .
The script is generated as JobTracker_Script.java : hadoop@arch-server:~$ ls JobTracker_Script.java -la -rw-r--r-- 1 hadoop hadoop 34833 2011-06-19 16:53 JobTracker_Script.java
hadoop@arch-server:~$ jps|grep JobTracker 26545 JobTracker
hadoop@arch-server:~$ btrace 26545 JobTracker_Script.java
1308473766502 org.apache.hadoop.mapred.JobTracker#getTaskTracker:(ms) 1
1308473766503 org.apache.hadoop.mapred.JobTracker#getClusterStatus:(ms) 0
1308473766503 org.apache.hadoop.mapred.JobTracker#getClusterStatus:(ms) 0
1308473766503 org.apache.hadoop.mapred.JobTracker#getNumberOfUniqueHosts:(ms) 0
1308473766503 org.apache.hadoop.mapred.JobTracker#getClusterStatus:(ms) 0
1308473766503 org.apache.hadoop.mapred.JobTracker#getClusterStatus:(ms) 0
1308473766503 org.apache.hadoop.mapred.JobTracker#getClusterStatus:(ms) 0
1308473766503 org.apache.hadoop.mapred.JobTracker#getClusterStatus:(ms) 0
1308473766503 org.apache.hadoop.mapred.JobTracker#getNextHeartbeatInterval:(ms) 0
1308473766503 org.apache.hadoop.mapred.JobTracker#heartbeat:(ms) 0
the output line : ' 1308473766502 org.apache.hadoop.mapred.JobTracker#getTaskTracker:(ms) 1 ' means : at 1308473766502, class: org.apache.hadoop.mapred.JobTracker, method: getTaskTracker is invoked, cost: 1 milisencond.