help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Evenly distributing job slots


From: Paul Smith
Subject: Re: Evenly distributing job slots
Date: Tue, 06 Jun 2023 10:19:49 -0400
User-agent: Evolution 3.48.2 (by Flathub.org)

On Tue, 2023-06-06 at 00:00 -0400, Siyang He wrote:
> Ideally I would like to calculate the thread-count-per-instance from
> entirely within foo. I managed to get the thread count, but I am
> having trouble counting the number of instances currently running. As
> far as I know, this number is not passed by Make.

I'm not sure what you mean by "currently running".  If you mean exactly
that, then there is of course no way to know that.  The jobserver is
not a separate process that keeps track of what's running and what's
not running, where you can query it to see how many are left.

Any individual make instance has no idea how many jobs are running
across all the other make instances at any given time.  All it knows is
whether it's allowed to create one more job, or not.

But, I don't understand what you want to do anyway.  What is the
purpose of learning how many outstanding jobs there are?  The instant
after you determine this, and put back the tokens, whatever you learned
will be obsolete anyway as some other job could be started that takes
one or more tokens.

If you know the total job count (which you can get from the command
line arguments) and you know how many total "foo"'s you want to start,
then it's a simple matter of math to see how many jobs each "foo"
should be allocated to evenly distribute them.

Of course this assumes that you are not running any other jobs besides
"foo".



reply via email to

[Prev in Thread] Current Thread [Next in Thread]