Skip to content
Browse files
perf: eliminate expensive log construction in remote-task-runner shut…
…down (#12097)
  • Loading branch information
jasonk000 committed Mar 3, 2022
1 parent f594e7a commit 36193955b6d8a03fe247157dddebea0365c7e501
Showing 1 changed file with 9 additions and 5 deletions.
@@ -325,13 +325,17 @@ void manageInternal()
final Set<String> tasksToKill = Sets.difference(runnerTaskFutures.keySet(), knownTaskIds);
if (!tasksToKill.isEmpty()) {"Asking taskRunner to clean up %,d tasks.", tasksToKill.size());

// On large installations running several thousands of tasks,
// concatenating the list of known task ids can be compupationally expensive.
final boolean logKnownTaskIds = log.isDebugEnabled();
final String reason = logKnownTaskIds
? String.format("Task is not in knownTaskIds[%s]", knownTaskIds)
: "Task is not in knownTaskIds";

for (final String taskId : tasksToKill) {
try {
"task is not in knownTaskIds[%s]",
taskRunner.shutdown(taskId, reason);
catch (Exception e) {
log.warn(e, "TaskRunner failed to clean up task: %s", taskId);

0 comments on commit 3619395

Please sign in to comment.