This is an automated email from the ASF dual-hosted git repository.
tuglu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new 619a61f779b perf: More TaskQueue optimizations (#19199)
619a61f779b is described below
commit 619a61f779b55f3ccb65cd07bd7cd5792fbaf5f3
Author: jtuglu1 <[email protected]>
AuthorDate: Mon Mar 23 23:14:46 2026 -0700
perf: More TaskQueue optimizations (#19199)
Small change. Reduces CPU footprint on task scheduling path by acquiring
key (or range)-based lock over tasks map (instead of acquiring giant lock +
copying/filtering task list to check a single value).
---
.../java/org/apache/druid/indexing/overlord/TaskQueue.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git
a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskQueue.java
b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskQueue.java
index 01447abaa83..221bc2a63f4 100644
---
a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskQueue.java
+++
b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskQueue.java
@@ -36,6 +36,7 @@ import org.apache.druid.common.utils.IdUtils;
import org.apache.druid.error.DruidException;
import org.apache.druid.error.EntryAlreadyExists;
import org.apache.druid.error.InvalidInput;
+import org.apache.druid.indexer.RunnerTaskState;
import org.apache.druid.indexer.TaskInfo;
import org.apache.druid.indexer.TaskLocation;
import org.apache.druid.indexer.TaskStatus;
@@ -500,9 +501,12 @@ public class TaskQueue
private boolean isTaskPending(Task task)
{
- return taskRunner.getPendingTasks()
- .stream()
- .anyMatch(workItem ->
workItem.getTaskId().equals(task.getId()));
+ // Opt for point lookup on the runner rather than expensive list() call
+ final RunnerTaskState taskState =
taskRunner.getRunnerTaskState(task.getId());
+ if (taskState == null) {
+ return false; // we don't know
+ }
+ return taskState == RunnerTaskState.PENDING;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]