/** * A SingleMergeExchange processes a total of M rows coming from N * sorted input streams (from N senders) and merges them into a single * output sorted stream. For costing purposes we can assume each sender * is sending M/N rows to a single receiver. * (See DremioCost for symbol notations) * C = CPU cost of SV remover for M/N rows * + Network cost of sending M/N rows to 1 destination. * So, C = (s * M/N) + (w * M/N) * Cost of merging M rows coming from N senders = (M log2 N) * c * Total cost = N * C + (M log2 N) * c */ @Override public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) { if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) { return super.computeSelfCost(planner).multiplyBy(.1); } RelNode child = this.getInput(); double inputRows = mq.getRowCount(child); int rowWidth = child.getRowType().getFieldCount() * DremioCost.AVG_FIELD_WIDTH; double svrCpuCost = DremioCost.SVR_CPU_COST * inputRows; double networkCost = DremioCost.BYTE_NETWORK_COST * inputRows * rowWidth; int numEndPoints = PrelUtil.getSettings(getCluster()).numEndPoints(); double mergeCpuCost = DremioCost.COMPARE_CPU_COST * inputRows * (Math.log(numEndPoints)/Math.log(2)); Factory costFactory = (Factory)planner.getCostFactory(); return costFactory.makeCost(inputRows, svrCpuCost + mergeCpuCost, 0, networkCost); }
/** * In a BroadcastExchange, each sender is sending data to N receivers (for costing * purposes we assume it is also sending to itself). */ @Override public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) { if(PrelUtil.getSettings(getCluster()).useDefaultCosting()) { return super.computeSelfCost(planner).multiplyBy(.1); } RelNode child = this.getInput(); final int numEndPoints = PrelUtil.getSettings(getCluster()).numEndPoints(); final double inputRows = mq.getRowCount(child); final int rowWidth = child.getRowType().getFieldCount() * DremioCost.AVG_FIELD_WIDTH; final double cpuCost = DremioCost.SVR_CPU_COST * inputRows; final double networkCost = DremioCost.BYTE_NETWORK_COST * inputRows * rowWidth * numEndPoints; return new DremioCost(inputRows, cpuCost, 0, networkCost); }
final double leftRowCount = mq.getRowCount(left); final int numEndPoints = plannerSettings.numEndPoints(); final long maxWidthPerNode = plannerSettings.getNumCoresPerExecutor(); final long maxWidthPerQuery = plannerSettings.getOptions().getOption(ExecConstants.MAX_WIDTH_GLOBAL);
OperatorPhase.PHASE_1of2); int numEndPoints = PrelUtil.getSettings(phase1Agg.getCluster()).numEndPoints();