perf(disaggregation): slice decode waiting queue for prebuilt batches

This commit is contained in:
wxiwnd
2026-04-08 23:09:03 +08:00
parent 6237271fc9
commit 14c40f4e7d
2 changed files with 125 additions and 20 deletions

View File

@@ -1212,23 +1212,16 @@ class SchedulerDisaggregationDecodeMixin:
num_not_used_batch = batch_size - curr_batch_size
# pop req from waiting queue
can_run_list: List[Req] = []
waiting_queue: List[Req] = []
for i in range(len(self.waiting_queue)):
req = self.waiting_queue[i]
# we can only add at least `num_not_used_batch` new batch to the running queue
if i < num_not_used_batch:
can_run_list.append(req)
req.init_next_round_input(self.tree_cache)
else:
waiting_queue.append(req)
self.waiting_queue = waiting_queue
if len(can_run_list) == 0:
num_new_reqs = min(num_not_used_batch, len(self.waiting_queue))
if num_new_reqs <= 0:
return None
can_run_list = self.waiting_queue[:num_new_reqs]
self.waiting_queue = self.waiting_queue[num_new_reqs:]
for req in can_run_list:
req.init_next_round_input(self.tree_cache)
set_time_batch(can_run_list, "set_forward_entry_time")
# construct a schedule batch with those requests and mark as decode