def testfindExpectedDesign(self): """Perform the actual search for a design""" # Generate all the design candidates # Instantiate cost model cmConfig = { 'weight_network': 4, 'weight_disk': 1, 'weight_skew': 1, 'nodes': 10, 'max_memory': 1024, 'skew_intervals': 10, 'address_size': 64, 'window_size': 500 } cm = CostModel(self.collections, self.workload, cmConfig) d0 = self.getManMadeDesign() print d0 output_design = d0.toJSON() cost0 = cm.overallCost(d0) ds = Deserializer(output_design) d1 = ds.Deserialize() print d1 cost1 = cm.overallCost(d1) self.assertEqual(cost1, cost0)
def outtestfindExpectedDesign(self): """Perform the actual search for a design""" # Generate all the design candidates # Instantiate cost model cmConfig = { 'weight_network': 4, 'weight_disk': 1, 'weight_skew': 1, 'nodes': 10, 'max_memory': 1024, 'skew_intervals': 10, 'address_size': 64, 'window_size': 500 } cm = CostModel(self.collections, self.workload, cmConfig) initialDesign = InitialDesigner(self.collections, self.workload, None).generate() upper_bound = cm.overallCost(initialDesign) print "init solution: ", initialDesign print "init solution cost: ", upper_bound collectionNames = [c for c in self.collections] dc = self.dc.getCandidates(collectionNames) print "candidates: ", dc ln = LNSDesigner(self.collections, \ self.dc, \ self.workload, \ None, \ cm, \ initialDesign, \ upper_bound, \ LNS_RUN_TIME) solution = ln.solve() print "Best cost: ", ln.bestCost print "solution: ", solution
def load(self, replay=False, replay_design=None, init=False): """Perform the actual search for a design""" isShardingEnabled = self.config.getboolean(configutil.SECT_DESIGNER, 'enable_sharding') isIndexesEnabled = self.config.getboolean(configutil.SECT_DESIGNER, 'enable_indexes') isDenormalizationEnabled = self.config.getboolean(configutil.SECT_DESIGNER, 'enable_denormalization') self.collections = self.loadCollections() self.workload = self.loadWorkload(self.collections) # Generate all the design candidates self.designCandidates = self.generateDesignCandidates(self.collections, isShardingEnabled, isIndexesEnabled, isDenormalizationEnabled) #LOG.info("candidates: %s\n", self.designCandidates) # Instantiate cost model cmConfig = { 'weight_network': self.config.getfloat(configutil.SECT_COSTMODEL, 'weight_network'), 'weight_disk': self.config.getfloat(configutil.SECT_COSTMODEL, 'weight_disk'), 'weight_skew': self.config.getfloat(configutil.SECT_COSTMODEL, 'weight_skew'), 'nodes': self.config.getint(configutil.SECT_CLUSTER, 'nodes'), 'max_memory': self.config.getint(configutil.SECT_CLUSTER, 'node_memory'), 'skew_intervals': self.config.getint(configutil.SECT_COSTMODEL, 'time_intervals'), 'address_size': self.config.getint(configutil.SECT_COSTMODEL, 'address_size'), 'window_size': self.config.getint(configutil.SECT_COSTMODEL, 'window_size') } self.cm = CostModel(self.collections, self.workload, cmConfig) # if self.debug: # state.debug = True # costmodel.LOG.setLevel(logging.DEBUG) # Compute initial solution and calculate its cost # This will be the upper bound from starting design if not replay: initialDesign = InitialDesigner(self.collections, self.workload, self.config).generate() if init: print initialDesign.toJSON() #import pycallgraph #pycallgraph.start_trace() initialCost = self.cm.overallCost(initialDesign) #pycallgraph.make_dot_graph('d4.png') return initialCost, initialDesign else: self.cm.overallCost(replay_design) return None
def testfindExpectedDesign(self): """Perform the actual search for a design""" # Generate all the design candidates # Instantiate cost model cmConfig = { 'weight_network': 4, 'weight_disk': 1, 'weight_skew': 1, 'nodes': 10, 'max_memory': 1024, 'skew_intervals': 10, 'address_size': 64, 'window_size': 500 } cm = CostModel(self.collections, self.workload, cmConfig) d0 = self.getManMadeDesign() cost0 = cm.overallCost(d0) d1 = d0.copy() d1.setDenormalizationParent(tpccConstants.TABLENAME_ORDER_LINE, tpccConstants.TABLENAME_ORDERS) cost1 = cm.overallCost(d1) self.assertLess(cost1, cost0)