Commit f5ec8be
authored
perf: Submit tasks to TaskRunner order by task priority (#19203)
Ensure active tasks are (re)-submitted to TaskRunner in order of priority. With the way things are currently structured, TaskQueue and TaskRunner both introduce their own delays to the scheduling of a task as they are both queues in their own ways. This patch attempts to minimize the HOL-blocking delay introduced by the TaskQueue and #18851 will help reduce the slowness on the TaskRunner. This helps enormously for large task volume cases (O(5k) tasks+) where lots of low-priority tasks are hitting the queue (think large compaction or batch volume) while realtime indexing tasks are being submitted. This allows the higher-priority realtime tasks to "jump" the line in submission to the runner (which is still ultimately FIFO relatively speaking), and not pay the O(XX) seconds of time wasted waiting for other lower-priority tasks to be submitted to the queue.
Notably, this does do a sort every time startPendingTasksOnRunner is called, however, given the activeTasks should be on the order of O(10k) tasks and the comparator is comparing integers, this should be relatively cheap (empirically, this has never shown up in flamegraph as TaskQueue is bound by other things). When #18851 is merged (and priority based running is introduced) this may have less of an effect. Storing activeTasks in an ordered container might be nice, but given this is a single use-case which requires a sorted order (and the maximum container size is tolerable) I opted to go for this approach.1 parent b2eed67 commit f5ec8be
2 files changed
Lines changed: 77 additions & 2 deletions
File tree
- indexing-service/src
- main/java/org/apache/druid/indexing/overlord
- test/java/org/apache/druid/indexing/overlord
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| |||
417 | 418 | | |
418 | 419 | | |
419 | 420 | | |
420 | | - | |
421 | | - | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
422 | 429 | | |
423 | 430 | | |
424 | 431 | | |
| |||
Lines changed: 68 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| 102 | + | |
101 | 103 | | |
102 | 104 | | |
103 | 105 | | |
| |||
751 | 753 | | |
752 | 754 | | |
753 | 755 | | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
754 | 797 | | |
755 | 798 | | |
756 | 799 | | |
| |||
904 | 947 | | |
905 | 948 | | |
906 | 949 | | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
907 | 975 | | |
0 commit comments