Assign a process to a core on start

Hi,

In Ubuntu it is possible to start a process in a specified core using taskset command (taskset 0 myproc it will execute myproc in core 0).

I know it is possible a process(pid) can bind to a core using pbind. But my requirement is to start a process in a specified core.

How it is possible in Solaris?

Thank you.

man psrset

It won't. You should actually run

taskset 1 myproc

to bind your process to core #0.

You can still use pbind. Just wrap your command with a script that bind itself to the required core then execute the command. As a processor binding is inherited, that would fulfill the requirement. eg:

#!/bin/ksh
pbind -b 0 $$
exec myproc "$@"

Beware that achenle's processor set suggestion (psrset) is about exclusive processor binding while both Linux taskset and Solaris pbind create non-exclusive binding, i.e. the processor can still be used by other processes. This might not be what you expect.

1 Like

I do wonder what problem is being solved here. Binding to processors is almost never worthwhile. It might get you somewhat better performance for a memory-latency-bound application on a NUMA machine where you can guarantee your application uses memory with better locality to the processor(s) you bind to, but that's about it.

If you're grasping that hard for every last processor cycle, how much time have you spent profiling your application and improving its performance directly based on profiled performance data?

Processor binding is indeed almost never a proper way to enhance to performance of the bounded process. It might however help improving the performance of other processes by limiting the CPU resources the bounded process can use.

Another usage is to approximate the process performance that would be observed on a single core server while you "only" have a multi-core one to test it.