michaelforney / samurai

ninja-compatible build tool written in C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jobs scheduled in a different order than ninja

michaelforney opened this issue · comments

ninja schedules jobs based on the first item in a std::set<Edge *>, which I think means edges with lower pointer values are started first.

https://github.com/ninja-build/ninja/blob/e0bc2e5fd9036a31d507881e1383adde3672aaef/src/build.cc#L405

samurai uses a singly-linked list, inserting at the front, so the most recently queued edge is started first.

samurai/build.c

Lines 95 to 104 in 854f648

struct edge **front = &work;
if (e->pool && e->rule != &phonyrule) {
if (e->pool->numjobs == e->pool->maxjobs)
front = &e->pool->work;
else
++e->pool->numjobs;
}
e->worknext = *front;
*front = e;

I'm not interested in matching ninja's behavior here, since any problems that arise are due to buggy build graphs, and I don't think a binary tree is the right data structure for a queue.

We could possibly try to keep track of the end pointer and insert at the back instead, but not sure if that's worth the trouble.

Added a note about this in the README.