mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 09:41:54 +00:00
IO: Allow to take new loops if the thread is hot, but only one at time
This commit is contained in:
parent
18d069d663
commit
865bab6237
@ -678,24 +678,21 @@ birdloop_take(struct birdloop_pickup_group *group)
|
|||||||
{
|
{
|
||||||
struct birdloop *loop = NULL;
|
struct birdloop *loop = NULL;
|
||||||
|
|
||||||
if (birdloop_hot_potato(this_thread->meta))
|
|
||||||
return;
|
|
||||||
|
|
||||||
LOCK_DOMAIN(attrs, group->domain);
|
LOCK_DOMAIN(attrs, group->domain);
|
||||||
|
|
||||||
if (this_thread->busy_active &&
|
if (this_thread->busy_active &&
|
||||||
(group->thread_busy_count < group->thread_count) &&
|
(group->thread_busy_count < group->thread_count) &&
|
||||||
(this_thread->loop_count > 1) &&
|
(this_thread->loop_count > 1) &&
|
||||||
!EMPTY_LIST(group->loops) &&
|
(EMPTY_LIST(group->loops) ||
|
||||||
birdloop_hot_potato(HEAD(group->loops)))
|
!birdloop_hot_potato(HEAD(group->loops))))
|
||||||
{
|
{
|
||||||
THREAD_TRACE(DL_SCHEDULING, "Loop drop requested (tbc=%d, tc=%d, lc=%d)",
|
THREAD_TRACE(DL_SCHEDULING, "Loop drop requested (tbc=%d, tc=%d, lc=%d)",
|
||||||
group->thread_busy_count, group->thread_count, this_thread->loop_count);
|
group->thread_busy_count, group->thread_count, this_thread->loop_count);
|
||||||
UNLOCK_DOMAIN(attrs, group->domain);
|
UNLOCK_DOMAIN(attrs, group->domain);
|
||||||
|
|
||||||
uint dropped = 0;
|
uint dropped = 0;
|
||||||
node *n;
|
node *n, *_nxt;
|
||||||
WALK_LIST2(loop, n, this_thread->loops, n)
|
WALK_LIST2_DELSAFE(loop, n, _nxt, this_thread->loops, n)
|
||||||
{
|
{
|
||||||
birdloop_enter(loop);
|
birdloop_enter(loop);
|
||||||
if (ev_active(&loop->event) && !loop->stopped && !birdloop_hot_potato(loop))
|
if (ev_active(&loop->event) && !loop->stopped && !birdloop_hot_potato(loop))
|
||||||
@ -709,7 +706,7 @@ birdloop_take(struct birdloop_pickup_group *group)
|
|||||||
birdloop_set_thread(loop, NULL, group);
|
birdloop_set_thread(loop, NULL, group);
|
||||||
|
|
||||||
dropped++;
|
dropped++;
|
||||||
if (dropped * dropped > this_thread->loop_count)
|
if ((dropped * dropped) / 2 > this_thread->loop_count)
|
||||||
{
|
{
|
||||||
birdloop_leave(loop);
|
birdloop_leave(loop);
|
||||||
|
|
||||||
@ -743,7 +740,9 @@ birdloop_take(struct birdloop_pickup_group *group)
|
|||||||
if (group->thread_busy_count < group->thread_count)
|
if (group->thread_busy_count < group->thread_count)
|
||||||
thread_count -= group->thread_busy_count;
|
thread_count -= group->thread_busy_count;
|
||||||
|
|
||||||
uint assign = 1 + group->loop_unassigned_count / thread_count;
|
uint assign = birdloop_hot_potato(this_thread->meta) ? 1 :
|
||||||
|
1 + group->loop_unassigned_count / thread_count;
|
||||||
|
|
||||||
for (uint i=0; !EMPTY_LIST(group->loops) && i<assign; i++)
|
for (uint i=0; !EMPTY_LIST(group->loops) && i<assign; i++)
|
||||||
{
|
{
|
||||||
loop = SKIP_BACK(struct birdloop, n, HEAD(group->loops));
|
loop = SKIP_BACK(struct birdloop, n, HEAD(group->loops));
|
||||||
@ -765,10 +764,12 @@ birdloop_take(struct birdloop_pickup_group *group)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bird_thread_pickup_next(group);
|
bird_thread_pickup_next(group);
|
||||||
|
|
||||||
|
if (assign)
|
||||||
|
this_thread->meta->last_transition_ns = ns_now();
|
||||||
}
|
}
|
||||||
|
|
||||||
UNLOCK_DOMAIN(attrs, group->domain);
|
UNLOCK_DOMAIN(attrs, group->domain);
|
||||||
this_thread->meta->last_transition_ns = ns_now();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user