Message Boards Message Boards

Speed of Jobs on AWS with RemoteBatchSubmit

Posted 3 years ago

Hello,

I have been playing with the new remote batch computation capabilities in Mathematica and have come across speed issues that I do not understand. My calculation involves thousands of Fourier transforms on complex lists with tens of thousands of elements per "step".

It runs reasonably fast on my local computer with a seven year old mobile i7 (4 cores, 8 threads) but much slower on AWS. Also the speed on AWS seems to be affected by parameters that (in my understanding) should not affect it. To rule out that the jobs run on slower hardware, I created a stack with only "c5a" as allowed instance type.

All tests are performed with one master kernel and zero subkernels. On my local machine CPU load is 50 %, so the calculation uses all cores. First I tested the performance of sequential single jobs with RemoteBatchSubmit:

single job speed

The achieved speeds are not great, but still something I could work with. When working with array batch jobs it gets more confusing and slower though.

When running an array job (RemoteBatchMapSubmit, 16 evaluations, 16 jobs, 1 vCPU each) every child job sees just one CPU, but 64 GB memory, the speed started at 0.8 steps/s when only one child was running but dropped to 0.05 steps/s when multiple ones were - should different child jobs influence each other like this?

To test this I started a single job with "VCPUCount" -> 2. This job reported 128 GB of $SystemMemory and ran with 0.9 steps/s. I started an additional and identical single job and the speed of both running jobs dropped to 0.6 steps/s. After starting a third identical job the speed of all three single jobs dropped to 0.3 steps/s.

Has anyone else experienced these issues or has a better understanding to explain what is happening? I would love to use this feature, but as of now there is no benefit, it runs much faster locally.

Thank you!

POSTED BY: Stefan Popien
3 Replies
Posted 3 years ago

Hi Jesse, thank you very much for the detailed description and the suggestions. I am working on a different project right now, but will try out your points as soon as I get to work on this some more.

I think setting the thread numbers might do the trick, as my calculation is not using any subkernels, but clearly the Mathematica functions I use are using multiple threads (e.g. 4 threads on my local machine with 4 physical cores). I will test this as well as comparing the speed with Intel based instances and limiting the threads to half the hardware threads to achieve one thread per physical core.

A lot of what you wrote here would be good to have in the documentation. Even though I read early on that vCPUs do not correspond to physical cores, it still took a while to understand how all the numbers are connected. For example, it was not clar to me in the beginning if the vCPU count given for RemoteBatchMapSubmit is per one job or per the whole array.

Thank you so much for your help!

POSTED BY: Stefan Popien
POSTED BY: Jesse Friedman

Regarding the slowdowns you saw with multiple concurrent jobs, it occurred to me that although $ProcessorCount is overridden to reflect the "VCPUCount" of each job, the processor counts used for internal multithreaded computation will still reflect the host instance's total physical core count. This would cause excessive contention with multiple concurrent jobs, where e.g. an N-physical-core instance has X jobs each running N software threads, resulting in N * X total threads contending for only N physical cores. You can change this internal processor count by evaluating at the start of your job code (or for array batch jobs, in the Initialization option):

SetSystemOptions["ParallelOptions" -> {
    "MKLThreadNumber" -> $ProcessorCount,
    "ParallelThreadNumber" -> $ProcessorCount
}]

Let me know if this has any effect for your application. This is probably something RemoteBatchSubmit should be doing automatically; I will look into having it do so.

POSTED BY: Jesse Friedman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract