aboutsummaryrefslogtreecommitdiff
path: root/tools/server/schedule.c
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-06-27 00:58:05 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-06-27 01:03:41 +0200
commitaf55803d0dff9eb692c760c8d486e736c945061d (patch)
tree0875a1112bf98304e445e0544c4309670d6f4769 /tools/server/schedule.c
parent0f861b7f3098750ddee4f6570f3be228d1da5320 (diff)
downloadffwd-af55803d0dff9eb692c760c8d486e736c945061d.tar.gz
ffwd-af55803d0dff9eb692c760c8d486e736c945061d.zip
chore: clean up comment formatting and wording
Diffstat (limited to 'tools/server/schedule.c')
-rw-r--r--tools/server/schedule.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/tools/server/schedule.c b/tools/server/schedule.c
index d57fbed..8254739 100644
--- a/tools/server/schedule.c
+++ b/tools/server/schedule.c
@@ -1,3 +1,21 @@
+/* Job queue, micro-batching, and completion.
+ *
+ * dispatch_request in server.c enqueues one job per framed request.
+ *
+ * The inference worker thread, worker_main in server.c, drains jobs with
+ * collect_job_batch. A short first-arrival wait groups concurrent arrivals.
+ *
+ * process_job_group routes each job to its endpoint handler and merges all
+ * compatible requests into one pool. execute_*_request_list then repacks that
+ * pool into token-budget batches.
+ *
+ * Finished jobs go to the done queue and wake the event loop through the
+ * completion pipe.
+ *
+ * completion_cb writes each response on the loop thread, so sockets are only
+ * touched there.
+ */
+
#include "server_internal.h"
#include "util.h"
@@ -9,19 +27,6 @@
#include <sys/time.h>
#include <unistd.h>
-/* ========================================================================
- * Job queue, micro-batching, and completion
- *
- * dispatch_request (server.c) enqueues one job per framed request; the
- * inference worker thread (worker_main, server.c) drains them with
- * collect_job_batch (a short first-arrival wait groups concurrent arrivals) and
- * runs process_job_group, which routes each job to its endpoint handler and
- * merges all compatible requests into one pool that execute_*_request_list
- * re-packs into token-budget batches. Finished jobs go on the done queue and
- * wake the event loop through the completion pipe; completion_cb writes each
- * response back on the loop thread, so sockets are only ever touched there.
- * ======================================================================== */
-
static void enqueue_done(job *j) {
http_server *s = j->srv;
pthread_mutex_lock(&s->mu);
@@ -324,12 +329,17 @@ static void process_unknown_job(job *j) {
yyjson_doc_free(root);
}
-/* Parse and tokenize one job into a heap request attached to j->prep, which the
- * worker then moves into its request array. Runs on the tokenizer thread, or on
- * the worker itself for a request that reached the job queue untokenized. An
- * unknown endpoint leaves prep_kind 0 (process_unknown_job handles it); a parse
- * failure leaves prep NULL with the 422 already set, so the worker finishes it
- * as not-ready. The tokenized flag guards against tokenizing twice. */
+/* Parse and tokenize one job into a heap request attached to j->prep.
+ * The worker later moves it into its request array.
+ *
+ * Runs on the tokenizer thread, or on the worker for requests that reached the
+ * job queue untokenized.
+ *
+ * Unknown endpoints leave prep_kind as 0; process_unknown_job handles them.
+ * Parse failures leave prep NULL with the 422 already set, so the worker
+ * finishes them as not-ready.
+ *
+ * tokenized prevents tokenizing twice. */
void tokenize_job(http_server *s, job *j) {
j->tokenized = 1;
if (!j->started_ns)