Page 1 of 1

Max number of job started

Posted: Thu Mar 02, 2017 9:55 am
by gmaxera
Hello,
I need to limit the number of simultaneous jobs started. Not Tasks, but jobs.
And I don't see any option into afanasy server to limit this number.

I'll explain in detail my user-case:
All my jobs contains multiple tasks and the first one is just for setting some directories, very fast and requires low capacity (10).
And when I submit 1000 jobs in a short period of time, afanasy server start all of them because the first tasks can be done and this is unwanted behaviour for me.
I'd like instead to have afanasy server start only 10 jobs (for example) and not start others until one of them has been fully completed.

Is this possible ?

Thanks,
Gianluca.

Re: Max number of job started

Posted: Thu Mar 02, 2017 10:31 am
by timurhai
Hi.
For now there is no such limit.
One way is to write a script that will check running jobs and pause/unpause some.
Or you can simple not to set such low capacity to the first task.

But it can be a feature.
( I moved the topic in a feature requests section. )

Re: Max number of job started

Posted: Thu Mar 02, 2017 11:09 am
by gmaxera
Instead of doing a script, I'd rather prefer to contribute to Afanasy if you think this could be a nice feature to add.

I was looking at the code and I found a way to implement that feature.
I was thinking to add a check inside the "bool JobAf::v_canRun()" method just above the check of max running tasks as by following proposal:

Code: Select all

	// proposed modification to check maximum 
	if( number_of_running_jobs >= getMaximumRunningJobs())
	{
		return false;
	}
		
	// check maximum running tasks:
	if(( m_max_running_tasks >= 0 ) && ( getRunningTasksNumber() >= m_max_running_tasks ))
	{
		return false;
	}
If you think it's a good place where to put such check ... then I'll try to figure out how to implement and pull a merge request.

Thanks,
Gianluca.

Re: Max number of job started

Posted: Thu Mar 02, 2017 12:58 pm
by timurhai
You should implement it in UserAf class.
And add a new max_running_jobs parameter to user.
Also you should add this parameter visualization and manipulation in GUIs.
It not very hard, but not so simple too.

Re: Max number of job started

Posted: Thu Mar 02, 2017 1:32 pm
by gmaxera
Thanks for the starting point.
I'll have a look.
Luckily, I'm a C++/Qt/Python programmer and web developer :-)

Re: Max number of job started

Posted: Thu Mar 02, 2017 2:12 pm
by timurhai
Great!
You are welcome!