Avoid overly large bursts of shovelling
This commit is contained in:
parent
187a17ca6d
commit
cc275029f7
20
queue.c
20
queue.c
|
@ -78,6 +78,15 @@ static int send_to_waiter(subscription_t *sub, sexp_t *body) {
|
|||
return post_node(sexp_data(sub->sink), sexp_data(sub->name), body, sub->uuid);
|
||||
}
|
||||
|
||||
static void end_burst(queue_extension_t *q, size_t *burst_count_ptr, size_t total_count) {
|
||||
if (*burst_count_ptr > 0) {
|
||||
info("Queue <<%.*s>>: burst count %lu; total %lu\n",
|
||||
sexp_data(q->name).len, sexp_data(q->name).bytes,
|
||||
*burst_count_ptr, total_count);
|
||||
}
|
||||
*burst_count_ptr = 0;
|
||||
}
|
||||
|
||||
static void shoveller(void *qv) {
|
||||
queue_extension_t *q = qv;
|
||||
|
||||
|
@ -129,17 +138,20 @@ static void shoveller(void *qv) {
|
|||
DECREF(body, sexp_destructor);
|
||||
queue_append(&q->waiter_q, &examined);
|
||||
enqueue(&q->waiter_q, sub);
|
||||
|
||||
if (burst_count > 10000) {
|
||||
end_burst(q, &burst_count, total_count);
|
||||
yield();
|
||||
}
|
||||
|
||||
goto check_for_work;
|
||||
|
||||
wait_and_shovel:
|
||||
info("Queue <<%.*s>>: burst count %lu; total %lu\n",
|
||||
sexp_data(q->name).len, sexp_data(q->name).bytes,
|
||||
burst_count, total_count);
|
||||
end_burst(q, &burst_count, total_count);
|
||||
//info("Waiting for throck\n");
|
||||
q->shovel_awake = 0;
|
||||
suspend();
|
||||
//info("Throck received!\n");
|
||||
burst_count = 0;
|
||||
goto check_for_work;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue