Source:
<code>private TaskStatus createTaskStatus(TaskHolder taskHolder) { long versionNumber = nextTaskInfoVersion.getAndIncrement(); TaskState state = taskStateMachine.getState(); List<ExecutionFailureInfo> failures = ImmutableList.of(); if (state == TaskState.FAILED) { failures = toFailures(taskStateMachine.getFailureCauses()); } int queuedPartitionedDrivers = 0; int runningPartitionedDrivers = 0; DataSize memoryReservation = new DataSize(0, BYTE); if (taskHolder.getFinalTaskInfo() != null) { TaskStats taskStats = taskHolder.getFinalTaskInfo().getStats(); queuedPartitionedDrivers = taskStats.getQueuedPartitionedDrivers(); runningPartitionedDrivers = taskStats.getRunningPartitionedDrivers(); memoryReservation = taskStats.getMemoryReservation(); } else if (taskHolder.getTaskExecution() != null) { TaskContext taskContext = taskHolder.getTaskExecution().getTaskContext(); for (PipelineContext pipelineContext : taskContext.getPipelineContexts()) { PipelineStatus pipelineStatus = pipelineContext.getPipelineStatus(); queuedPartitionedDrivers += pipelineStatus.getQueuedPartitionedDrivers(); runningPartitionedDrivers += pipelineStatus.getRunningPartitionedDrivers(); } memoryReservation = taskContext.getMemoryReservation(); } <START> Set<DriverLifeCycle> completedDriverGroups = getCompletedDriverGroups(taskHolder); <END> return new TaskStatus(taskStateMachine.getTaskId(), taskInstanceId, versionNumber, state, location, nodeId, completedDriverGroups, failures, queuedPartitionedDrivers, runningPartitionedDrivers, memoryReservation); }</code><technical_language>is critical this code acquire a contended lock (or do a long time). appears methods this is calling synchronized, please double check lock is contended</technical_language>

Target:
private TaskStatus createTaskStatus(TaskHolder taskHolder) { long versionNumber = nextTaskInfoVersion.getAndIncrement(); TaskState state = taskStateMachine.getState(); List<ExecutionFailureInfo> failures = ImmutableList.of(); if (state == TaskState.FAILED) { failures = toFailures(taskStateMachine.getFailureCauses()); } int queuedPartitionedDrivers = 0; int runningPartitionedDrivers = 0; DataSize physicalWrittenDataSize = new DataSize(0, BYTE); DataSize memoryReservation = new DataSize(0, BYTE); Set<Lifespan> completedDriverGroups = ImmutableSet.of(); if (taskHolder.getFinalTaskInfo() != null) { TaskStats taskStats = taskHolder.getFinalTaskInfo().getStats(); queuedPartitionedDrivers = taskStats.getQueuedPartitionedDrivers(); runningPartitionedDrivers = taskStats.getRunningPartitionedDrivers(); physicalWrittenDataSize = taskStats.getPhysicalWrittenDataSize(); memoryReservation = taskStats.getMemoryReservation(); } else if (taskHolder.getTaskExecution() != null) { long physicalWrittenBytes = 0; TaskContext taskContext = taskHolder.getTaskExecution().getTaskContext(); for (PipelineContext pipelineContext : taskContext.getPipelineContexts()) { PipelineStatus pipelineStatus = pipelineContext.getPipelineStatus(); queuedPartitionedDrivers += pipelineStatus.getQueuedPartitionedDrivers(); runningPartitionedDrivers += pipelineStatus.getRunningPartitionedDrivers(); physicalWrittenBytes += pipelineContext.getPhysicalWrittenDataSize(); } physicalWrittenDataSize = succinctBytes(physicalWrittenBytes); memoryReservation = taskContext.getMemoryReservation(); completedDriverGroups = taskContext.getCompletedDriverGroups(); } return new TaskStatus(taskStateMachine.getTaskId(), taskInstanceId, versionNumber, state, location, nodeId, completedDriverGroups, failures, queuedPartitionedDrivers, runningPartitionedDrivers, isOutputBufferFull(), physicalWrittenDataSize, memoryReservation); }