-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Cost Estimator Using Past Statistics for Schedule Generator #3156
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
SqlServer | ||
.getInstance( | ||
StorageConfig.jdbcUrl, | ||
StorageConfig.jdbcUsername, | ||
StorageConfig.jdbcPassword | ||
) | ||
.createDSLContext() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bobbai00 is this the correct way to use connection pool?
val eid = latestSuccessfulExecution.get.eId | ||
val rawStats = context | ||
.select( | ||
WORKFLOW_RUNTIME_STATISTICS.OPERATOR_ID, | ||
WORKFLOW_RUNTIME_STATISTICS.TIME, | ||
WORKFLOW_RUNTIME_STATISTICS.DATA_PROCESSING_TIME, | ||
WORKFLOW_RUNTIME_STATISTICS.CONTROL_PROCESSING_TIME | ||
) | ||
.from(WORKFLOW_RUNTIME_STATISTICS) | ||
.where( | ||
WORKFLOW_RUNTIME_STATISTICS.WORKFLOW_ID | ||
.eq(widAsUInteger) | ||
.and(WORKFLOW_RUNTIME_STATISTICS.EXECUTION_ID.eq(eid)) | ||
) | ||
.orderBy(WORKFLOW_RUNTIME_STATISTICS.TIME, WORKFLOW_RUNTIME_STATISTICS.OPERATOR_ID) | ||
.fetchInto(classOf[WorkflowRuntimeStatistics]) | ||
.asScala | ||
.toList |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if possible, can we use one query to get the latest successful execution's stats? we can avoid the transaction.
if (rawStats.isEmpty) { | ||
None | ||
} else { | ||
val cumulatedStats = rawStats.foldLeft(Map.empty[String, Double]) { (acc, stat) => | ||
val opTotalExecutionTime = acc.getOrElse(stat.getOperatorId, 0.0) | ||
acc + (stat.getOperatorId -> (opTotalExecutionTime + (stat.getDataProcessingTime | ||
.doubleValue() + stat.getControlProcessingTime.doubleValue()) / 1e9)) | ||
} | ||
Some(cumulatedStats) | ||
} | ||
} else { | ||
None | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try to use early return or other techniques (e.g., pattern matching) to reduce branches.
val region = Region( | ||
id = RegionIdentity(0), | ||
physicalOps = workflow.physicalPlan.operators, | ||
physicalLinks = workflow.physicalPlan.links | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add a test case where the region only contains a sub-dag of the workflow? just to make sure it can extract region costs correctly.
val region = Region( | ||
id = RegionIdentity(0), | ||
physicalOps = workflow.physicalPlan.operators, | ||
physicalLinks = workflow.physicalPlan.links | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add a test case where the region only contains a sub-dag of the workflow? just to make sure it can extract region costs correctly.
This PR introduces the
CostEstimator
trait which estimates the cost of a region, given some resource units.CostBasedScheduleGenerator
to calculate the cost of a schedule during search.A
DefaultCostEstimator
implementation is also added, which uses past execution statistics to estimate the wall-clock runtime of a region: