if i have a process that i wish to run in the background on all cores, it can make the system extremely sluggish, even running at nice +20. Running out of memory or io is not the issue. Is there any easy way of reducing the cpu priority below this, or do i have to resort to starting the background process with fewer workerthreads than the number of cores, or some other kind of cpu management internal to the process.
idprio 31 commandhere
commandhere to idle priority. And
cpuset -l 0-3 commandhere
would limit it to cpu cores 0-3 only. To combine them:
cpuset -l 0 idprio 31 commandhere
(order could be switched to
idprio 31 cpuset -l 0-3 commandhere, I don't think it matters). Which command or combination of commands arguments (priority or cpu list) depends on your workload of course, YMMV, etc.
Use the limit command. As explained in the manpage :
limit, ulimit, unlimit - set or get limitations on the system resources available to the current shell and its descendents
Here is a link to the manpage.
Use a jail, it can be used to isolate a process from the rest of your system and can limit CPU and memory usage too.
As explained here :
FreeBSD provides several methods for an administrator to limit the amount of system resources an individual may use. Disk quotas limit the amount of disk space available to users. Quotas are discussed in Section 17.11, “Disk Quotas”.
Limits to other resources, such as CPU and memory, can be set using either a flat file or a command to configure a resource limits database. The traditional method defines login classes by editing /etc/login.conf. While this method is still supported, any changes require a multi-step process of editing this file, rebuilding the resource database, making necessary changes to /etc/master.passwd, and rebuilding the password database. This can become time consuming, depending upon the number of users to configure.