Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 8fbae1d10 -> 8bef9e6dc
PHOENIX-2343 Pherf - Add ability to draw comparison chart with average query run time Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/8bef9e6d Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/8bef9e6d Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/8bef9e6d Branch: refs/heads/4.x-HBase-0.98 Commit: 8bef9e6dc195b900b0751650360189421890d4bb Parents: 8fbae1d Author: Mujtaba <mujt...@apache.org> Authored: Fri Nov 20 10:17:22 2015 -0800 Committer: Mujtaba <mujt...@apache.org> Committed: Fri Nov 20 10:17:22 2015 -0800 ---------------------------------------------------------------------- .../java/org/apache/phoenix/pherf/Pherf.java | 8 ++++-- .../apache/phoenix/pherf/PherfConstants.java | 7 ++++- .../pherf/util/GoogleChartGenerator.java | 27 +++++++++++++++----- .../phoenix/pherf/workload/WriteWorkload.java | 15 ----------- 4 files changed, 33 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/8bef9e6d/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/Pherf.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/Pherf.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/Pherf.java index cf5b6aa..eaf199a 100644 --- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/Pherf.java +++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/Pherf.java @@ -30,6 +30,7 @@ import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.cli.PosixParser; +import org.apache.phoenix.pherf.PherfConstants.CompareType; import org.apache.phoenix.pherf.PherfConstants.GeneratePhoenixStats; import org.apache.phoenix.pherf.configuration.XMLConfigParser; import org.apache.phoenix.pherf.jmx.MonitorManager; @@ -86,7 +87,8 @@ public class Pherf { options.addOption("stats", false, "Update Phoenix Statistics after data is loaded with -l argument"); options.addOption("label", true, "Label a run. Result file name will be suffixed with specified label"); - options.addOption("compare", true, "Specify labeled runs to compare against current run"); + options.addOption("compare", true, "Specify labeled run(s) to compare"); + options.addOption("useAverageCompareType", false, "Compare results with Average query time instead of default is Minimum query time."); } private final String zookeeper; @@ -106,6 +108,7 @@ public class Pherf { private final GeneratePhoenixStats generateStatistics; private final String label; private final String compareResults; + private final CompareType compareType; public Pherf(String[] args) throws Exception { CommandLineParser parser = new PosixParser(); @@ -151,6 +154,7 @@ public class Pherf { properties.setProperty("pherf. default.dataloader.threadpool", writerThreadPoolSize); label = command.getOptionValue("label", null); compareResults = command.getOptionValue("compare", null); + compareType = command.hasOption("useAverageCompareType") ? CompareType.AVERAGE : CompareType.MINIMUM; if ((command.hasOption("h") || (args == null || args.length == 0)) && !command .hasOption("listFiles")) { @@ -199,7 +203,7 @@ public class Pherf { // Compare results and exit if (null != compareResults) { logger.info("\nStarting to compare results and exiting for " + compareResults); - new GoogleChartGenerator(compareResults).readAndRender(); + new GoogleChartGenerator(compareResults, compareType).readAndRender(); return; } http://git-wip-us.apache.org/repos/asf/phoenix/blob/8bef9e6d/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/PherfConstants.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/PherfConstants.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/PherfConstants.java index b6e509d..c3a1200 100644 --- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/PherfConstants.java +++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/PherfConstants.java @@ -23,10 +23,15 @@ import java.io.InputStream; import java.util.Properties; public class PherfConstants { - public enum GeneratePhoenixStats { + public static enum GeneratePhoenixStats { YES, NO } + + public static enum CompareType { + MINIMUM, + AVERAGE + } private static PherfConstants instance = null; private static Properties instanceProperties = null; http://git-wip-us.apache.org/repos/asf/phoenix/blob/8bef9e6d/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/util/GoogleChartGenerator.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/util/GoogleChartGenerator.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/util/GoogleChartGenerator.java index 8a9fef5..577c0d9 100644 --- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/util/GoogleChartGenerator.java +++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/util/GoogleChartGenerator.java @@ -33,6 +33,7 @@ import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; import org.apache.phoenix.pherf.PherfConstants; +import org.apache.phoenix.pherf.PherfConstants.CompareType; import org.apache.phoenix.pherf.result.file.ResultFileDetails; /** @@ -41,13 +42,15 @@ import org.apache.phoenix.pherf.result.file.ResultFileDetails; public class GoogleChartGenerator { private String[] labels; + private CompareType compareType; private final Map<String, DataNode> datanodes = new TreeMap<String, DataNode>(); private final PherfConstants constants = PherfConstants.create(); private final String resultDir = constants.getProperty("pherf.default.results.dir"); private final double threshold = Double.parseDouble(constants.getProperty("pherf.default.comparison.threshold")); - public GoogleChartGenerator(String labels) { + public GoogleChartGenerator(String labels, CompareType compareType) { this.setLabels(labels); + this.setCompareType(compareType); } String[] getLabels() { @@ -62,6 +65,14 @@ public class GoogleChartGenerator { this.labels = labels.split(","); } + CompareType getCompareType() { + return this.compareType; + } + + void setCompareType(CompareType compareType) { + this.compareType = compareType; + } + public void readAndRender() { try { for (String label : labels) { @@ -122,13 +133,13 @@ public class GoogleChartGenerator { for (Map.Entry<String, DataNode> dn : datanodes.entrySet()) { for (Map.Entry<String, Node> node : dn.getValue().getDataSet().entrySet()) { if (timeToCompare == -1) { - timeToCompare = node.getValue().getMinTime(); + timeToCompare = node.getValue().getTime(getCompareType()); if (timeToCompare < 10) { // extremely small query time in ms therefore don't compare return true; } } - if ((((double) (timeToCompare - node.getValue().getMinTime())) / (double) node - .getValue().getMinTime()) > threshold) { + if ((((double) (timeToCompare - node.getValue().getTime(getCompareType()))) / (double) node + .getValue().getTime(getCompareType())) > threshold) { return false; } } @@ -158,7 +169,7 @@ public class GoogleChartGenerator { lastKeyPrefix = currentKeyPrefix; sb.append("['" + dn.getKey() + "'"); for (Map.Entry<String, Node> nodeSet : dn.getValue().getDataSet().entrySet()) { - sb.append (", " + nodeSet.getValue().getMinTime()); + sb.append (", " + nodeSet.getValue().getTime(getCompareType())); sb.append (",'" + getToolTipAsHTML(dn.getValue().getDataSet()) + "'"); } sb.append("],\n"); @@ -220,7 +231,7 @@ public class GoogleChartGenerator { + node.getQueryAsHTML(); } - /** + /** * DataNode to store results to render and compare */ class DataNode { @@ -271,6 +282,10 @@ public class GoogleChartGenerator { void setExplainPlan(String explainPlan) { this.explainPlan = explainPlan; } + long getTime(CompareType compareType) { + return (compareType == CompareType.AVERAGE ? getAvgTime() : getMinTime()); + } + long getMinTime() { if (minTime <= 2) return 2; http://git-wip-us.apache.org/repos/asf/phoenix/blob/8bef9e6d/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/WriteWorkload.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/WriteWorkload.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/WriteWorkload.java index 7b5276b..92acf52 100644 --- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/WriteWorkload.java +++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/WriteWorkload.java @@ -179,9 +179,6 @@ public class WriteWorkload implements Workload { } else { logger.info("Phoenix table stats update not requested."); } - - // always update stats for Phoenix base tables - updatePhoenixStats(scenario.getTableName(), scenario); } private List<Future> getBatches(DataLoadThreadTime dataLoadThreadTime, Scenario scenario) @@ -231,18 +228,6 @@ public class WriteWorkload implements Workload { .add(scenario.getTableName(), sumRows, (int) (System.currentTimeMillis() - start)); } - /** - * TODO Move this method to PhoenixUtil - * Update Phoenix table stats - * - * @param tableName - * @throws Exception - */ - public void updatePhoenixStats(String tableName, Scenario scenario) throws Exception { - logger.info("Updating stats for " + tableName); - pUtil.executeStatement("UPDATE STATISTICS " + tableName, scenario); - } - public Future<Info> upsertData(final Scenario scenario, final List<Column> columns, final String tableName, final int rowCount, final DataLoadThreadTime dataLoadThreadTime) {