feat: grow local runqueue if full

master
Sean McBride 3 years ago
parent 823c46f6f8
commit 69bdf5b49b

@ -25,6 +25,28 @@ local_runqueue_minheap_is_empty()
return priority_queue_length_nolock(local_runqueue_minheap) == 0;
}
/**
* Doubles capacity of local runqueue
*/
void
local_runqueue_minheap_grow(void)
{
assert(local_runqueue_minheap != NULL);
/* capacity is padded by 1 because idx 0 is padding */
if (unlikely(local_runqueue_minheap->capacity == 1)) {
debuglog("Growing to 2\n");
local_runqueue_minheap->capacity++;
} else {
local_runqueue_minheap->capacity = (local_runqueue_minheap->capacity - 1) * 2 + 1;
debuglog("Growing to %zu\n", local_runqueue_minheap->capacity);
}
local_runqueue_minheap = (struct priority_queue *)
realloc(local_runqueue_minheap,
sizeof(struct priority_queue) + sizeof(void *) * (local_runqueue_minheap->capacity));
}
/**
* Adds a sandbox to the run queue
* @param sandbox
@ -34,8 +56,11 @@ void
local_runqueue_minheap_add(struct sandbox *sandbox)
{
int return_code = priority_queue_enqueue_nolock(local_runqueue_minheap, sandbox);
/* TODO: propagate RC to caller. Issue #92 */
if (return_code == -ENOSPC) panic("Thread Runqueue is full!\n");
if (unlikely(return_code == -ENOSPC)) {
local_runqueue_minheap_grow();
return_code = priority_queue_enqueue_nolock(local_runqueue_minheap, sandbox);
if (unlikely(return_code == -ENOSPC)) panic("Thread Runqueue is full!\n");
}
}
/**

@ -45,3 +45,6 @@ client-preempt:
client-fib10-multi:
hey -z ${DURATION_SEC}s -cpus 4 -c 100 -t 0 -o csv -m GET -d "10\n" "http://${HOSTNAME}:10010"
client-fib40-multi:
hey -z ${DURATION_SEC}s -cpus 4 -c 100 -t 0 -o csv -m GET -d "40\n" "http://${HOSTNAME}:10040"

Loading…
Cancel
Save