git.haldean.org ubik / 36e6f03
remove owner tracking, the gettid() syscall isn't cheap Haldean Brown 5 years ago
3 changed file(s) with 0 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
4545 struct ubik_jobq_node *tail;
4646 struct ubik_jobq_node *recycle;
4747 size_t size;
48 int64_t owner_tid;
4948 };
5049
5150 struct ubik_jobq
620620 if (likely(r->waiting != NULL))
621621 {
622622 pthread_mutex_lock(&r->waiting->lock);
623
624623 t0 = r->node;
625624 r->waiting->nv[t0] = r->e->nv[t1];
626625 r->waiting->nt[t0] = r->e->nt[t1];
627626 setstatus(r->waiting, t0, LOADED);
628
629627 pthread_mutex_unlock(&r->waiting->lock);
630628 }
631629 if (unlikely(r->cb != NULL))
2626 void
2727 ubik_jobq_init(struct ubik_jobq *q, size_t n_workers)
2828 {
29 size_t i;
30
3129 pthread_mutex_init(&q->global_lock, NULL);
3230 ubik_galloc((void**) &q->qs, n_workers, sizeof(struct ubik_jobq_subq));
3331 q->n_queues = n_workers;
3432 q->global_head = NULL;
3533 q->global_tail = NULL;
36
37 for (i = 0; i < n_workers; i++)
38 q->qs[i].owner_tid = -1;
3934 }
4035
4136 void
8883
8984 sq = q->qs + worker_id;
9085 n = NULL;
91
92 if (sq->owner_tid == -1)
93 sq->owner_tid = ubik_gettid();
94 else if (ubik_gettid() != sq->owner_tid)
95 {
96 ubik_unreachable("shouldn't happen!");
97 }
9886
9987 if (likely(sq->size > 0))
10088 {