Optimize execution of processes by CPU core

Farhan Khan farhan at farhan.codes
Wed Feb 20 17:35:31 UTC 2019


Hi all,

I am trying to optimize the execution of a CPU-intensive workload where I am running multiple instances of a program. The moment the program ends (expected behavior), the calling shell script verifies the results and if its good it reruns the program. The machines I am running this on have 8 cores, but ps reports that some of the processes frequently run on the same CPU, so I suspect I am not getting optimized performance. If possible, and if most efficient, I would like to run each process on its own CPU core.

Are there any best practices on how to run something like this? I understand cpuset can perform some functionality around this, but I do not understand the tooling (The man page speaks of a CPU set?) Would I do something like "cpuset -c -l 0 program arg1 arg2 arg3" in one script, and then "cpuset -c -l 1 program arg1 arg2 arg3" in the next up to 7?

Obviously it would be best to re-write the program to handle multiple threads in in an optimized way, but that would take more time than the optimization would likely save.

Thanks,

---
Farhan Khan


More information about the freebsd-hackers mailing list