size_t PlanOperation::determineDynamicCount(size_t maxTaskRunTime) { // this can never be satisfied. Default to NO parallelization. if (maxTaskRunTime == 0) { return 1; } auto totalTableSize = getTotalTableSize(); // Table is empty or in case of RadixJoin at least one operand is empty. // Also if getTotalTableSize() uses default implementation. if (totalTableSize == 0) { return 1; } auto totalTblSizeIn100k = totalTableSize / 100000.0; // this is the b of the mts = a / instances + b model auto minMts = calcMinMts(totalTblSizeIn100k); if (maxTaskRunTime < minMts) { LOG4CXX_ERROR(logger, planOperationName() << ": Could not honor MTS request. Too small."); return 1024; } auto a = calcA(totalTblSizeIn100k); size_t numTasks = std::max(1, static_cast<int>(round(a / (maxTaskRunTime - minMts)))); LOG4CXX_DEBUG(logger, planOperationName() << ": tts(in 100k): " << totalTblSizeIn100k << ", numTasks: " << numTasks); return numTasks; }
const _PlanOperation *_PlanOperation::execute() { epoch_t startTime = get_epoch_nanoseconds(); refreshInput(); setupPlanOperation(); PapiTracer pt; pt.addEvent("PAPI_TOT_CYC"); pt.addEvent(getEvent()); pt.start(); executePlanOperation(); pt.stop(); teardownPlanOperation(); epoch_t endTime = get_epoch_nanoseconds(); std::string threadId = boost::lexical_cast<std::string>(std::this_thread::get_id()); if (_performance_attr != nullptr) *_performance_attr = (performance_attributes_t) { pt.value("PAPI_TOT_CYC"), pt.value(getEvent()), getEvent() , planOperationName(), _operatorId, startTime, endTime, threadId }; setState(OpSuccess); return this; }
void _PlanOperation::operator()() noexcept { if (allDependenciesSuccessful()) { try { LOG4CXX_DEBUG(logger, "Virtual operator called " << vname() << "(" << _operatorId << ")"); execute(); return; } catch (const std::exception &ex) { setErrorMessage(ex.what()); } catch (...) { setErrorMessage("Unknown error"); } } else { // dependencies were not successful setErrorMessage(getDependencyErrorMessages()); } LOG4CXX_ERROR(logger, this << " " << planOperationName() << " failed: " << getErrorMessage()); setState(OpFail); }
const PlanOperation* PlanOperation::execute() { const bool recordPerformance = _performance_attr != nullptr; // Check if we really need this epoch_t startTime = 0; if (recordPerformance) startTime = get_epoch_nanoseconds(); PapiTracer pt; // Start the execution refreshInput(); setupPlanOperation(); if (recordPerformance) { pt.addEvent("PAPI_TOT_CYC"); pt.addEvent(getEvent()); pt.start(); } executePlanOperation(); if (recordPerformance) pt.stop(); teardownPlanOperation(); if (recordPerformance) { epoch_t endTime = get_epoch_nanoseconds(); std::string threadId = boost::lexical_cast<std::string>(std::this_thread::get_id()); size_t cardinality; if (getResultTable() != empty_result) cardinality = getResultTable()->size(); else // the cardinality is max(size_t) by convention if there is no return table cardinality = std::numeric_limits<size_t>::max(); *_performance_attr = (performance_attributes_t) {pt.value("PAPI_TOT_CYC"), pt.value(getEvent()), getEvent(), planOperationName(), _operatorId, startTime, endTime, threadId, cardinality}; } setState(OpSuccess); return this; }
const std::string PlanOperation::vname() { return planOperationName(); }
void PlanOperation::setErrorMessage(const std::string& message) { LOG4CXX_INFO(logger, this << " " << planOperationName() << " sets error message: " << message); getResponseTask()->addErrorMessage(_operatorId + ": " + message); }