Max number of job started

Feature requests discussion.
Post Reply
gmaxera
Posts: 10
Joined: Thu Feb 09, 2017 3:59 pm

Max number of job started

Post 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.
User avatar
timurhai
Site Admin
Posts: 911
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: Max number of job started

Post 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. )
Timur Hairulin
CGRU 3.3.1, Ubuntu 20.04, 22.04, MS Windows 10 (clients only).
gmaxera
Posts: 10
Joined: Thu Feb 09, 2017 3:59 pm

Re: Max number of job started

Post 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.
User avatar
timurhai
Site Admin
Posts: 911
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: Max number of job started

Post 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.
Timur Hairulin
CGRU 3.3.1, Ubuntu 20.04, 22.04, MS Windows 10 (clients only).
gmaxera
Posts: 10
Joined: Thu Feb 09, 2017 3:59 pm

Re: Max number of job started

Post by gmaxera »

Thanks for the starting point.
I'll have a look.
Luckily, I'm a C++/Qt/Python programmer and web developer :-)
User avatar
timurhai
Site Admin
Posts: 911
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: Max number of job started

Post by timurhai »

Great!
You are welcome!
Timur Hairulin
CGRU 3.3.1, Ubuntu 20.04, 22.04, MS Windows 10 (clients only).
Post Reply