With a significant number of jobs (in history and/or running), job dispatching can become very slow, in excess of 3 minutes per dispatch cycle.
This is caused by the call:
SystemLoad systemLoad = getHostLoads(em, true);
for every job being dispatched. This is the query
On our 3.x production system, New Relic reports this query taking 94% of all database time. Response time can be up to 2s, and the query can be called hundreds of times per minute.
The job dispatching code needs refactoring to avoid this expensive query being called frequently.