Question
Norman W. Freeman · Oct 8

Starting a new job with "job" command take more time than expected

I use the following code to start a start a job :

Class MyClass Extends (...)
{
    ClassMethod Foo()
    {
       job $CLASSMETHOD("MyClass","MyMethod") //take forever depending hardware
    }

    ClassMethod MyMethod()
    {
       //do database related stuff
    }
}

On local environment, calling Foo() is instantaneous (a few ms). On production/test servers (which have much better hardware than local) calling this function is slow and take between 200 ms to 800 ms. Obviously starting a new job with "job" command take lot of time on those environments.

I don't know the reason of this. Is this a well know issue ?

00
2 0 3 119
Log in or sign up to continue

This is likely an issue with the OS - it shouldn't take that long to create a new process. It might be worth gathering an OS-level trace of your process while you do this to narrow down where the time is spent. Depending on platform, the trace can be gathered with strace, truss, Windows process monitor, or others.

Thanks for the info. While there is probably something wrong with the OS (Windows in this case), is there a lighter way in Caché to execute a routine in a separate task ? I am thinking something like starting a new thread or using a thread pool. Does such thing exists ?

If creating processes is slow, it might be worth looking into using Job Servers. This is a pool of processes that wait to handle 'job' requests.