Skip to content

Commit 144abd3

Browse files
author
Stratum
committed
fix(server): a slot action pops the next deferred task (pilotlight 114)
1 parent 2a3e17e commit 144abd3

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

‎tools/server/server-context.cpp‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,25 @@
3939

4040
constexpr int HTTP_POLLING_SECONDS = 1;
4141

42+
// KVFIX-114: a slot action (save, restore, erase) runs on the task loop
43+
// without launching its slot, so no release follows it and
44+
// slot.callback_on_release never pops the next deferred task. A completion
45+
// deferred alongside the action was then left in queue_tasks_deferred until
46+
// some other request released the slot: forever, on an idle server
47+
// (pilotlight item 114, spike 99 UPSTREAM.md). Constructed once the action
48+
// is committed to run (after the is_processing() deferral check), it pops
49+
// one deferred task on every exit, success or error. pop_deferred_task
50+
// still prefers a task naming this slot, so a chain of waiting slot actions
51+
// drains one after another and then one generation task starts.
52+
struct slot_action_drain {
53+
server_queue & queue;
54+
const int id_slot;
55+
56+
~slot_action_drain() {
57+
queue.pop_deferred_task(id_slot);
58+
}
59+
};
60+
4261
static common_speculative_output_limits server_output_limits(const common_params & params) {
4362
if (params.embedding ||
4463
(params.pooling_type != LLAMA_POOLING_TYPE_UNSPECIFIED && params.pooling_type != LLAMA_POOLING_TYPE_NONE)) {
@@ -2905,6 +2924,9 @@ struct server_context_impl {
29052924
break;
29062925
}
29072926

2927+
// KVFIX-114: drain one deferred task when this action ends
2928+
const slot_action_drain drain_on_exit{queue_tasks, id_slot};
2929+
29082930
const int64_t t_start = ggml_time_us();
29092931

29102932
std::string filename = task.slot_action.filename;
@@ -2972,6 +2994,9 @@ struct server_context_impl {
29722994
break;
29732995
}
29742996

2997+
// KVFIX-114: drain one deferred task when this action ends
2998+
const slot_action_drain drain_on_exit{queue_tasks, id_slot};
2999+
29753000
const int64_t t_start = ggml_time_us();
29763001

29773002
std::string filename = task.slot_action.filename;
@@ -3055,6 +3080,9 @@ struct server_context_impl {
30553080
break;
30563081
}
30573082

3083+
// KVFIX-114: drain one deferred task when this action ends
3084+
const slot_action_drain drain_on_exit{queue_tasks, id_slot};
3085+
30583086
// Erase token cache
30593087
const size_t n_erased = slot->prompt.tokens.size();
30603088

0 commit comments

Comments
 (0)