-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
[For debugging purpose] add runtime stats for task create/update on the worker side #24161
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e8422dc
add runtime stats for task create/update on the worker side
shangm2 102a04a
add runtime stats for task create/update on the worker side
shangm2 6824e1f
Merge remote-tracking branch 'upstream/master'
shangm2 2e487c1
merge master
shangm2 1fca596
Merge remote-tracking branch 'upstream/master' into shangma/workerRun…
shangm2 97f1133
Revert "add runtime stats for task create/update on the worker side"
shangm2 48bb41f
add runtime stats for task create/update on the worker side
shangm2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ | |
import com.facebook.airlift.stats.CounterStat; | ||
import com.facebook.airlift.stats.GcMonitor; | ||
import com.facebook.presto.Session; | ||
import com.facebook.presto.common.RuntimeStats; | ||
import com.facebook.presto.common.RuntimeUnit; | ||
import com.facebook.presto.common.block.BlockEncodingSerde; | ||
import com.facebook.presto.event.SplitMonitor; | ||
import com.facebook.presto.execution.StateMachine.StateChangeListener; | ||
|
@@ -68,6 +70,7 @@ | |
import javax.inject.Inject; | ||
|
||
import java.io.Closeable; | ||
import java.lang.management.ManagementFactory; | ||
import java.nio.file.Paths; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
@@ -95,6 +98,7 @@ | |
import static com.google.common.base.Predicates.notNull; | ||
import static com.google.common.collect.Iterables.filter; | ||
import static com.google.common.collect.Iterables.transform; | ||
import static java.lang.Math.max; | ||
import static java.lang.String.format; | ||
import static java.util.Objects.requireNonNull; | ||
import static java.util.concurrent.Executors.newFixedThreadPool; | ||
|
@@ -407,6 +411,10 @@ public TaskInfo updateTask( | |
requireNonNull(sources, "sources is null"); | ||
requireNonNull(outputBuffers, "outputBuffers is null"); | ||
|
||
RuntimeStats runtimeStats = session.getRuntimeStats(); | ||
long startHouseKeepingWallTime = System.nanoTime(); | ||
long starthouseKeepingCPUTime = ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime(); | ||
|
||
SqlTask sqlTask = tasks.getUnchecked(taskId); | ||
QueryContext queryContext = sqlTask.getQueryContext(); | ||
if (!queryContext.isMemoryLimitsInitialized()) { | ||
|
@@ -431,6 +439,9 @@ public TaskInfo updateTask( | |
queryContext.setHeapDumpFilePath(heapDumpFilePath); | ||
|
||
sqlTask.recordHeartbeat(); | ||
runtimeStats.addMetricValue("houseKeepingOnWorkerCPUTimeNano", RuntimeUnit.NANO, max(0, ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime() - starthouseKeepingCPUTime)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. . |
||
runtimeStats.addMetricValue("houseKeepingOnWorkerWallTimeNano", RuntimeUnit.NANO, max(0, System.nanoTime() - startHouseKeepingWallTime)); | ||
|
||
return sqlTask.updateTask(session, fragment, sources, outputBuffers, tableWriteInfo); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
import com.facebook.airlift.json.Codec; | ||
import com.facebook.airlift.json.JsonCodec; | ||
import com.facebook.presto.Session; | ||
import com.facebook.presto.common.RuntimeStats; | ||
import com.facebook.presto.common.RuntimeUnit; | ||
import com.facebook.presto.connector.ConnectorTypeSerdeManager; | ||
import com.facebook.presto.execution.TaskId; | ||
import com.facebook.presto.execution.TaskInfo; | ||
|
@@ -54,6 +56,7 @@ | |
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.core.UriInfo; | ||
|
||
import java.lang.management.ManagementFactory; | ||
import java.util.List; | ||
import java.util.concurrent.Executor; | ||
import java.util.concurrent.ScheduledExecutorService; | ||
|
@@ -74,6 +77,7 @@ | |
import static com.facebook.presto.util.TaskUtils.randomizeWaitTime; | ||
import static com.google.common.collect.Iterables.transform; | ||
import static com.google.common.util.concurrent.MoreExecutors.directExecutor; | ||
import static java.lang.Math.max; | ||
import static java.util.Objects.requireNonNull; | ||
import static java.util.concurrent.TimeUnit.MILLISECONDS; | ||
import static java.util.concurrent.TimeUnit.SECONDS; | ||
|
@@ -135,19 +139,49 @@ public Response createOrUpdateTask(@PathParam("taskId") TaskId taskId, TaskUpdat | |
{ | ||
requireNonNull(taskUpdateRequest, "taskUpdateRequest is null"); | ||
|
||
long startWallTime = System.nanoTime(); | ||
long startCpuTime = ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime(); | ||
|
||
Session session = taskUpdateRequest.getSession().toSession(sessionPropertyManager, taskUpdateRequest.getExtraCredentials()); | ||
RuntimeStats runtimeStats = session.getRuntimeStats(); | ||
|
||
runtimeStats.addMetricValue("sessionCreationOnWorkerCPUTimeNano", RuntimeUnit.NANO, max(0, ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime() - startCpuTime)); | ||
runtimeStats.addMetricValue("sessionCreationOnWorkerWallTimeNano", RuntimeUnit.NANO, max(0, System.nanoTime() - startWallTime)); | ||
|
||
long startUpdateTaskWallTime = System.nanoTime(); | ||
long startUpdateTaskCPUTime = ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime(); | ||
TaskInfo taskInfo = taskManager.updateTask(session, | ||
taskId, | ||
taskUpdateRequest.getFragment().map(planFragmentCodec::fromBytes), | ||
taskUpdateRequest.getSources(), | ||
taskUpdateRequest.getOutputIds(), | ||
taskUpdateRequest.getTableWriteInfo()); | ||
runtimeStats.addMetricValue("taskUpdateOnWorkerCPUTimeNano", RuntimeUnit.NANO, max(0, ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime() - startUpdateTaskCPUTime)); | ||
runtimeStats.addMetricValue("taskUpdateOnWorkerWallTimeNano", RuntimeUnit.NANO, max(0, System.nanoTime() - startUpdateTaskWallTime)); | ||
|
||
TaskResourceUtils.recordTaskUpdateReceivedTimeNanos(session.getRuntimeStats(), ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime() - startCpuTime, System.nanoTime() - startWallTime); | ||
|
||
long startSummarizeWallTime = System.nanoTime(); | ||
long startSummarizeCPUTime = ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime(); | ||
|
||
if (shouldSummarize(uriInfo)) { | ||
taskInfo = taskInfo.summarize(); | ||
} | ||
runtimeStats.addMetricValue("taskInfoSummarizeOnWorkerCPUTimeNano", RuntimeUnit.NANO, max(0, ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime() - startSummarizeCPUTime)); | ||
runtimeStats.addMetricValue("taskInfoSummarizeOnWorkerWallTimeNano", RuntimeUnit.NANO, max(0, System.nanoTime() - startSummarizeWallTime)); | ||
|
||
long responseGenerationWallTime = System.nanoTime(); | ||
long responseGenerationCPUTime = ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime(); | ||
Response response = Response.ok().entity(taskInfo).build(); | ||
runtimeStats.addMetricValue("responseGenerationOnWorkerCPUTimeNano", RuntimeUnit.NANO, max(0, ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime() - responseGenerationCPUTime)); | ||
runtimeStats.addMetricValue("responseGenerationOnWorkerWallTimeNano", RuntimeUnit.NANO, max(0, System.nanoTime() - responseGenerationWallTime)); | ||
|
||
runtimeStats.addMetricValue("createOrUpdateTaskOnWorkerCPUTimeNano", RuntimeUnit.NANO, max(0, ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime() - startCpuTime)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. anchor |
||
runtimeStats.addMetricValue("createOrUpdateTaskOnWorkerWallTimeNano", RuntimeUnit.NANO, max(0, System.nanoTime() - startWallTime)); | ||
|
||
return Response.ok().entity(taskInfo).build(); | ||
//send task's runtime stats back | ||
taskInfo.getStats().getRuntimeStats().mergeWith(runtimeStats); | ||
return response; | ||
} | ||
|
||
@GET | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
anchor