Package edu.brown.workload

Examples of edu.brown.workload.TransactionTrace


            Instance inst = trainingData.instance(i);
            int c = (int)state.clusterer.clusterInstance(inst);
            cluster_h.put(c);
           
            long txn_id = Long.valueOf(inst.stringValue(FeatureExtractor.TXNID_ATTRIBUTE_IDX));
            TransactionTrace txn_trace = this.workload.getTransaction(txn_id);
            assert(txn_trace != null) : "Invalid TxnId #" + txn_id + "\n" + inst;

            // Figure out which base partition this txn would execute on
            // because we want divide the MarkovGraphContainers by the base partition
            int base_partition = this.p_estimator.getBasePartition(txn_trace);
View Full Code Here


            ProfileMeasurement time = new ProfileMeasurement("costmodel").start();
            hist.clear();
            for (AbstractTraceElement<? extends CatalogType> element : args.workload) {
                if (element instanceof TransactionTrace) {
                    total++;
                    TransactionTrace xact = (TransactionTrace) element;
                    boolean is_singlesited = costmodel.processTransaction(args.catalogContext, xact, null).singlesited;
                    if (is_singlesited) {
                        singlepartition++;
                        hist.put(xact.getCatalogItemName());
                    } else {
                        multipartition++;
                        if (!hist.contains(xact.getCatalogItemName()))
                            hist.put(xact.getCatalogItemName(), 0);
                    }
                }
            } // FOR
            System.err.println("ESTIMATE TIME: " + time.stop().getTotalThinkTimeSeconds());
            break; // XXX
View Full Code Here

        long xact_ctr = 0;
        while (it.hasNext()) {
            AbstractTraceElement<? extends CatalogType> element = it.next();
           
            if (element instanceof TransactionTrace) {
                TransactionTrace xact = (TransactionTrace)element;
                if (xact_ctr++ % 100 == 0) LOG.info("Processing xact #" + xact_ctr);
                this.processTransaction(xact);
            }
           
        } // WHILE
View Full Code Here

     */
    protected double estimateWorkloadCostImpl(CatalogContext catalogContext, Workload workload, Filter filter, Double upper_bound) throws Exception {
        double cost = 0.0d;
        Iterator<TransactionTrace> it = workload.iterator(filter);
        while (it.hasNext()) {
            TransactionTrace xact = it.next();
            // System.out.println(xact.debug(this.catalogContext) + "\n");
            try {
                cost += this.estimateTransactionCost(catalogContext, workload, filter, xact);
            } catch (Exception ex) {
                LOG.error("Failed to estimate cost for " + xact.getCatalogItemName());
                CatalogUtil.saveCatalog(catalogContext.catalog, CatalogUtil.CATALOG_FILENAME);
                throw ex;
            }
            if (upper_bound != null && cost > upper_bound.doubleValue()) {
                if (debug.val)
View Full Code Here

                            continue;
                        }
                        if (pair == null) break;
                       
                        int partition = pair.getFirst();
                        TransactionTrace txn_trace = pair.getSecond();
                        Procedure catalog_proc = txn_trace.getCatalogItem(catalog_db);
                        long txn_id = txn_trace.getTransactionId();
                        try {
                            int map_id = (is_global ? MarkovUtil.GLOBAL_MARKOV_CONTAINER_ID : partition);
                            Object params[] = txn_trace.getParams();
                           
                            markovs = markovs_map.get(map_id);
                            if (markovs == null) {
                                synchronized (markovs_map) {
                                    markovs = markovs_map.get(map_id);
View Full Code Here

                        }
                        if (pair == null)
                            break;

                        int partition = pair.getFirst();
                        TransactionTrace txn_trace = pair.getSecond();
                        Procedure catalog_proc = txn_trace.getCatalogItem(args.catalog_db);
                        total_h.put(catalog_proc);
                        if (debug.val)
                            LOG.debug(String.format("Processing %s [%d / %d]", txn_trace, thread_ctr, thread_ctr + queues[thread_id].size()));

                        proc_h = proc_penalties_h.get(catalog_proc);
View Full Code Here

                catalog_proc = this.getProcedure(TARGET_PROCEDURES[i]);
                break;
            }
        } // FOR
        assertNotNull(catalog_proc);
        TransactionTrace multip_txn = null;
        for (TransactionTrace txn_trace : workload) {
            if (txn_trace.getCatalogItem(catalogContext.database).equals(catalog_proc)) {
                multip_txn = txn_trace;
                break;
            }
View Full Code Here

     */
    public void testWeightedTxnEstimation() throws Exception {
        // Make a new workload that only has multiple copies of the same multi-partition transaction
        Workload new_workload = new Workload(catalogContext.catalog);
        int num_txns = 13;
        TransactionTrace multip_txn = this.getMultiPartitionTransaction();
        Procedure catalog_proc = multip_txn.getCatalogItem(catalogContext.database);
        for (int i = 0; i < num_txns; i++) {
            TransactionTrace clone = (TransactionTrace)multip_txn.clone();
            clone.setTransactionId(i);
            new_workload.addTransaction(catalog_proc, clone);
        } // FOR
        assertEquals(num_txns, new_workload.getTransactionCount());
       
        // We now want to calculate the cost of this new workload
        final SingleSitedCostModel orig_costModel = new SingleSitedCostModel(catalogContext);
        final double orig_cost = orig_costModel.estimateWorkloadCost(catalogContext, new_workload);
        assert(orig_cost > 0);
        // if (orig_costModel.getMultiPartitionProcedureHistogram().isEmpty()) System.err.println(orig_costModel.getTransactionCacheEntry(0).debug());
        assertEquals(num_txns, orig_costModel.getMultiPartitionProcedureHistogram().getSampleCount());
        assertEquals(0, orig_costModel.getSinglePartitionProcedureHistogram().getSampleCount());
       
        // Only the base partition should be touched (2 * num_txns). Everything else should
        // be touched num_txns
        Integer base_partition = CollectionUtil.first(orig_costModel.getQueryPartitionAccessHistogram().getMaxCountValues());
        assertNotNull(base_partition);
        for (Integer p : orig_costModel.getQueryPartitionAccessHistogram().values()) {
            if (p.equals(base_partition)) {
                assertEquals(2 * num_txns, orig_costModel.getQueryPartitionAccessHistogram().get(p).intValue());
            } else {
                assertEquals(num_txns, orig_costModel.getQueryPartitionAccessHistogram().get(p).intValue());
            }
        } // FOR
       
        // Now change make a new workload that has the same multi-partition transaction
        // but this time it only has one but with a transaction weight
        // We should get back the exact same cost
        new_workload = new Workload(catalogContext.catalog);
        TransactionTrace clone = (TransactionTrace)multip_txn.clone();
        clone.setTransactionId(1000);
        clone.setWeight(num_txns);
        new_workload.addTransaction(catalog_proc, clone);
        final SingleSitedCostModel new_costModel = new SingleSitedCostModel(catalogContext);
        final double new_cost = new_costModel.estimateWorkloadCost(catalogContext, new_workload);
        assert(new_cost > 0);
        assertEquals(orig_cost, new_cost, 0.001);
View Full Code Here

     */
    public void testWeightedQueryEstimation() throws Exception {
        // Make a new workload that has its single queries duplicated multiple times
        Workload new_workload = new Workload(catalogContext.catalog);
        int num_dupes = 7;
        TransactionTrace multip_txn = this.getMultiPartitionTransaction();
        Procedure catalog_proc = multip_txn.getCatalogItem(catalogContext.database);
       
        final TransactionTrace orig_txn = (TransactionTrace)multip_txn.clone();
        List<QueryTrace> clone_queries = new ArrayList<QueryTrace>();
        for (int i = 0; i < num_dupes; i++) {
            for (QueryTrace query_trace : multip_txn.getQueries()) {
                QueryTrace clone_query = (QueryTrace)query_trace.clone();
                clone_queries.add(clone_query);
            } // FOR
        } // FOR
        orig_txn.setQueries(clone_queries);
        new_workload.addTransaction(catalog_proc, orig_txn);
        assertEquals(1, new_workload.getTransactionCount());
        assertEquals(multip_txn.getQueryCount() * num_dupes, orig_txn.getQueryCount());
       
        // We now want to calculate the cost of this new workload
        final SingleSitedCostModel orig_costModel = new SingleSitedCostModel(catalogContext);
        final double orig_cost = orig_costModel.estimateWorkloadCost(catalogContext, new_workload);
        assert(orig_cost > 0);
        TransactionCacheEntry orig_txnEntry = orig_costModel.getTransactionCacheEntry(orig_txn);
        assertNotNull(orig_txnEntry);
        assertEquals(orig_txn.getQueryCount(), orig_txnEntry.getExaminedQueryCount());
//        System.err.println(orig_txnEntry.debug());
//        System.err.println("=========================================");
       
        // Now change make a new workload that has the same multi-partition transaction
        // but this time it only has one but with a transaction weight
        // We should get back the exact same cost
        new_workload = new Workload(catalogContext.catalog);
        final TransactionTrace new_txn = (TransactionTrace)multip_txn.clone();
        clone_queries = new ArrayList<QueryTrace>();
        for (QueryTrace query_trace : multip_txn.getQueries()) {
            QueryTrace clone_query = (QueryTrace)query_trace.clone();
            clone_query.setWeight(num_dupes);
            clone_queries.add(clone_query);
        } // FOR
        new_txn.setQueries(clone_queries);
        new_workload.addTransaction(catalog_proc, new_txn);
        assertEquals(1, new_workload.getTransactionCount());
        assertEquals(multip_txn.getQueryCount(), new_txn.getQueryCount());
        assertEquals(multip_txn.getQueryCount() * num_dupes, new_txn.getWeightedQueryCount());
       
        final SingleSitedCostModel new_costModel = new SingleSitedCostModel(catalogContext);
        final double new_cost = new_costModel.estimateWorkloadCost(catalogContext, new_workload);
        assert(new_cost > 0);
        assertEquals(orig_cost, new_cost, 0.001);
View Full Code Here

     */
    public void testWeightedTxnInvalidateCache() throws Throwable {
        // Make a new workload that only has a single weighted copy of our multi-partition transaction
        Workload new_workload = new Workload(catalogContext.catalog);
        int weight = 16;
        TransactionTrace multip_txn = this.getMultiPartitionTransaction();
        Procedure catalog_proc = multip_txn.getCatalogItem(catalogContext.database);
        TransactionTrace clone = (TransactionTrace)multip_txn.clone();
        clone.setTransactionId(1000);
        clone.setWeight(weight);
        new_workload.addTransaction(catalog_proc, clone);
        assertEquals(1, new_workload.getTransactionCount());
       
        SingleSitedCostModel cost_model = new SingleSitedCostModel(catalogContext);
        final double orig_cost = cost_model.estimateWorkloadCost(catalogContext, new_workload);
View Full Code Here

TOP

Related Classes of edu.brown.workload.TransactionTrace

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.